Skip to content

Blitz patch 15: the layout tree's debug check looks only at the layout tree - #11

Merged
theetherGit merged 1 commit into
mainfrom
hidden-layout-check
Nov 26, 2026
Merged

theetherGit merged 1 commit into
mainfrom
hidden-layout-check

Conversation

@theetherGit

Copy link
Copy Markdown
Contributor

Main's CI (run 45850244628, on 578cafc) failed on V8 in list::in_a_narrow_window_the_pane_takes_the_lists_place. Locally it failed 4 runs in 4:

panicked at crates/blitz-dom/src/resolve.rs:354:21:
layout child NodeId(749v1) of NodeId(743v1) is not in the slab

Cause

The panic comes from assert_layout_parents_consistent, an upstream Blitz check that only runs in debug builds. Upstream main has the same code.

  • In a window narrower than 1120 px, the Tracker's list column is display: none while the detail pane is open (Clicks clipped by boxes that clip; the Tracker in narrow windows #8).
  • Blitz collects no layout children for a display: none box (DisplayInside::None => {}), so resolve_layout_children never walks below it. Every list down there keeps what it held when the column was hidden.
  • While the column is hidden, every row's labels <span> gets new children. V8 collects the old ones, and their ids stay in lists that nothing lays out, paints or hit-tests. The column's own layout_children are [].
  • Upstream's check looked at every node in the document, so it panicked on those ids.
  • QuickJS did not collect the labels during the test, which is why only V8 failed.
  • Patch 13 has nothing to do with it: with patch 13 turned off the test still failed.

I traced it with a diagnostic that I have since removed: 248 stale ids while the pane was open, 93 while it closed, and 0 once the column showed again. Showing it again rebuilds the subtree, so nothing was drawn wrong.

Fix

Patch 15 (crates/blitz-dom/src/resolve.rs, marked sepal patch, entry 15 in PATCH.md): the check now walks the tree that resolve_layout_children maintains, starting from the root. It checks the same two things on every node it can reach. It has no effect on release builds.

The new test ops::tests::a_node_freed_below_a_hidden_box_is_not_a_layout_child reproduces the panic from ops alone, with no JS engine and no GC: a laid-out box is hidden, its child is removed and dropped, and a new child is added. It also checks that the new child is laid out once the box shows again.

Checked

  • pnpm test passes.
  • cargo test --features "screenshot engine-v8": 141 passed, 0 failed.
  • The V8 Tracker test passes 4 runs in 4; it failed 4 in 4 before the fix.

Not fixed

Blitz's text-selection walkers (traversal.rs) index self.nodes[child] straight from layout_children. If a selection's anchor were inside a hidden subtree whose children changed, they could still reach one of these stale ids in a release build. That is a separate upstream fragility, and nothing here makes it worse.

🤖 Generated with Claude Code

…t tree

Main's V8 job failed in list::in_a_narrow_window_the_pane_takes_the_lists_place:
"layout child NodeId(749v1) of NodeId(743v1) is not in the slab", from
upstream's assert_layout_parents_consistent (debug builds only).

Below a display: none box resolve_layout_children never walks, because the
box has no layout children. The lists down there keep what they held when
the box was hidden. In a narrow window the Tracker's list column hides
behind the detail pane, the rows' labels change, and V8 collects the old
ones: their ids stay in lists that nothing lays out, paints or hit-tests,
and that are rebuilt when the box shows again. Upstream's check looked at
every node in the document; it now walks the tree that is kept, from the
root. QuickJS did not collect the labels during the test, so only V8 failed.

The new ops test reproduces it without a JS engine, and checks that the
box's contents are laid out anew once it shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@theetherGit
theetherGit merged commit 8c81c90 into main Nov 26, 2026
3 of 4 checks passed
@theetherGit
theetherGit deleted the hidden-layout-check branch November 26, 2026 15:55
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