Skip to content

fix: start the margin layout's size watch when the first row registers - #5500

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-5464
Nov 5, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-5464

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

#5252 moved the margin layout's size watch on the body and the column out of registerMarginRow and 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. On pr-walkthrough, notification-playground and thread-panel-gallery, the layout pass those deliveries trigger then resizes boxes the observer loop has already delivered, and Chromium raises ResizeObserver loop completed with undelivered notifications, which fails test_page_fixture_renders at 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:runtime passes, as do check:browser and the margin browser tests test_rail.py and test_pins.py. test_entries.py::test_an_inline_contribution_name_needs_no_physical_margin fails both with and without the change; #5473 tracks it.

How the cause was found
  • git bisect over 19757c94c..8b759a566, running the notification-playground case and marking only the ResizeObserver error as bad, lands on 7f857fd0f (Hold each cost on a large page to the page's size, and measure its growth with leaf-dev scaling #5252). Its parent aef8926c5 passes.
  • I logged each sizeObserver delivery up to the error. On pr-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. On notification-playground the watch hadn't delivered at all before the error. There the final write is the playground's --playground-controls-height in 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.
  • Putting the watch's start back at registration clears the error on all three pages.

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 at 7f857fd0f, bisects to 61afa3016 (#5361), and still fails with this change. #5486 tracks it.

Closes #5464 — automated triage

#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
@leaf-agent
leaf-agent merged commit 205c71a into main Nov 5, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-5464 branch November 5, 2026 15:18
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_
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.

test_page_fixture_renders: ResizeObserver loop error on pr-walkthrough and notification-playground

1 participant