Repository navigation
fix(linux): stop forcing SA_ONSTACK on SIGUSR1 to prevent WebKit freeze - #5530
Conversation
WebKit's JavaScriptCore uses SIGUSR1 to suspend/resume threads for conservative GC stack scanning. The signal-handler fix added in alpha.97 (#5507) re-applied SA_ONSTACK to every signal it touched, including SIGUSR1. Once JSC installs its own SIGUSR1 handler it owns the signal (Go no longer handles it), so forcing SA_ONSTACK makes that handler run on Go's alternate signal stack, breaking GC thread synchronisation. This froze the WebKit UI during idle garbage collection (most visibly with the inspector open) while the Go backend kept running. Remove fix_signal(SIGUSR1) from install_signal_handlers in v3 (GTK4 + GTK3) and v2. The genuine #5506 fix for SIGSEGV/SIGBUS (which Go needs SA_ONSTACK for) is unaffected. Fixes #5527 https://claude.ai/code/session_01AtT1CjDNRArXv1eddXte2a
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis PR fixes a UI freeze on Linux with the inspector open by removing the ChangesSIGUSR1 signal handling fix for WebKit idle freeze
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 🔧 Infer (1.2.0)v3/pkg/application/linux_cgo.cIn file included from v3/pkg/application/linux_cgo.c:3: ... [truncated 759 characters] ... inux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR addresses a Linux-specific WebKit freeze regression introduced in v3 alpha.97 by stopping Wails from forcing SA_ONSTACK onto SIGUSR1, which JavaScriptCore uses for GC thread coordination.
Changes:
- Remove
fix_signal(SIGUSR1)from Linux/WebKit signal handler installation in v2 + v3 (GTK3/GTK4). - Add inline comments documenting why
SIGUSR1must not be modified. - Add a v3 changelog entry describing the fix and linking to #5527.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| v3/UNRELEASED_CHANGELOG.md | Documents the Linux WebKit idle/inspector freeze fix for the next v3 alpha release. |
| v3/pkg/application/linux_cgo.c | Stops applying SA_ONSTACK to SIGUSR1 in the GTK4 signal-handler fix path; adds rationale comment. |
| v3/pkg/application/linux_cgo_gtk3.go | Stops applying SA_ONSTACK to SIGUSR1 in the GTK3 signal-handler fix path; adds rationale comment. |
| v2/internal/frontend/desktop/linux/frontend.go | Stops applying SA_ONSTACK to SIGUSR1 in the v2 Linux frontend signal-handler fix path; adds rationale comment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Problem: Wails v2.12 repairs Linux signal handlers only once, before JavaScriptCore may lazily replace them, so affected WebKitGTK applications can still abort during startup. Root cause: JavaScriptCore installs handlers after the one-shot repair and can drop the SA_ONSTACK flag required by the Go runtime. Moving JSC GC to SIGUSR2 does not restore those flags and is not the upstream fix. Fix: Backport the final Wails v2.13 Linux strategy: reapply SA_ONSTACK every 50 ms for a bounded five-second startup window and once again at DomReady, while leaving SIGUSR1 under JavaScriptCore ownership. Keep Wails v2.12 and retain the NVIDIA DMA-BUF workaround. Non-Linux hooks are no-ops. Upstream: wailsapp/wails#5507, wailsapp/wails#5530 Verification: - go test ./... (desktop) - go build ./... (desktop) - go vet ./... (desktop) - go test ./... (repository root) - GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./... (desktop) - GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build ./... (desktop) - git diff --check
…WebKit 启动信号修复 (#6655) * fix(desktop): add WebKit2GTK 2.50 SIGUSR1 signal workaround for Linux crash WebKit2GTK 2.50.x changed internal GObject type registration in ways that interact badly with the Go runtime's SIGUSR1 signal handler, causing a SIGABRT inside webkit_user_content_manager_new() on certain Linux distributions (Deepin 23, Arch). The crash produces no useful error output — just a white window that exits with code 1. Root cause: Go's runtime uses SIGUSR1 (signal 10) for thread management, and JavaScriptCore also uses SIGUSR1 for conservative GC stack scanning. When Go registers its handler first, WebKit's attempt to set its own is overridden, corrupting the GObject type system during webview setup. This commit adds two workarounds applied via package init() before Wails initialises the webview: 1. JSC_SIGNAL_FOR_GC=12 — tells JavaScriptCore to use SIGUSR2 instead of SIGUSR1, eliminating the signal conflict at the source. 2. WEBKIT_DISABLE_DMABUF_RENDERER=1 on NVIDIA GPUs — the DMA-BUF compositing path in WebKit2GTK 2.50.x is unstable with NVIDIA's proprietary driver; disabling it falls back to the stable software OpenGL path. Also bumps the Wails dependency from v2.12.0 to v2.13.0 for additional Linux/WebKit compatibility fixes from the upstream. Tested on: Deepin 23, WebKit2GTK 2.50.4, Go 1.26.5, NVIDIA GT 1030 (driver 580.119.02), X11 session. Cache-impact: none Cache-guard: none (desktop/init only, no prompt/tool prefix changes) System-prompt-review: none * fix(desktop): keep WebKit workaround Linux-only Problem: The PR coupled a Linux WebKit compatibility workaround to a cross-platform Wails v2.13.0 upgrade with placeholder checksums, and the new Linux file redeclared an existing NVIDIA helper. Root cause: The dependency bump expanded the change beyond the affected platform, while the compatibility file duplicated platform support already owned by nvidia_wayland_linux.go. Fix: Restore Wails v2.12.0 and its verified checksums, reuse the existing Linux NVIDIA detector, and format the compatibility file. Verification: - go mod tidy - go build ./... - go test ./... - git diff --check Co-authored-by: SivanCola <[email protected]> * fix(desktop): backport Linux WebKit signal repair Problem: Wails v2.12 repairs Linux signal handlers only once, before JavaScriptCore may lazily replace them, so affected WebKitGTK applications can still abort during startup. Root cause: JavaScriptCore installs handlers after the one-shot repair and can drop the SA_ONSTACK flag required by the Go runtime. Moving JSC GC to SIGUSR2 does not restore those flags and is not the upstream fix. Fix: Backport the final Wails v2.13 Linux strategy: reapply SA_ONSTACK every 50 ms for a bounded five-second startup window and once again at DomReady, while leaving SIGUSR1 under JavaScriptCore ownership. Keep Wails v2.12 and retain the NVIDIA DMA-BUF workaround. Non-Linux hooks are no-ops. Upstream: wailsapp/wails#5507, wailsapp/wails#5530 Verification: - go test ./... (desktop) - go build ./... (desktop) - go vet ./... (desktop) - go test ./... (repository root) - GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./... (desktop) - GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build ./... (desktop) - git diff --check * Scope Linux WebKit renderer fallback to safe mode Problem: All Linux NVIDIA launches inherited WEBKIT_DISABLE_DMABUF_RENDERER, disabling accelerated backing store, while the signal-repair comments implied coverage of failures before the GTK main loop. Root cause: The renderer fallback ran from package initialization without recovery gating. The backported GLib timer only dispatches after GTK enters its main loop. Fix: Apply the DMA-BUF fallback only to Safe Mode NVIDIA launches before Wails creates WebKit, preserve preconfigured environment values, keep other platforms as no-ops, and document the signal fix boundary. Add focused policy and platform tests. Verification: - cd desktop && go test ./... - cd desktop && go vet ./... - cd desktop && go build ./... - cd desktop && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./... - git diff --check Co-authored-by: SivanCola <[email protected]> --------- Co-authored-by: SivanCola <[email protected]>
…WebKit 启动信号修复 (#6655) * fix(desktop): add WebKit2GTK 2.50 SIGUSR1 signal workaround for Linux crash WebKit2GTK 2.50.x changed internal GObject type registration in ways that interact badly with the Go runtime's SIGUSR1 signal handler, causing a SIGABRT inside webkit_user_content_manager_new() on certain Linux distributions (Deepin 23, Arch). The crash produces no useful error output — just a white window that exits with code 1. Root cause: Go's runtime uses SIGUSR1 (signal 10) for thread management, and JavaScriptCore also uses SIGUSR1 for conservative GC stack scanning. When Go registers its handler first, WebKit's attempt to set its own is overridden, corrupting the GObject type system during webview setup. This commit adds two workarounds applied via package init() before Wails initialises the webview: 1. JSC_SIGNAL_FOR_GC=12 — tells JavaScriptCore to use SIGUSR2 instead of SIGUSR1, eliminating the signal conflict at the source. 2. WEBKIT_DISABLE_DMABUF_RENDERER=1 on NVIDIA GPUs — the DMA-BUF compositing path in WebKit2GTK 2.50.x is unstable with NVIDIA's proprietary driver; disabling it falls back to the stable software OpenGL path. Also bumps the Wails dependency from v2.12.0 to v2.13.0 for additional Linux/WebKit compatibility fixes from the upstream. Tested on: Deepin 23, WebKit2GTK 2.50.4, Go 1.26.5, NVIDIA GT 1030 (driver 580.119.02), X11 session. Cache-impact: none Cache-guard: none (desktop/init only, no prompt/tool prefix changes) System-prompt-review: none * fix(desktop): keep WebKit workaround Linux-only Problem: The PR coupled a Linux WebKit compatibility workaround to a cross-platform Wails v2.13.0 upgrade with placeholder checksums, and the new Linux file redeclared an existing NVIDIA helper. Root cause: The dependency bump expanded the change beyond the affected platform, while the compatibility file duplicated platform support already owned by nvidia_wayland_linux.go. Fix: Restore Wails v2.12.0 and its verified checksums, reuse the existing Linux NVIDIA detector, and format the compatibility file. Verification: - go mod tidy - go build ./... - go test ./... - git diff --check Co-authored-by: SivanCola <[email protected]> * fix(desktop): backport Linux WebKit signal repair Problem: Wails v2.12 repairs Linux signal handlers only once, before JavaScriptCore may lazily replace them, so affected WebKitGTK applications can still abort during startup. Root cause: JavaScriptCore installs handlers after the one-shot repair and can drop the SA_ONSTACK flag required by the Go runtime. Moving JSC GC to SIGUSR2 does not restore those flags and is not the upstream fix. Fix: Backport the final Wails v2.13 Linux strategy: reapply SA_ONSTACK every 50 ms for a bounded five-second startup window and once again at DomReady, while leaving SIGUSR1 under JavaScriptCore ownership. Keep Wails v2.12 and retain the NVIDIA DMA-BUF workaround. Non-Linux hooks are no-ops. Upstream: wailsapp/wails#5507, wailsapp/wails#5530 Verification: - go test ./... (desktop) - go build ./... (desktop) - go vet ./... (desktop) - go test ./... (repository root) - GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./... (desktop) - GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build ./... (desktop) - git diff --check * Scope Linux WebKit renderer fallback to safe mode Problem: All Linux NVIDIA launches inherited WEBKIT_DISABLE_DMABUF_RENDERER, disabling accelerated backing store, while the signal-repair comments implied coverage of failures before the GTK main loop. Root cause: The renderer fallback ran from package initialization without recovery gating. The backported GLib timer only dispatches after GTK enters its main loop. Fix: Apply the DMA-BUF fallback only to Safe Mode NVIDIA launches before Wails creates WebKit, preserve preconfigured environment values, keep other platforms as no-ops, and document the signal fix boundary. Add focused policy and platform tests. Verification: - cd desktop && go test ./... - cd desktop && go vet ./... - cd desktop && go build ./... - cd desktop && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./... - git diff --check Co-authored-by: SivanCola <[email protected]> --------- Co-authored-by: SivanCola <[email protected]>
Summary
Fixes #5527 — a regression introduced in alpha.97 where the WebKit UI freezes on Linux while idle (most visibly with the inspector open). Only the UI hangs; the Go backend keeps running.
Root cause
The freeze traces to PR #5507 (
6329e9d), the only Linux/WebKit signal-handling change between alpha.96 and alpha.97. That commit addedfix_signal(SIGUSR1)toinstall_signal_handlers().fix_signal()ORsSA_ONSTACKinto whatever handler is currently registered. Once JSC installs its own SIGUSR1 handler, Go no longer handles SIGUSR1 at all, so forcingSA_ONSTACKonly corrupts JSC's handler — making it run on Go's alternate signal stack instead of the thread's normal stack.The original commit even noted the
Overriding existing handler for signal 10message — that is JSC taking ownership of SIGUSR1, which is exactly the point at which addingSA_ONSTACKbecomes harmful rather than helpful.Fix
Remove
fix_signal(SIGUSR1)frominstall_signal_handlers()in all three locations:v3/pkg/application/linux_cgo.c(GTK4)v3/pkg/application/linux_cgo_gtk3.go(GTK3)v2/internal/frontend/desktop/linux/frontend.goEach is replaced with a comment explaining why SIGUSR1 must not be touched. The genuine #5506 fix for SIGSEGV/SIGBUS (which Go does require
SA_ONSTACKfor, for JIT crash recovery) is fully preserved.Testing
gofmtclean on the modified Go file.OpenInspectorOnStartup: true,wails3 dev, tab away for a few minutes.Fixes #5527
https://claude.ai/code/session_01AtT1CjDNRArXv1eddXte2a
Generated by Claude Code
Summary by CodeRabbit