Skip to content

gpui: release measured layout contexts before clearing Taffy - #9

Closed
liuyanghejerry wants to merge 1 commit into
remorses:gpuixfrom
liuyanghejerry:gpuix-memory-contexts
Closed

liuyanghejerry wants to merge 1 commit into
remorses:gpuixfrom
liuyanghejerry:gpuix-memory-contexts

Conversation

@liuyanghejerry

@liuyanghejerry liuyanghejerry commented Oct 4, 2026 •

Copy link
Copy Markdown

GPUI pins Taffy 0.13, whose clear() leaves node_context_data alive. After a measured subtree disappears, its measurement closure can retain a view entity indefinitely. A repeated native input mount/unmount test reproduces this with App::leak_detector_snapshot() / assert_no_new_leaks().

Track measured node IDs and remove their contexts through TaffyTree::set_node_context(id, None) before clearing the tree. This preserves Taffy's reusable tree allocations and keeps the fix in GPUI, where the measurement contexts are owned. The regression test checks captured values are dropped across shrinking frames.

Taffy's fix is already merged in DioxusLabs/taffy#1181, but it belongs to 0.14; the current GPUI dependency is still exactly 0.13.0. Remove this compatibility patch once the dependency includes that fix.

Validation on macOS arm64:

  • clear_releases_measured_contexts passes in release. The temporary test workspace includes GPUI and its dependency closure (unrelated Zed CLI dependencies require uncached Wasmtime); sources and manifests are restored after the test.
  • GPUIV release native build and cargo check --all-targets --release pass; 345 native unit tests pass.
  • Four same-window lifecycle scenarios run 30 cycles each and pass ownership + GPUI Entity assertions, including focused inputs and the Beautiful UI gallery. The unpatched build failed with surviving TextEditorState entities.
  • Existing input/highlight/Canvas/list tests, 80 example tests and the Beautiful UI performance gate pass.

GPUIV temporarily consumes this single reachable commit from its own fork, with the divergence and removal triggers recorded in GPUIV PR #158.

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.

1 participant