Repository navigation
fix: start the margin layout's size watch when the first row registers - #5500
Merged
Merged
Conversation
#5252 moved the margin layout's subscription to the body and the column from row registration into the layout pass, so that a first paint would not read the column once per row. That also delayed the watch's first deliveries until a later pass, while the page was still settling. On pr-walkthrough, notification-playground and thread-panel-gallery, the layout pass those deliveries run then resizes boxes the observer loop has already delivered, and Chromium reports "ResizeObserver loop completed with undelivered notifications", which fails the render gate's teardown. The first registered row now starts the watch with one column read, as before #5252. The layout pass still keeps the column current, so later rows read nothing. Behavior change: none intended beyond when the watch starts. test_page_fixture_renders fails for those three pages on main and passes with the change. Closes #5464
max-sixty
added a commit
that referenced
this pull request
Nov 5, 2026
…watches (#5544) The margin watched resizes with two ResizeObservers, one for row targets and one for the body and the column, so a resize both saw ran two full margin passes over the same layout, and the load and each revision that adds rows paid an extra pass. This merges them into one observer and gives one function, `subscribe` in `margin-layout.js`, sole ownership of what it watches: each pass states the set (row targets, the body, the column, every live lane's scroller), and `subscribe` observes or unobserves the difference. - The column observer (`observer`, `observedColumn`, `observeLayout` and its disconnect) is deleted; `laneFor` and lane retirement no longer touch subscriptions. The first registered row still starts watching the body and column straight away, which #5500 needs, now through `subscribe`. - Giving `subscribe` sole ownership also fixes a loss that predates this: a lane scroller that was also an ancestor of a row's target was unsubscribed when its lane retired, though the pass still needed it. - No first delivery is suppressed. #5493 tried that and reverted it after review showed no measurement Leaf can take matches what the observer reports; only the duplicate callback is gone. Measured on the generated asks page (least of interleaved rounds, a loaded host): the load and each one-paragraph revision run one pass fewer (2 passes with rows per revision instead of 3), with every row's rectangle identical after the load, the addition and the removal. A revision's main-thread CPU in Chromium went 175→154 ms (add) and 173→145 (remove) at 64 sections, and 1,915→1,205 and 1,427→916 at 512. Load went 821→508 ms at 64 sections in Chromium and 817→492 in Firefox. Checks: `pnpm run test:runtime` (820), `pnpm run check`, 35+ lane, pane-switching, rail, pin, scroller and resize browser tests by node id, the three render-gate pages #5500 names, and `leaf-dev stills` over 30 margin and thread states in Chromium and Firefox with byte-identical screenshots. An independent review found the lane-retirement loss in the first version; its review of the fix found nothing. > _This was written by Claude Code on behalf of max-sixty_
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.
#5252 moved the margin layout's size watch on the body and the column out of
registerMarginRowand into the layout pass, so that a first paint wouldn't read the column once per row. That also delayed the watch's first deliveries to a later pass, while the page was still settling. Onpr-walkthrough,notification-playgroundandthread-panel-gallery, the layout pass those deliveries trigger then resizes boxes the observer loop has already delivered, and Chromium raisesResizeObserver loop completed with undelivered notifications, which failstest_page_fixture_rendersat teardown.The first registered row now starts the watch with one column read, as it did before #5252. The layout pass still keeps the observed column current, so the rows after it read nothing, which keeps #5252's saving. Nothing changes on screen.
Verification.
uv run pytest --run-nightly "tests/journeys/test_render_gate.py::test_page_fixture_renders[<page>]"fails on main (f8808301f) for all three pages and passes with this change.pnpm run test:runtimepasses, as docheck:browserand the margin browser teststest_rail.pyandtest_pins.py.test_entries.py::test_an_inline_contribution_name_needs_no_physical_marginfails both with and without the change; #5473 tracks it.How the cause was found
git bisectover19757c94c..8b759a566, running thenotification-playgroundcase and marking only the ResizeObserver error as bad, lands on7f857fd0f(Hold each cost on a large page to the page's size, and measure its growth with leaf-dev scaling #5252). Its parentaef8926c5passes.sizeObserverdelivery up to the error. Onpr-walkthrough, the last delivery before the error is the margin watch's first notification for the column (MAIN.layout-sidebar), which arrives after the page's other observers have already delivered several rounds. Onnotification-playgroundthe watch hadn't delivered at all before the error. There the final write is the playground's--playground-controls-heightin its own observer, and removing that write also clears the error. So the playground's write is one way a late-settling page trips the loop, not a separate cause.tests/browser/test_render_controls.py::test_sample_host_view_changes_leave_its_scroll_and_keyboard_position, which the issue also names, has a different cause. It passes at7f857fd0f, bisects to61afa3016(#5361), and still fails with this change. #5486 tracks it.Closes #5464 — automated triage