Repository navigation
fix(gpui): defer window callbacks AppKit sends while the app is mid-update - #2760
Open
richiemcilroy wants to merge 1 commit into
Open
richiemcilroy wants to merge 1 commit into
richiemcilroy wants to merge 1 commit into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Bug
Every launch, and every time the recording controls window opens, logs
ERROR gpui::window: RefCell already borrowed(1–4 per launch). Seen on nightly0.6.2-nightly.202610200310(before any of today's gpui changes), nightly…0640and the 0.6.1 build, with an upgraded user's saved window state.The text comes from
AsyncApp::update_window, whoseapp.try_borrow_mut()fails because AppKit called a window delegate synchronously while the app was already inside an update. Cap opens and positions windows inside updates (restoring the camera bubble's saved position, placing the recording controls, restoring the main window), and AppKit answers thosesetFrame:/orderFront:calls on the spot:gpui_macos/src/window.rs)gpui/src/window.rs)window_did_moveon_moved→bounds_changedset_frame_size,update_window_scale_factoron_resize→bounds_changedview_did_change_effective_appearanceon_appearance_changeddisplay_layer, the becomes-key frameon_request_frameActivation already goes through the foreground executor (
window_did_change_key_status), which is why it never showed up.Fix
update_window_or_defer:on_resize,on_moved,on_appearance_changedandon_button_layout_changednow apply their update, and when the only failure is that the app is borrowed, they retry once on the next turn of the run loop. The updates are idempotent (bounds_changedre-reads the platform bounds), so a deferred one converges to the current state. Any other error (window closed, app quitting) is logged as before.on_request_frame: a frame that fails because the app is borrowed now callsFramePacer::missed_frame, which asks for another single frame (FrameRequests::Once) while requests are stopped. A window that closed still returns quietly (fix(gpui): end a frame quietly when its window has already closed #2734).Tests
New
frame_pacer_tests:a_frame_missed_while_stopped_asks_for_anothera_frame_missed_while_running_asks_for_nothingThese are gpui crate tests, which Cap CI does not run. They have not been run for this PR, because the Mac this was written on is off-limits for local builds right now. The pacer suite last passed 212/212 on #2740.
CI compiles the patched gpui on macOS (arm and Intel), Linux and Windows.
./scripts/prepare-gpui-dependency.shverifies the stack, and its tests pass 8/8.

Confidence Score: 5/5
The PR appears safe to merge; no actionable defects were found.Summary
Updates the GPUI patch to preserve window notifications that arrive during an app update.
Review was static. The upstream GPUI checkout was unavailable, so patched builds and tests were not run.
Reviews (1) · Last reviewed commit: "fix(gpui): defer window callbacks AppKit..." · Reviewed by Greptile