Windows (v3): Sometimes clicking the systray notifcation menu icon crashes
Description
All I did was run the systray-menu example and click the icon over and over. Eventually it crashes. (I've seen this behavior in our own app too without repeatedly clicking the icon. Probably some kind of race.)
PS C:\Users\jmaguire\src\wails\v3\examples> cd .\systray-menu\
PS C:\Users\jmaguire\src\wails\v3\examples\systray-menu> go run .
Mar 19 15:05:30.736 INF Build Info: Wails=v3.0.0-dev Compiler=go1.24.0 -buildmode=exe -compiler=gc CGO_ENABLED=0 GOARCH=amd64 GOOS=windows GOAMD64=v1
Mar 19 15:05:30.738 INF AssetServer Info: middleware=true handler=true
Mar 19 15:05:30.738 INF Platform Info: Go-WebView2Loader=true WebView2=134.0.3124.72 ID=24H2 Name="Windows 10 Pro" Version="2009 (Build: 26100)" Branding="Windows 11 Pro"
2025/03/19 15:05:30 [WebView2] Environment created successfully
Mar 19 15:05:30.985 INF [AssetFileServerFS] Handling request url=/ file=.
Mar 19 15:05:30.987 INF Asset Request: windowName="" windowID=1 code=200 method=GET path=/ duration=1.6087ms
Mar 19 15:05:31.007 INF Asset Request: windowName="" windowID=1 code=200 method=GET path=/runtime.js duration=505.6µs
Mar 19 15:05:31.036 INF [AssetFileServerFS] Handling request url=/favicon.ico file=favicon.ico
Mar 19 15:05:31.036 INF Asset Request: windowName="" windowID=1 code=404 method=GET path=/favicon.ico duration=0s
Mar 19 15:05:38.751 ERR
******************************** FATAL *********************************
* There has been a catastrophic failure in your application. *
**************************** Error Details *****************************
TrackPopupMenu failed************************************************************************
[0319/150538.752:ERROR:window_impl.cc(122)] Failed to unregister class Chrome_WidgetWin_0. Error = 1412
exit status 1
https://discord.com/channels/1042734330029547630/1351996470974484632
To Reproduce
cd v3/examples/systray-menugo run .- Click the systray icon a bunch
Expected behaviour
No crashes :)
Screenshots
No response
Attempted Fixes
No response
System Details
Wails (v3.0.0-alpha.9) Wails Doctor
# System
┌──────────────────────────────────────────────────────────────────────────────────────────────┐
| Name | Windows 10 Pro |
| Version | 2009 (Build: 26100) |
| ID | 24H2 |
| Branding | Windows 11 Pro |
| Platform | windows |
| Architecture | amd64 |
| Go WebView2Loader | true |
| WebView2 Version | 134.0.3124.72 |
| CPU 1 | Apple Silicon |
| CPU 2 | Apple Silicon |
| CPU 3 | Apple Silicon |
| CPU 4 | Apple Silicon |
| GPU 1 | Parallels Display Adapter (WDDM) (Parallels) - Driver: 20.18.2022.55879 |
| Memory | 8GB |
└──────────────────────────────────────────────────────────────────────────────────────────────┘
# Build Environment
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Wails CLI | v3.0.0-alpha.9 |
| Go Version | go1.24.0 |
| -buildmode | exe |
| -compiler | gc |
| CGO_ENABLED | 0 |
| DefaultGODEBUG | asynctimerchan=1,gotestjsonbuildtext=1,gotypesalias=0,httpservecontentkeepheaders=1,multipathtcp=0,randseednop=0,rsa1024min=0,tls3des=1,tlsmlkem=0,x509keypairleaf=0,x509negativeserial=1,x509rsacrt=0,x509usepolicies=0 |
| GOAMD64 | v1 |
| GOARCH | amd64 |
| GOOS | windows |
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
# Dependencies
┌───────────────────────────┐
| NSIS | Not Installed |
| npm | 10.9.2 |
└─ * - Optional Dependency ─┘
# Diagnosis
SUCCESS Your system is ready for Wails development!
Need documentation? Run: wails3 docs
♥ If Wails is useful to you or your company, please consider sponsoring the project: wails3 sponsor
PS C:\Users\jmaguire\src\wails\v3\examples\systray-menu>
Additional context
No response
I'm guessing that there's a race condition between the popup being drawn and the TrackPopupMenu call. We could incorporate a debounce. Was it the button to show the menu over and over again?
I am clicking the icon here repeatedly. In my first repro, I clicked nothing but the icon over and over:
But I did find another reliable way to reproduce it... if I first click on the network icon next to it, and then try clicking on the Wails icon, the menu opens, but I can't click off of it to close it. Then, if I click it a second time, I get the same crash from above.
https://github.com/user-attachments/assets/6bc3561f-5345-4c76-9bd8-07f97a14472e
So, I can confirm that the issue with being unable to "click off" the menu seems to be a Windows bug (I can reproduce this with Windows Defender, and it actually pops the menu "under" the taskbar.) But I think we should be able to avoid a crash in this case still.
https://github.com/user-attachments/assets/048cdf76-90d6-4a81-9f8a-1882c7bc7cde
On MacOs on a fresh install of a wails3 project, following the docs for the systray also crashes the program when clicking outside of the application.
https://github.com/user-attachments/assets/8419c0d9-7e9f-4711-8a30-8a437816d3ae
(the recording doesn't show the mouse icon changes to a loading icon when hovering over the wails app)
System
┌──────────────────────────────────────────────────┐ | Name | MacOS | | Version | 14.5 | | Branding | Sonoma | | Platform | darwin | | Architecture | arm64 | | Apple Silicon | true | └──────────────────────────────────────────────────┘
Build Environment
Wails CLI | v3.0.0-alpha.9 Go Version | go1.24.1
@johnmaguire - I've pushed a fix into the beta-readiness branch which should be merged with v3-alpha shortly @PietervdWerk - please raise your issue on discord.
This specific issue seems to be solved both here and in mega-menu-fixes, though it still isn't possible to close the menu without clicking on one of the options in it, though as John said, that seems to exist in other Windows apps.
However, when testing out the beta-readiness branch, I find that hidden windows are incorrectly shown when the app starts up. There are no contents shown, but the frame is opened immediately. I'll create a reproduction and open a discord discussion about it.
Thanks @IanVS ! Really appreciate your time on this. Feels like we're close (at least for windows!)
Hey @leaanthony - thanks for your work on this issue above! Do you still intend to merge the fix into the v3-alpha branch? (Perhaps before cutting v3-alpha.10?) thx!
I also encountered the same crash problem in macos 12
# System
┌──────────────────────────────────────────────────────────────────────────┐
| Name | MacOS |
| Version | 12.7.6 |
| ID | 21H1320 |
| Branding | Monterey |
| Platform | darwin |
| Architecture | amd64 |
| Apple Silicon | unknown |
| CPU | Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz |
| CPU | Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz |
| GPU | cores, Metal Family: Supported, Metal GPUFamily macOS 2 |
| | Metal Family: Supported, Metal GPUFamily macOS 2 |
| Memory | 16 GB |
└──────────────────────────────────────────────────────────────────────────┘
# Build Environment
┌────────────────────────────────┐
| Wails CLI | v3.0.0-alpha.27 |
| Go Version | go1.24.0 |
| -buildmode | exe |
| -compiler | gc |
| CGO_CFLAGS | |
| CGO_CPPFLAGS | |
| CGO_CXXFLAGS | |
| CGO_ENABLED | 1 |
| CGO_LDFLAGS | |
| GOAMD64 | v1 |
| GOARCH | amd64 |
| GOOS | darwin |
└────────────────────────────────┘
# Dependencies
┌────────────────────────────────────────────────────────────────────────┐
| Xcode cli tools | 2395 |
| npm | 10.8.1 |
| *NSIS | Not Installed. Install with `brew install makensis`. |
| |
└─────────────────────── * - Optional Dependency ────────────────────────┘