Fix keyring unlock blocking the Fyne event loop on startup (#900)

GetServerPassword can block while the system keyring daemon shows its
unlock dialog. Calling it synchronously on the Fyne main thread froze
the event loop, causing Wayland compositors to hide the window.

Move the keyring lookup into a goroutine and dispatch back to the Fyne
thread to show the connecting dialog and attempt the connection.
This commit is contained in:
Mark Stenglein
2026-04-06 07:23:55 -07:00
committed by GitHub
parent 7db96e8056
commit d985154062
+17 -7
View File
@@ -49,14 +49,24 @@ func (m *Controller) PromptForFirstServer() {
// DoConnectToServerWorkflow does the workflow for connecting to the last active server on startup
func (c *Controller) DoConnectToServerWorkflow(server *backend.ServerConfig) {
pass, err := c.App.ServerManager.GetServerPassword(server.ID)
if err != nil {
log.Printf("error getting password from keyring: %v", err)
c.PromptForLoginAndConnect()
return
}
// GetServerPassword may block on keyring unlock (showing a system dialog),
// so run it in a goroutine to avoid freezing the Fyne event loop.
go func() {
pass, err := c.App.ServerManager.GetServerPassword(server.ID)
if err != nil {
log.Printf("error getting password from keyring: %v", err)
fyne.Do(c.PromptForLoginAndConnect)
return
}
// try connecting to last used server - set up cancelable modal dialog
// Password retrieved; show the dialog and connect from the Fyne thread
fyne.Do(func() {
c.doConnectWithPassword(server, pass)
})
}()
}
func (c *Controller) doConnectWithPassword(server *backend.ServerConfig, pass string) {
canceled := false
ctx, cancel := context.WithCancel(context.Background())
dlg := dialog.NewCustom(lang.L("Connecting"), lang.L("Cancel"),