Files
magpie/internal/gui
yetone 93906ba755 gui: a second launch on Windows hands over at once, not after 30s (shangyuan0818 on X)
On Windows, opening magpie from the Start menu while it already ran took
over 10s to show the window, longer than a cold start. fb6b4de0a made
every start wait, up to 30s, for the WebView2 profile folder's lockfile
before the app is made. A second launch hands over to the running magpie
only as the app is made (Wails' single instance, in application.New), and
the running magpie's WebView2 holds that folder for as long as it runs,
so every second launch waited the whole 30s, then handed over.

Now the wait is skipped when Wails' single instance mutex for this config
(wails-app-<id>-sim) is held: a magpie runs, and the launch goes straight
on to hand over. A restart after an update or a failed WebView2 start
still waits: the magpie before has ended by then (AwaitPredecessor), so
the mutex is free and only its msedgewebview2 can still hold the folder.

Run:
- Reproduced on xiaomi-gpu (Windows 11) with builds of 406ad72f1 and of
  this commit, sandbox USERPROFILE/APPDATA/LOCALAPPDATA, MAGPIE_ADDR
  :3461, HKCU magpie/ccswitch/App Paths/Uninstall keys exported and put
  back. ssh has no desktop (the real app crashes in uxtheme there, and no
  one was signed in for an interactive task), so a stand-in held what a
  running magpie holds: the single instance mutex for the sandbox's
  config and EBWebView\lockfile without sharing. Launching magpie.exe
  with no arguments, as the Start menu does, three times each: before,
  the launch quit after 30240, 30232, 30234 ms ("still held by another
  process after 30s"); after, 189, 161, 166 ms. That Wails took the
  launch for a second one also shows the mutex name matches Wails'.
- TestWebView2ReadyDoesNotWaitOnTheRunningMagpie (Windows): red with the
  held check turned off by hand (waited 20.06s), green with it.
- go test -count=1 ./internal/gui on mote: ok (150s). On xiaomi-gpu: 9
  reds, the same 9 at origin/main 633ab58e9 and all filed (#6068, #5324,
  #5928, #6059).
- gofmt -l; go vet ./internal/gui on darwin, windows, linux -tags nogui
  and windows -tags nogui (on mote: mica is out of disk).
Not tried: the real tray app with a desktop session and a Start menu
click, for the reason above.
2026-11-13 14:01:50 +08:00
..
…
…
…
…
…
…
…