Skip to content

fix(v3/macos): marshal main menu updates to UI thread - #5910

Draft
leaanthony wants to merge 1 commit into
masterfrom
agent/macos-main-menu-main-thread
Draft

fix(v3/macos): marshal main menu updates to UI thread#5910
leaanthony wants to merge 1 commit into
masterfrom
agent/macos-main-menu-main-thread

Conversation

@leaanthony

Copy link
Copy Markdown
Member

What changed

  • Marshal macOS application-menu replacement synchronously onto AppKit's main queue.
  • Apply directly when already on the main thread to avoid a dispatch_sync deadlock.
  • Document the fix in the unreleased v3 changelog.

Why

Wails custom-event listeners execute on worker goroutines. Calling app.Menu.Set(...) from one of those callbacks reaches [NSApp setMainMenu:] on that worker thread and macOS aborts the process with:

NSInternalInconsistencyException: API misuse: setting the main menu on a non-main thread.

The native macOS boundary now owns the thread-safety guarantee, so applications do not need to wrap menu replacement in application.InvokeAsync themselves.

Impact

Dynamic application menus can safely be replaced from Wails callbacks on macOS. Other platforms and initial main-thread menu setup are unchanged.

Validation

  • go test ./pkg/application
  • Built and ran a standalone macOS reproduction against this checkout.
  • The reproduction replaced the application menu from a worker goroutine and exited cleanly; before the fix, the same path aborted in NSApplication setMainMenu:.
  • git diff --check

Local CodeRabbit review was skipped at the repository owner's direction; hosted review can run on this PR.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 81df8afb-eb66-4350-8946-a35306f2e338

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added Documentation Improvements or additions to documentation MacOS v3-alpha labels Aug 6, 2026
@taliesin-ai taliesin-ai self-assigned this Aug 7, 2026
@taliesin-ai taliesin-ai added this to the v3.0.0-beta.3 milestone Aug 7, 2026
@taliesin-ai taliesin-ai moved this from Todo to In Progress in Wails Release Train Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation MacOS v3-alpha

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants