Skip to content

fix(desktop): keep the tray responsive when the webview is wedged#3862

Merged
esengine merged 1 commit into
main-v2from
fix/3834-tray-tap-offloop
Jun 10, 2026
Merged

fix(desktop): keep the tray responsive when the webview is wedged#3862
esengine merged 1 commit into
main-v2from
fix/3834-tray-tap-offloop

Conversation

@esengine

Copy link
Copy Markdown
Owner

Problem

After minimizing to the tray, then sleeping the machine and losing the network for a while, clicking the Reasonix tray icon does nothing — the icon is still there (selectable via Win+B) but no click responds (#3834).

Root cause

fyne.io/systray dispatches a left-click straight from its Win32 message loop:

nativeLoop → GetMessage/DispatchMessage → wndProc → WM_LBUTTONUP → systrayLeftClick() → tappedLeft()

tappedLeft is our SetOnTapped(func(){ a.showFromTray() }), which runs runtime.WindowShow. When the webview / main thread is wedged (a known post-sleep + dropped-connection state), that call blocks, so wndProc never returns and the tray's message pump freezes — the icon stays registered with the shell (hence selectable) but stops processing any click.

The tray menu items don't hit this: they're already decoupled onto goroutines (for range item.ClickedCh). The left-tap handler was the last callback still running on the message loop.

Fix

Dispatch showFromTray on a goroutine so wndProc returns immediately and the pump never blocks — matching the menu-item pattern. A wedged WindowShow then leaks a short-lived goroutine at worst (it completes when the webview recovers) instead of freezing the whole tray.

Test

No unit test — this is a threading fix on a third-party Win32 callback (the menu-item decoupling it mirrors is likewise untested). Verified cd desktop && go build ./... && go vet ./....

Closes #3834

The left-click handler set via systray.SetOnTapped runs synchronously
inside the tray's Win32 wndProc. When showFromTray blocks — runtime.WindowShow
can stall while the webview/main thread is wedged after sleep + a dropped
network connection — wndProc never returns and the tray's message pump
freezes: the icon stays in the tray (selectable via Win+B) but no click does
anything. The menu items were already decoupled via goroutines; the tap
handler was the last callback running on the message loop.

Dispatch showFromTray on a goroutine so the pump is never blocked.

Closes #3834
@esengine esengine requested a review from SivanCola as a code owner June 10, 2026 14:03
@github-actions github-actions Bot added desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 10, 2026
@esengine esengine merged commit 924c691 into main-v2 Jun 10, 2026
14 checks passed
@esengine esengine deleted the fix/3834-tray-tap-offloop branch June 10, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 最小化托盘无响应

1 participant