Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] When a window is disabled, clicking the taskbar icon after the window loses focus causes a crash. #4168

Open
Astrov0 opened this issue Mar 27, 2025 · 0 comments
Labels
Bug Something isn't working

Comments

@Astrov0
Copy link

Astrov0 commented Mar 27, 2025

Description

When a window is disabled, clicking the taskbar icon after the window loses focus causes a crash.

Create two windows using the following code.

func main() {
  app := application.New(application.Options{
    Name:        "JS Window API Demo",
    Description: "A demo of the JS Window API",
    Mac: application.MacOptions{
      ApplicationShouldTerminateAfterLastWindowClosed: true,
    },
    Assets: application.AssetOptions{
      Handler: application.BundledAssetFileServer(assets),
    },
  })

  win1 := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
    Title:  "JS Window API Demo",
    Width:  800,
    Height: 600,
  })
  win1Menu := application.NewMenu()
  win1Menu.Add("disabled").OnClick(func(ctx *application.Context) {
    win1.SetEnabled(false)
  })
  win1.SetMenu(win1Menu)

  win2 := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
    Title:   "JS Window API Demo2",
    Width:   800,
    Height:  600,
  })
  win2Menu := application.NewMenu()
  win2Menu.Add("disabled").OnClick(func(ctx *application.Context) {
    win2.SetEnabled(false)
  })
  win2.SetMenu(win2Menu)

  err := app.Run()

  if err != nil {
    log.Fatal(err.Error())
  }
}

Disabling window2 will not crash, disabling window1 will crash.

Crashes only when switching to a disabled window.

To Reproduce

2025-03-26.07-08-24.mp4

log

Mar 26 07:25:08.875 INF Build Info: Wails=v3.0.0-alpha.9 Compiler=go1.24.0 -buildmode=exe -compiler=gc CGO_ENABLED=1 CGO_LDFLAGS="" GOAMD64=v1 CGO_CFLAGS="" CGO_CPPFLAGS="" CGO_CXXFLAGS="" GOARCH=amd64 GOOS=windows
Mar 26 07:25:08.878 INF AssetServer Info: middleware=true handler=true
Mar 26 07:25:08.878 INF Platform Info: Go-WebView2Loader=true WebView2=134.0.3124.83 ID=24H2 Name="Windows 10 Pro" Version="2009 (Build: 26100)" Branding="Windows 11 专业版"
2025/03/26 07:25:08 ApplicationDidFinishLaunching
2025/03/26 07:25:08 [WebView2] Environment created successfully
Mar 26 07:25:09.493 INF [AssetFileServerFS] Handling request url=/ file=.
Mar 26 07:25:09.495 INF Asset Request: windowName="" windowID=1 code=200 method=GET path=/ duration=1.9516ms
Mar 26 07:25:09.581 INF Asset Request: windowName="" windowID=1 code=200 method=GET path=/runtime.js duration=0s
Mar 26 07:25:09.682 INF [AssetFileServerFS] Handling request url=/favicon.ico file=favicon.ico
Mar 26 07:25:09.682 INF Asset Request: windowName="" windowID=1 code=404 method=GET path=/favicon.ico duration=0s
[WebView2 Error] The parameter is incorrect.

Stack trace:
2025/03/26 07:25:13 1: github.com/wailsapp/go-webview2/pkg/edge.(*Chromium).errorCallback
        E:/Ruanjian/Gopath/pkg/mod/github.com/wailsapp/[email protected]/pkg/edge/chromium.go:151
2025/03/26 07:25:13 2: github.com/wailsapp/go-webview2/pkg/edge.(*Chromium).Focus
        E:/Ruanjian/Gopath/pkg/mod/github.com/wailsapp/[email protected]/pkg/edge/chromium.go:575
2025/03/26 07:25:13 3: github.com/wailsapp/wails/v3/pkg/application.(*windowsWebviewWindow).focus
        F:/Atom/Downloads/wails-3-alpha/wails-3-alpha/v3/pkg/application/webview_window_windows.go:789
2025/03/26 07:25:13 4: github.com/wailsapp/wails/v3/pkg/application.(*windowsWebviewWindow).WndProc
        F:/Atom/Downloads/wails-3-alpha/wails-3-alpha/v3/pkg/application/webview_window_windows.go:1151
