base: measure a state shared by several windows in one window at a time - #2
Merged
Hmbown merged 1 commit intoOct 1, 2026
Merged
Conversation
A host can draw the same entity in two windows of different sizes (Codewhale opens a second window onto one workspace). Two kit states keep geometry measured at draw time, and each window wrote its own into the one shared entity, so every draw invalidated the other window and GPUI's test-mode flush_effects redrew the pair forever (100% CPU in the app's differently-sized-windows regression; in the app it is endless frames). - ResizableState (dock splits): ResizablePanelGroup::measure(bool) keeps the group/panel prepaint and handle drags out of non-measuring windows. DockArea::set_measurement_window names the window whose layout the shared split sizes follow (None, the default, measures everywhere as before). Dock-edge drags now size against the area bounds of the window the pointer is in; bounds() reports the measuring window. - ResizableState::update_panel_size notifies only when something changed (it runs on every prepaint). - InputBaseState: a paint writes geometry, soft-wrap width and scroll only from the window that last measured, until another window is active or it closes; other windows draw with that geometry and do not rewrap the shared display map. Root cause was found by sampling the hung test and then attaching lldb to break on WindowInvalidator::invalidate_view: every captured invalidation came from TextElement::paint on the shared textarea, after the split fix removed the ResizableState ping-pong. Evidence (local, macOS arm64, cargowhale governor): - cargo test -p gpui-base --lib -- resizable:: dock:: : 178 passed, 0 failed, including a_state_shared_by_two_windows_settles_on_the_measuring_window - cargo test -p gpui-base --lib -- input:: : 274 passed, 0 failed, including test_textarea_shared_by_two_windows_settles - cargo clippy -p gpui-base --locked -- --deny warnings: clean - cargo fmt --check -p gpui-base: clean (only these files changed) - Codewhale app differently_sized_windows_follow_the_active_layout_owner_ and_transfer_on_close, built against this tree via a cargo paths override: 1 passed in 0.66s (previously hung indefinitely) Hosted CI for this head is pending. Co-Authored-By: Claude Opus 5.5 <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.
Why
Codewhale draws one workspace in two windows. Two kit states record geometry at draw time. When the same entity is drawn in two differently sized windows, each window writes its own measurement, invalidates the other, and GPUI keeps redrawing the pair: 100% CPU and a hung test in test mode, endless frames in the app. Root cause was traced with a stack sample plus lldb breakpoints on
WindowInvalidator::invalidate_view.What
ResizableState):ResizablePanelGroup::measure(bool)keeps prepaint measurement and handle drags out of non-measuring windows.DockArea::set_measurement_window(Option<WindowId>)lets a host name the window the shared split sizes follow; the default (None) keeps the old measure-everywhere behavior. Dock-edge drags now size against the bounds of the window the pointer is in.ResizableState::update_panel_sizenotifies only on change (it runs every prepaint).InputBaseState): geometry, soft-wrap width and scroll are written only by the window that last measured, until another window becomes active or that window closes.Evidence (local, macOS arm64)
cargo test -p gpui-base --lib -- resizable:: dock::: 178 passed, 0 failed (newa_state_shared_by_two_windows_settles_on_the_measuring_window)cargo test -p gpui-base --lib -- input::: 274 passed, 0 failed (newtest_textarea_shared_by_two_windows_settles)cargo clippy -p gpui-base --locked -- --deny warnings: clean;cargo fmt --check -p gpui-base: cleandifferently_sized_windows_follow_the_active_layout_owner_and_transfer_on_closeagainst this tree: 1 passed in 0.66 s (previously hung)Both new tests are bounded: a notification cap turns a regression into a failure instead of a hang.
🤖 Generated with Claude Code