Skip to content

test_page_fixture_opens_without_firefox_console_warnings[thread-panel-gallery]: Firefox reports a ResizeObserver loop on macOS #6604

Closed

Description

@leaf-agent

tests/journeys/test_render_gate.py::test_page_fixture_opens_without_firefox_console_warnings[thread-panel-gallery] errors at teardown on macOS only (render_harness.py:1552): …/versions/v1.html: window error: ResizeObserver loop completed with undelivered notifications.

It reproduces on current main (d714c2e60): 5 of 18 copies errored with that message in dispatch 44762687613 on CI's Mac (--workers 1 --load 4). It first failed in scheduled run 44722728605 and passes on Linux.

Firefox reports this when an observer callback resizes something it observes within the same frame. So some ResizeObserver in what the thread-panel gallery draws can feed back into itself when frames are slow. #5708 and #5743 fixed an earlier corpus loop. Whether this is that path coming back or a new one isn't established yet; the next step is to find which observer's callback writes a size it observes.

Cause of a failure tracked in #4225.

Activity

  1. added
    tend-ci-cause
    on Nov 20, 2026
  2. leaf-agent commented on Nov 20, 2026

    @leaf-agent
    CollaboratorAuthor

    I found the observer that loops, and it reproduces on Linux under load. A fit of the margin card writes max-height on #lf-margin-preview while box-motion's shared observer is delivering the card inside it. The two fixes I tried at the cap rule broke another test with the same loop, so this isn't fixed yet. The fix belongs where placements land, not in the cap rule.

    The sequence. It is the same in every failing copy I logged, in the On Me sample's card:

    1. The card's first fit, made before the card is held, writes max-height: 599px, the whole room, on the preview aside (depth 4). The card stands at 430 px.
    2. Once the card is held at the top, each later fit computes a cap of 430 px. measureThreadCard only writes when the cap is below the card's current height, or when contents overflow. So the stale 599 px stays.
    3. The message holding the Runs table finishes drawing (its body goes from 98 to 298 px), and the aside grows into the stale room, 430 → 599 px.
    4. box-motion's placedParts delivers div.lf-margin-preview-card (depth 5) and asks the placement for this size (place). The fit lands in that delivery's microtasks and writes max-height: 430px on the aside, a box shallower than the one just delivered.
    5. The reading-regions and Floating UI observers of the aside can't hear 599 → 430 in that frame, and Firefox reports the loop.

    Two attempts that failed. I made the fit tighten the worn cap down to its computed cap: first always, then only while the contents fit. Either way the gallery passed 15 of 15 copies with the probe on, against 7 of 15 failing before. But tests/browser/margin/test_card_reply.py::test_a_card_a_scroll_moves_onto_or_off_the_windows_foot_as_it_resizes_only_resizes then failed deterministically with the same loop notice (Chromium) and a 120 s timeout (Firefox), and it passes on main. With the tighter cap, the content's growth reaches the card only through the fit's next write, and that write again lands in box-motion's delivery. So any size the fit sets from inside that delivery takes this path. box-motion's header relies on a placement landing in the delivery. That is safe only while the landing changes no observed size, and here it changes the parent aside's.

    Next step. Decide where a placement that box-motion's delivery asks for should write a size change. One option defers just a placement that would change the aside's size to the next render pass, at the cost of one frame at the old size. The other lets the delivery observe the box the fit actually sizes, the aside. I'll keep working on this from that point.

    Reproduction and probe
    • On Linux, uv run leaf-dev suite flake --copies 12 --workers 3 --load 6 'tests/journeys/test_render_gate.py::test_page_fixture_opens_without_firefox_console_warnings[thread-panel-gallery]' failed 2 of 12 on f33e974b4. --load 2 --workers 2 passed 8 of 8.
    • The probe is an init script added in clean_browser's page setup (render_harness.py, before watch_sources). It wraps ResizeObserver to log each delivery's constructor stack, its targets and their depths. It patches CSSStyleDeclaration.prototype.setProperty to log each max-height write on #lf-margin-preview with its stack and the delivery it ran in. On the loop error, it prints the log through console.error. With it, 7 of 15 and 3 of 9 copies failed, and every one showed the sequence above. A failing copy's fit inputs: first fit stood=0 height=599 stationary=false, then stood=430 height=415.6 stationary=true keepTop=true, with worn=599px until the write in box-motion's delivery.
  3. leaf-agent commented on Nov 21, 2026

    @leaf-agent
    CollaboratorAuthor

    Still open, and still live on current main (bd99da0ee): 3 of 18 copies failed on Linux at --workers 4 --load 8. A probe now names the observer that misses the shrink. Changing the order the observers are created in didn't fix the loop, which narrows what's left to a choice between the two options in the last comment.

    The observer that loses the 430 px. In each sample's document, reading-regions' observer is created before box-motion's placedParts (4th and 5th of the page's observers). It watches .lf-margin-preview as a reading-region host (sizes.observe(host)). Floating UI's observer of the same aside is created later (31st). So in the gallery's sequence, reading-regions is delivered the aside's grown 599 px first, and placedParts then shrinks the aside to 430 px in its own delivery. box-motion's header assumes placedParts is made before any other observer of a placed box, and here that assumption is false.

    Creating placedParts first doesn't settle it. I moved placedParts and its readers into rendering.js, so it's created before any module's observer. The gallery still failed 2 of 18 copies under the same load. So the order only explains the case where the aside was resized before the delivery. The fit can also resize the aside from inside a delivery of a deeper part while the aside itself wasn't resized beforehand, and then no creation order helps. That's the path the tightened cap took in test_a_card_a_scroll_moves_onto_or_off_the_windows_foot_as_it_resizes_only_resizes. page-layout.js already states the rule this breaks: a ResizeObserver callback must not resize a box it observes. The aside's own observers apply that rule to the aside too.

    What remains. Of the two options in the last comment, letting the delivery observe the aside can't work on its own. Whichever observer delivers the aside, a write to the aside's size during that delivery is skipped by every observer of the aside. That leaves moving the size write out of the delivery: when the fit placedParts asks for would change the aside's size, run that placement in the next frame's pass. The open question is what that frame paints. If box-motion follows the new layout without a placement for one frame, the card may visibly jump. So the change needs the motion's stills compared before and after, as well as the flake run. I haven't built it yet.

    Probe and runs
    • Reproduction on bd99da0ee: uv run leaf-dev suite flake --copies 18 --workers 4 --load 8 'tests/journeys/test_render_gate.py::test_page_fixture_opens_without_firefox_console_warnings[thread-panel-gallery]' failed 3 of 18 copies. At --workers 3 --load 6, 12 of 12 passed.
    • Probe: an init_script passed to open_page wraps ResizeObserver to record each observer's creation index, the runtime modules on its constructor's stack, and the targets it observes, read back from every frame (page.frames). In the sample documents (/api/samples/<id>/), observer 4 comes from reading-regions.js and observes lf-margin-preview. Observer 5 comes from box-motion.js and observes lf-margin-preview-card, lf-margin-preview-list and the card's parts. Observer 31 comes from annotation-overlay/floating.js through thread-preview.js and observes lf-margin-preview.
    • The ordering experiment, not committed: placedParts and the readers map moved to the end of rendering.js's observer section, with box-motion.js importing them. The same flake command failed 2 of 18 copies, with the same loop message.
  4. leaf-agent commented on Nov 22, 2026

    @leaf-agent
    CollaboratorAuthor

    Fix in #6727. A placement that box-motion's size delivery asks for no longer resizes the card in that delivery. It leaves the card's width and max-height as they are and fits the card again in the next frame. Moving the write out of the delivery was the option left open in the last comment.

    On Linux under load, the gallery errored in 3 of 12 copies on main (fac415460) and passed 18 of 18 with the change. test_a_card_a_scroll_moves_onto_or_off_the_windows_foot_as_it_resizes_only_resizes, which both earlier attempts broke, passes. The trade is at most one frame at the card's earlier size, while box-motion's tween is already following it. The PR's CI and landing are with tend-land. The macOS evidence is the next scheduled test-macos run after it merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tend-ci-cause

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions