Skip to content

Write the floating panel's root scroll padding in a frame, not inside its ResizeObserver delivery - #5736

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-5709
Nov 9, 2026
Merged

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

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

The floating panel's size observers call followBox, which wrote the root's scroll-padding-bottom inside the ResizeObserver delivery. The margin's page MutationObserver (margin-layout.js, heardPage) hears the root's style, so a margin pass ran in that delivery's microtasks. Its lf-margin-layout event 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 reported ResizeObserver loop completed with undelivered notifications. page-layout.js already states the rule this broke: a size delivery may write only what nobody observes, or queue work for a frame.

The fix keeps stateFootBand immediate, since Leaf's own landings read the band from it. The root's padding, which only the browser's own reveals read, and announceRoom now 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_comment fails on main 2f47830e4 and passes 3 of 3 runs with the change. Other checks run locally, all passing:

  • the whole drawing journey file;
  • the tests that read the panel's band or land clear of it (test_chrome_contracts, drafts/test_keys, navigation/test_threads, widgets/test_obligations, controls/test_focus, threads/test_composing, three test_render_floating_panel cases): 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 ResizeObserver and logged each delivery with its targets' flat-tree depths, each --lf-thread-width write with its stack, and the margin's heardPage records. The error frame is the g T that opens Threads. The panel's follow observer (floating-panel.js, sizeObserver → followBox) delivers, and then a microtask's heardPage sees HTML.style = scroll-padding-bottom: 192px. It runs layoutMarginRows, and margin-projection.js's lf-margin-layout listener calls card.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.

layoutMarginRows is 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

…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
@leaf-agent
leaf-agent merged commit 4d2865d into main Nov 9, 2026
6 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-5709 branch November 9, 2026 08:52
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]>
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_a_drawing_is_sent_and_replayed_as_an_ordinary_comment: ResizeObserver loop error since #5630

1 participant