2025/03/26 07:25:13 5: github.com/wailsapp/wails/v3/pkg/application.(*windowsApp).wndProc
        F:/Atom/Downloads/wails-3-alpha/wails-3-alpha/v3/pkg/application/application_windows.go:256
2025/03/26 07:25:13 6: runtime.callbackWrap
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/runtime/syscall_windows.go:396
2025/03/26 07:25:13 7: runtime.cgocallbackg1
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/runtime/cgocall.go:444
2025/03/26 07:25:13 8: runtime.cgocallbackg
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/runtime/cgocall.go:350
2025/03/26 07:25:13 9: runtime.cgocallback
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/runtime/asm_amd64.s:1084
2025/03/26 07:25:13 10: runtime.systemstack_switch
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/runtime/asm_amd64.s:479
2025/03/26 07:25:13 11: runtime.cgocall
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/runtime/cgocall.go:185
2025/03/26 07:25:13 12: runtime.syscall_syscalln
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/runtime/syscall_windows.go:521
2025/03/26 07:25:13 13: syscall.SyscallN
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/runtime/syscall_windows.go:500
2025/03/26 07:25:13 14: syscall.(*Proc).Call
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/syscall/dll_windows.go:167
2025/03/26 07:25:13 15: syscall.(*LazyProc).Call
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/syscall/dll_windows.go:287
2025/03/26 07:25:13 16: github.com/wailsapp/wails/v3/pkg/w32.GetMessage
        F:/Atom/Downloads/wails-3-alpha/wails-3-alpha/v3/pkg/w32/user32.go:445
2025/03/26 07:25:13 17: github.com/wailsapp/wails/v3/pkg/application.(*windowsApp).runMainLoop
        F:/Atom/Downloads/wails-3-alpha/wails-3-alpha/v3/pkg/application/mainthread_windows.go:62
2025/03/26 07:25:13 18: github.com/wailsapp/wails/v3/pkg/application.(*windowsApp).run
        F:/Atom/Downloads/wails-3-alpha/wails-3-alpha/v3/pkg/application/application_windows.go:154
2025/03/26 07:25:13 19: github.com/wailsapp/wails/v3/pkg/application.(*App).Run
        F:/Atom/Downloads/wails-3-alpha/wails-3-alpha/v3/pkg/application/application.go:686
2025/03/26 07:25:13 20: main.main
        F:/Atom/Downloads/wails-3-alpha/wails-3-alpha/v3/examples/window/main.go:743
2025/03/26 07:25:13 21: runtime.main
        E:/Ruanjian/Gopath/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:283
[0326/072513.997:ERROR:window_impl.cc(122)] Failed to unregister class Chrome_WidgetWin_0. Error = 1412
exit status 1

Expected behaviour

The window displays normally instead of crashing.

Screenshots

No response

Attempted Fixes

No response

System Details

# System 

┌────────────────────────────────────────────────────────────────────────────────────────────┐
| Name              | Windows 10 Pro                                                         |
| Version           | 2009 (Build: 26100)                                                    |
| ID                | 24H2                                                                   |
| Branding          | Windows 11 专业版                                                      |
| Platform          | windows                                                                |
| Architecture      | amd64                                                                  |
| Go WebView2Loader | true                                                                   |
| WebView2 Version  | 134.0.3124.83                                                          |
| CPU               | Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz                                |
| GPU 1             | NVIDIA GeForce GTX 1650 (NVIDIA) - Driver: 31.0.15.4584                |
| GPU 2             | Intel(R) UHD Graphics 630 (Intel Corporation) - Driver: 31.0.101.2111  |
| Memory            | 16GB                                                                   |
└────────────────────────────────────────────────────────────────────────────────────────────┘

# Build Environment 

┌───────────────────────────────┐
| Wails CLI    | v3.0.0-alpha.9 |
| 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         | windows        |
└───────────────────────────────┘

# Dependencies 

┌───────────────────────────┐
| npm  | 10.9.0             |
| NSIS | v3.11              |
|                           |
└─ * - Optional Dependency ─┘

Additional context

No response

@Astrov0 Astrov0 added the Bug Something isn't working label Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant