Repository navigation
Write the floating panel's root scroll padding in a frame, not inside its ResizeObserver delivery - #5736
Merged
Conversation
…ivery The floating panel's size observers ran `followBox`, which wrote the root's `scroll-padding-bottom` inside the ResizeObserver delivery. The margin's page MutationObserver hears the root's style, so its pass ran in that delivery's microtasks and its `lf-margin-layout` event re-placed an open thread card, widening `#lf-margin-preview` after the delivery had passed its depth: Chrome reported "ResizeObserver loop completed with undelivered notifications". page-layout.js already says a size delivery writes only what nobody observes or queues work for a frame. The band's state (`stateFootBand`), which Leaf's own landings read, is still stated at once; the root's padding, read by the browser's own reveals, and the room announcement now land in the next rendering pass. Before #5630 the same writes ran in the same frame, but the panel observer's first round happened to include a detached svg at depth 1, which let Chrome deliver the card's resize in a second round. #5630 kept that svg connected, so the shallowest first-round target became the panel host at depth 5, below the card's depth 4, and the loop error surfaced in test_a_drawing_is_sent_and_replayed_as_an_ordinary_comment. Closes #5709
This was referenced Nov 9, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 9, 2026
…sured it (#5743) Since #5617, a chart with a legend finishes its first drawing in the delivery of its legend's ResizeObserver. The pending task the chart hands the page settles there, so the page's first presentation ran in that delivery's microtask checkpoint. That covers the `data-lf-upgraded`, `data-lf-applied` and `data-lf-presented` stamps on body, the margin and the details shelf, and it resized boxes shallower than the legend's figure (depth 8). Chrome then reported `ResizeObserver loop completed with undelivered notifications` on `heat-loss` and the other chart pages in #5708. Before #5617 the chart measured its legend synchronously (`offsetHeight`), so its drawing settled outside any delivery. The chart still refits its legend in the delivery that measured it, so the frame that shows the legend shows the drawing fitted to it, as #5617 intended. Only `draw()`'s settling now waits one hop, to Leaf's next rendering pass (`nextRender`). That is where `rendering.js` runs work asked for from a size delivery, and `page-layout.js` states the same rule: a size delivery writes only what nobody observes, or queues work for a frame. What the page draws doesn't change. Page readiness can come one frame later for a chart whose drawing finished inside a delivery. **Verification on Linux.** Each of these fails on main `2f47830e4` with the loop error and passes with the change: - `tests/journeys/test_render_gate.py::test_page_fixture_renders[heat-loss]` - `tests/journeys/test_render_gate.py::test_page_fixture_opens_without_firefox_console_warnings[heat-loss]` - `tests/journeys/test_render_navigation.py::test_presses_and_fills_leave_no_element_naming_stale_keys[heat-loss]` - `tests/journeys/test_site.py::test_a_published_decision_survives_reload` The two intermittent site journeys from the issue each passed once with the change: `test_what_a_user_leaves_on_one_page_stays_on_it` and `test_every_published_page_stands_as_a_live_page`. Eleven chart tests in `tests/browser/widgets/test_charts.py` covering legend, redraw, resize and Plot-pointer agreement pass, and so does pre-commit. **What this leaves in #5708.** The macOS-only failures need the next scheduled `test-macos` run. `live-progress` holds a chart and should be covered. `thread-panel-gallery` and `worktree-diffs` hold none, so their errors may have another cause; #5736 fixes one such path in the floating panel. The faceted pick mismatch in `test_a_chart_picks_the_point_plot_s_own_pointer_picks` is a different symptom and isn't addressed here. <details><summary>How the writer was found</summary> An instrumented load of `heat-loss` logged every ResizeObserver delivery with its targets' depths, plus DOM mutations by frame. The error frame delivers the legend watch on `div.plot-*-figure` (depth 8), which replaces the drawing. That frame's mutations then show the chart's `lf-rendered`, body's upgraded, applied and presented stamps, margin-cluster writes and the details shelf, before a deeper floating-panel delivery and the error. Deferring the repaint itself (`requestAnimationFrame`) left the error in place. Deferring only the legend watch's `settled()` removed it, as does this change's single hop at the end of `draw()`, which also covers a chart with no legend whose width delivery finishes the drawing. </details> Refs #5708 — automated triage Co-authored-by: leaf-agent <[email protected]>
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.
The floating panel's size observers call
followBox, which wrote the root'sscroll-padding-bottominside the ResizeObserver delivery. The margin's page MutationObserver (margin-layout.js,heardPage) hears the root'sstyle, so a margin pass ran in that delivery's microtasks. Itslf-margin-layoutevent re-placed the open thread card, widening#lf-margin-preview(320 → 403 px) after the delivery had already gone deeper than the card. Chrome then reportedResizeObserver loop completed with undelivered notifications.page-layout.jsalready states the rule this broke: a size delivery may write only what nobody observes, or queue work for a frame.The fix keeps
stateFootBandimmediate, since Leaf's own landings read the band from it. The root's padding, which only the browser's own reveals read, andannounceRoomnow land in the next rendering pass (nextRender, coalesced).Why it surfaced at #5630: at #5630's parent the same writes happen in the same frame. There, though, the panel observer's first round included a detached
<svg>at depth 1, so Chrome's second round still reached the card (depth 4). #5630 keeps that svg connected (depth 11), which leaves the panel host (depth 5) as the shallowest first-round target, and the card's resize goes undelivered. So #5630's intent and interface are untouched; it removed an accident that had hidden the write.Verification:
tests/journeys/test_render_drawing.py::test_a_drawing_is_sent_and_replayed_as_an_ordinary_commentfails on main2f47830e4and passes 3 of 3 runs with the change. Other checks run locally, all passing:test_chrome_contracts,drafts/test_keys,navigation/test_threads,widgets/test_obligations,controls/test_focus,threads/test_composing, threetest_render_floating_panelcases): 35 passed;pnpm run test:runtime(906), the browser type check and pre-commit.How the writer was found
Ran an instrumented copy of the journey that wrapped
ResizeObserverand logged each delivery with its targets' flat-tree depths, each--lf-thread-widthwrite with its stack, and the margin'sheardPagerecords. The error frame is thegTthat opens Threads. The panel'sfollowobserver (floating-panel.js,sizeObserver→followBox) delivers, and then a microtask'sheardPageseesHTML.style = scroll-padding-bottom: 192px. It runslayoutMarginRows, andmargin-projection.js'slf-margin-layoutlistener callscard.place(), whose placement writes--lf-thread-width: 553px. At the parent the same sequence runs, with the extra depth-1 entry in the first round.layoutMarginRowsis also a size observer's callback itself (layer.sizes), so the same card placement can happen inside a delivery by that route. This run neither reproduced nor changed that route. #5708's corpus-page loop errors have a different onset (#5617) and are not established to share this path.Closes #5709 — automated triage