fix: pump AppKit sooner and install default menus after the first frames - #608
Merged
Merged
Conversation
The first frame-loop tick waited `frameMs` (8ms) before pumping AppKit, delaying the post-show occlusion pump that reports the window visible. Run the first idle tick synchronously instead of scheduling it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The default menu bar (no `menus` option) loads WritingToolsUI and, with it, SwiftUI, WebKit and about a hundred other frameworks, all before the window's first present. Defer that install until after the window's second frame; a caller-supplied menu spec still installs synchronously during init so an invalid spec still fails `init()` immediately. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Harness: Claude Code
Agent: none
Model: anthropic/claude-opus-5
Task statements
Part of #600.
Two of #600's three startup changes on macOS:
frameMs(8 ms). That tick runs AppKit's post-show work, which ends in the window being reported visible and the display link starting, so it now runs immediately. React's first commit already happens beforestartFrameLoop. Windows and Linux use the timer path, which is unchanged.menusunset they are now installed from a second nestedon_next_frame. Caller-supplied menus are still installed during init, so an invalid spec still failsinit().GPUIX hello-world, launch to second frame,
bun scripts/app-bench.ts --runs 5alternating betweenmainand this branch, 3 rounds, with other builds running on the machine:mainmedianThe absolute figures are inflated by the load; the difference is about 27 ms.
examples/counter.tsxshows its content on the first screenshot and gets the default App and Window menus;examples/menus.tsxstill shows its own menus.The third change, committing React before the window's first present, is not in this PR. Committing before
init()fails becauseapply_batchinvalidates a window that does not exist yet, anduseWindowSizewould read an 800×600 fallback.Risk: the default menus appear two frames after the window instead of before it, about 30 ms at 60 Hz, so a menu shortcut pressed in that window does nothing. Cmd+Q was not exercised by a synthesised keystroke here, because macOS blocks keystroke automation without an Accessibility grant.
🤖 Generated with Claude Code