Skip to content

fix(desktop): keep Windows tray loop on locked thread#3717

Merged
esengine merged 1 commit into
esengine:main-v2from
wade19990814-hue:codex/fix-windows-tray-thread
Jun 9, 2026
Merged

fix(desktop): keep Windows tray loop on locked thread#3717
esengine merged 1 commit into
esengine:main-v2from
wade19990814-hue:codex/fix-windows-tray-thread

Conversation

@wade19990814-hue

Copy link
Copy Markdown
Contributor

What

Keep the Windows systray event loop on a locked OS thread.

Fixes #3516.

Also addresses the tray right-click/menu responsiveness symptoms reported in #3394 and the tray portion of #3548. The MCP orphan-process note in #3548 is a separate issue and is intentionally out of scope for this PR.

Why

We caught a live repro on Windows with desktop v1.4.0 where the tray icon stopped responding to right click while the app was hidden:

  • reasonix-desktop.exe was still alive and Responding=True.
  • The main Wails window was hidden but not hung.
  • The systray hidden window (SystrayClass) still existed but IsHungAppWindow(SystrayClass) == true.
  • The Wails window (wailsWindow) reported IsHungAppWindow(...) == false.

That points to the systray Win32 message loop becoming stuck independently of the main Wails window. fyne.io/systray relies on Win32 hidden-window messages on Windows, so the tray loop should stay pinned to one OS thread.

How

  • Wrap the Windows systray loop in a helper that calls runtime.LockOSThread() before systray.Run(...).
  • Add a Windows-only regression test that verifies the helper does not move OS threads across scheduler yields.

Testing

  • go test . -run 'TestDesktopTrayLoopRunsOnLockedOSThread|TestTrayMenuLabelsFollowLocale|TestBeforeCloseAllowsSystemQuitWhenBackgroundCloseEnabled' -count=1
  • wails build
  • Windows manual test passed locally: launch the built desktop app, enable close-to-tray/background behavior, close to tray, repeatedly use the tray right-click menu, and confirm Open/Quit remain responsive.

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Windows: the desktop module vets clean and TestDesktopTrayLoopRunsOnLockedOSThread passes, confirming the systray loop stays pinned to one OS thread across scheduler yields. This is the correct remedy for #3516 — fyne.io/systray's Win32 message loop must pump messages on the same thread that created the hidden window, and base code ran it on a migratable goroutine. Thanks for the live repro write-up and the regression test.

@esengine esengine merged commit 4d83146 into esengine:main-v2 Jun 9, 2026
14 checks passed
@wade19990814-hue wade19990814-hue deleted the codex/fix-windows-tray-thread branch June 9, 2026 16:04
SuMuxi66 pushed a commit to SuMuxi66/DeepSeek-Reasonix that referenced this pull request Jun 10, 2026
Wrap the Windows systray loop in runtime.LockOSThread() so fyne.io/systray's Win32 hidden-window message loop stays pinned to one OS thread; the scheduler migrating the goroutine left the tray unresponsive while the app was in the tray. Fixes esengine#3516.
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]: 后台模式下右键无响应

2 participants