Skip to content

base: measure a state shared by several windows in one window at a time - #2

Merged
Hmbown merged 1 commit into
codewhale/v0.6.4from
fix/multiwindow-dock-measurement-20260930
Oct 1, 2026
Merged

Hmbown merged 1 commit into
codewhale/v0.6.4from
fix/multiwindow-dock-measurement-20260930

Conversation

@Hmbown

@Hmbown Hmbown commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

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

  • Dock splits (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_size notifies only on change (it runs every prepaint).
  • Inputs (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 (new a_state_shared_by_two_windows_settles_on_the_measuring_window)
  • cargo test -p gpui-base --lib -- input::: 274 passed, 0 failed (new test_textarea_shared_by_two_windows_settles)
  • cargo clippy -p gpui-base --locked -- --deny warnings: clean; cargo fmt --check -p gpui-base: clean
  • Codewhale app regression differently_sized_windows_follow_the_active_layout_owner_and_transfer_on_close against 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

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>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 14:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Hmbown
Hmbown merged commit e3dfda2 into codewhale/v0.6.4 Oct 1, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants