wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.26k stars 1.22k forks source link

When I make the system tray flicker, the null pointer panic #3764

Closed prestonTao closed 1 month ago

prestonTao commented 1 month ago

Description

panic: panic called with nil argument

goroutine 1 [running, locked to thread]: github.com/wailsapp/wails/v3/pkg/application.(windowsSystemTray).setIcon(0xc00047c3c0, {0x27d5ac0?, 0x0?, 0xc00066eeb8?}) C:/Users/Preston/go/pkg/mod/github.com/wailsapp/wails/v3@v3.0.0-alpha.7/pkg/application/systemtray_windows.go:276 +0x65 github.com/wailsapp/wails/v3/pkg/application.(SystemTray).SetIcon.func1() C:/Users/Preston/go/pkg/mod/github.com/wailsapp/wails/v3@v3.0.0-alpha.7/pkg/application/systemtray.go:136 +0x32 github.com/wailsapp/wails/v3/pkg/application.InvokeSync.func1() C:/Users/Preston/go/pkg/mod/github.com/wailsapp/wails/v3@v3.0.0-alpha.7/pkg/application/mainthread.go:28 +0x42 github.com/wailsapp/wails/v3/pkg/application.(windowsApp).invokeCallback(0xc0002de1c0, 0xc00000007f?, 0x8?) C:/Users/Preston/go/pkg/mod/github.com/wailsapp/wails/v3@v3.0.0-alpha.7/pkg/application/mainthread_windows.go:125 +0x2ce github.com/wailsapp/wails/v3/pkg/application.(windowsApp).wndProc(0x0?, 0xc00066f0e8?, 0x66f088?, 0x0?, 0xc00066f320?) C:/Users/Preston/go/pkg/mod/github.com/wailsapp/wails/v3@v3.0.0-alpha.7/pkg/application/application_windows.go:227 +0x352 syscall.SyscallN(0x7ffd037d7ba0, {0xc0006257f8?, 0x1, 0x388753?}) C:/Users/Preston/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/runtime/syscall_windows.go:544 +0x11d syscall.(Proc).Call(0x304945?, {0xc0006257f8, 0x1, 0x1}) C:/Users/Preston/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/syscall/dll_windows.go:166 +0x39 syscall.(LazyProc).Call(0xc000400c00, {0xc0006257f8, 0x1, 0x1}) C:/Users/Preston/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/syscall/dll_windows.go:286 +0x45 github.com/wailsapp/wails/v3/pkg/w32.DispatchMessage(0x14c868673d0?) C:/Users/Preston/go/pkg/mod/github.com/wailsapp/wails/v3@v3.0.0-alpha.7/pkg/w32/user32.go:441 +0x45 github.com/wailsapp/wails/v3/pkg/application.(windowsApp).runMainLoop(0xc0002de1c0) C:/Users/Preston/go/pkg/mod/github.com/wailsapp/wails/v3@v3.0.0-alpha.7/pkg/application/mainthread_windows.go:64 +0xa5 github.com/wailsapp/wails/v3/pkg/application.(windowsApp).run(0xc0002de1c0) C:/Users/Preston/go/pkg/mod/github.com/wailsapp/wails/v3@v3.0.0-alpha.7/pkg/application/application_windows.go:185 +0xe5 github.com/wailsapp/wails/v3/pkg/application.(*App).Run(0xc000417188) C:/Users/Preston/go/pkg/mod/github.com/wailsapp/wails/v3@v3.0.0-alpha.7/pkg/application/application.go:618 +0x3fe main.main() D:/workspaces/go/web3_gui/gui/main.go:91 +0x2f2 [0921/144654.448:ERROR:window_impl.cc(121)] Failed to unregister class Chrome_WidgetWin_0. Error = 1412

To Reproduce

for { time.Sleep(time.Second / 3) sTray.SetIcon(systemTrayLightPngData) time.Sleep(time.Second / 3) sTray.SetIcon(systemTrayPngData) }

Expected behaviour

I won't panic

Screenshots

No response

Attempted Fixes

No response

System Details

# System
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Name              | Windows 10 Pro                                                                                    |
| Version           | 2009 (Build: 22631)
|
| ID                | 23H2
|
| Branding          | Windows 11 专业版
|
| Platform          | windows
|
| Architecture      | amd64
|
| Go WebView2Loader | true
|
| WebView2 Version  | 128.0.2739.79
|
| CPU               | AMD Ryzen 7 7840HS w/ Radeon 780M Graphics
|
| GPU 1             | OrayIddDriver Device (Shanghai Best Oray Information Technology Co., Ltd.) - Driver: 17.1.58.818  |
| GPU 2             | AMD Radeon RX 7600M XT (Advanced Micro Devices, Inc.) - Driver: 31.0.24019.1006
|
| GPU 3             | AMD Radeon 780M Graphics (Advanced Micro Devices, Inc.) - Driver: 31.0.24019.1006
|
| Memory            | 64GB
|
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Build Environment
┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-alpha.7                           |
| Go Version   | go1.22.4                                 |
| Revision     | 860d02d1fe7c7e11731d9e0c2dc617d0e80cdc39 |
| Modified     | true                                     |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOAMD64      | v1                                       |
| GOARCH       | amd64                                    |
| GOOS         | windows                                  |
| vcs          | git                                      |
| vcs.modified | true                                     |
| vcs.revision | 860d02d1fe7c7e11731d9e0c2dc617d0e80cdc39 |
| vcs.time     | 2024-09-18T11:48:26Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────┐
| npm  | 10.5.2             |
| NSIS | Not Installed      |
└─ * - Optional Dependency ─┘

Additional context

No response

prestonTao commented 1 month ago

After running for a few minutes, it will reproduce

prestonTao commented 1 month ago

The SetIcon method was accidentally set to nil, which has been resolved. sTray.SetIcon(nil)

leaanthony commented 1 month ago

Hi there! Thanks for this feedback. Whilst v3 is in alpha, we have a strict feedback procedure outlined here: https://v3alpha.wails.io/getting-started/feedback This is to reduce noise whilst the branch is unstable and keep all the information in one place. We'd love to have you as part of the v3 feedback loop so please consider opening a new post there. Just a copy and paste would be fine. Closing this for now. Thanks again 🙏