Skip to content

test: read the swap watch's boxes without a ResizeObserver, so it raises and hides no loop errors - #5898

Merged
max-sixty merged 1 commit into
mainfrom
swap-watch-resize-loop
Nov 14, 2026
Merged

max-sixty merged 1 commit into
mainfrom
swap-watch-resize-loop

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

The browser tests' swap watch (tests/swap_watch.js, injected into every page a browser test opens) read flex rows with its own ResizeObserver. When a page ResizeObserver on a deeper box resized a row the watch observed, the browser left the watch's observation undelivered and raised a loop error the page didn't cause. That is the teardown error failing test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame[combined-selection] in most of main's push runs (#3985); instrumented, the skipped observation was the watch's own, on .lf-fab-bar. The same observer also hid loop errors pages raise themselves: its shallow deliveries let a page's deeper observers deliver where the browser would otherwise leave them undelivered (reproduced in Chromium and Firefox).

The watch now reads boxes from an IntersectionObserver in the update after anything that may change one (a DOM write, text included, a resize, an image or font arriving, hover, a press, focus or typing) and in each update while an animation runs. It converts each painted box back to its layout box, so it judges the same sizes as before.

What to weigh:

  • A box changed by something no trigger announces, such as a script setting a textarea's value or editing a style sheet, is read only at the next trigger, so a swap in its row before then is judged against the old size. Leaf's own UI sets no textarea value. Reading every frame instead would close this, but keeps every test page rendering continuously.
  • A page's own loop errors now fail its test, and the watch catches swaps main's missed. A fixed random sample of 240 browser-tier tests, run four workers wide, failed the same Firefox preview test on main's watch and on this one, and once a Firefox anchor test on this one; both pass 18 of 18 concurrent copies (leaf-dev flake) on either watch.
  • Cost on leaf-dev bench's 256-ask page (5,400 watched boxes), main-thread CPU per input against main's watch: keystroke 11.4 vs 8.6 ms in Chromium and 16.7 vs 11.9 ms in Firefox, wheel step 10.7 vs 7.8 ms in Chromium and level in Firefox. Each reading walks every watched box.

#5754's 19 cases plus a transition case: main's watch judges 7 wrong, 4 of them with loop errors; this one judges all 20 right in both engines, over repeated runs. The cases two review rounds added pass too, except the two the first point describes. The failing test errored in 3 of 3 runs under taskpolicy -b before, and has passed all 8 since, 2 of them on this head. The new tests in test_render_swap_watch.py each fail on main's watch or on this one with the mechanism they cover removed. #5754 asks for main's cost too, so it stays open for the cost above.

Part of #5754. Requested by Max in a dispatched session; reviewed in two rounds by a separate agent.

This was written by Claude Code on behalf of max-sixty

…ses and hides no loop errors

The swap watch, which the browser fixture injects into every page a browser test
opens, read flex rows with its own ResizeObserver. When a page ResizeObserver on a
deeper box resized a row the watch observed, the browser left the watch's observation
undelivered and raised "ResizeObserver loop completed with undelivered notifications",
an error the page didn't cause. That error fails
test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame[combined-selection]
in most of main's push runs; instrumented, the skipped observation was the watch's own,
on .lf-fab-bar. The same observer also hid loop errors pages do raise, since its
shallow deliveries let a page's deeper observers deliver where the browser would
otherwise leave them undelivered.

The watch now reads boxes from an IntersectionObserver in the update after anything
that may change one (a DOM write, text included, a resize, an image or font arriving,
hover, a press, focus or typing) and in each update while an animation runs. It
converts each painted box back to its layout box, so it judges the sizes it judged
before. Behaviour this changes, each now a test:

- a page observer that swaps a standing row's occupant in its delivery is judged with
  no loop error, and a loop error the page raises reaches the test;
- an occupant shown for one frame is judged in that frame, from the boxes it painted;
- an occupant that arrives and moves on before a frame takes no seat;
- a row under a transform is judged in layout pixels, as its padding is.

A box changed by something none of the triggers announce, such as a script setting a
field's value or editing a style sheet, is read only after the next trigger.
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.

2 participants