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.
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