Skip to content

Judge every Firefox frame's watches on Playwright 1.65, and fail a frame whose judgement never completes - #5530

Merged
max-sixty merged 5 commits into
mainfrom
grind/firefox-lost-frames
Nov 10, 2026
Merged

max-sixty merged 5 commits into
mainfrom
grind/firefox-lost-frames

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

#5803 moved the suite to Playwright 1.65.0, whose Firefox build no longer loses frames. This raises the dev group's Playwright floor to 1.65, since on 1.64.1 the frames Playwright loses would now fail their test (measured below). The [project] dependency serves Chrome only and stays at 1.64.

judge_watches asked each Firefox child frame wait_for_function("() => true") with the 120 s suite deadline, and read the timeout as "Playwright lost this frame, nothing to judge". Each lost frame cost the full deadline. The feature gallery's Firefox console test took 1,614 s on daily run 42014155473, 1.1x under the per-test limit. This PR removes that probe (_reachable). Every frame is judged the same way in every engine, through one bounded wait_for_function that starts the drain on its first reading and returns when the drain completes. When that deadline expires, the test fails with a note naming the frame, rather than skipping the frame. No wait left in judge_watches decides a result by expiring (tests/AGENTS.md, "Functional results do not depend on execution speed"; #5522).

Why frames were lost

The frames are lost by Playwright's Firefox (Juggler), not by Leaf. Juggler learns that a frame's navigation has started from an observer whose subject is the frame's docShell, passed as a bare nsISupports. Its FrameTree read docShell.browsingContext without QueryInterface(Ci.nsIDocShell). In one run, the lookup found the frame for the early navigations and returned nothing for the later ones, and those navigation starts were dropped. When the new document's element is inserted, Juggler finds no pending navigation, so it never commits the document, never creates its execution context and never runs init scripts there. Firefox itself loads the document normally, and the sample becomes ready.

Why the unqueried read works at first is inferred, not observed: XPConnect reuses an earlier reflector of the docShell that was queried for nsIDocShell, until garbage collection frees it. Pages of window samples trigger the loss: 18 window samples lost 2 to 11 frames per run, and 12 plain samples lost none.

Upstream fixed it in Firefox r1564 (microsoft/playwright#43494, const docShell = subject.QueryInterface(Ci.nsIDocShell)). Playwright 1.65.0 ships r1572.

Evidence:

  • A copy of Juggler patched to log its observer printed frame=null without the QueryInterface, and the right frame with it, for every lost navigation. A second observer on the same topic fired for all 18 loads.
  • A plain Playwright page with 12 sandboxed iframes navigated in batches of three lost none.

Before and after

The feature-gallery Firefox console test on this Mac, -n 0 -p no:randomly:

Harness Firefox Time Child frames
main r1555 (Playwright 1.64.1) 1,213 s 10 of 18 timed out at 120 s each; 8 answered in 0.01 s
main r1572 (Playwright 1.65.0) 14 s 18 answered
this PR r1572 17 s all judged; slowest 0.03 s
this PR on Playwright 1.65.0 r1572 22 s passes
this PR r1555 fails after 136 s Timeout 120000ms exceeded, "judging the watches in about:blank"

The r1572 rows drive the downloaded r1572 build from this tree's Playwright 1.64.1 client through executable_path.

Control

test_words_in_a_firefox_frame_its_page_hides_fail_when_judged types words into an opaque Firefox frame, as a sample's is, and then the page hides the frame. A hidden frame paints nothing, so only the judgement reports the loss. With Firefox child frames skipped in _judge_frame_watches, the test fails with no finding.

test_health_judgement_releases_a_frame_removed_inside_its_evaluation now watches the one wait_for_function call, since judgement no longer calls evaluate. The comment in input_work_watch.js no longer cites lost Firefox frames as the reason a port message carries its source as an extra field. A worker, which runs no init script, still reads past that field.

Checks

  • tests/journeys/test_render_gate.py -k firefox_console_warnings: all 48 corpus pages pass on r1572 (44.75 s, -n 3).

  • tests/browser/test_render_shift_watch.py -k "frame or deadline" with test_a_wait_takes_the_suites_deadline: 20 passed.

  • tests/browser/test_render_words_watch.py -k frame: 4 passed.

  • dev/tests/browser/test_browser_diagnostics.py: 7 passed.

  • pre-commit run --files on the changed files.

  • On Playwright 1.65.0's own client, after merging main: the feature-gallery Firefox console test (22 s, -n 0), the hidden-frame control and -k health_judgement pass.

Not verified locally: Linux, and the Firefox browser tests outside the corpus console sweep and the control; the pull request's test job runs them.

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

… never completes

`judge_watches` asked each Firefox child frame `wait_for_function("() => true")`
with the 120 s suite deadline and read the timeout as "Playwright lost this frame,
nothing to judge". Each lost frame cost the full deadline: the feature gallery's
Firefox console test took 1,614 s on CI's daily run, 1.1x under the per-test limit.
This removes that probe (`_reachable`). Every frame is judged the same way in every
engine, through one bounded `wait_for_function` that starts the drain on its first
reading and returns when the drain completes. When that deadline expires, the test
fails with a note naming the frame, rather than skipping the frame.

Playwright's Firefox (Juggler) loses those frames, not Leaf. Juggler learns that a
frame's navigation has started from an observer whose subject is the frame's
docShell, passed as a bare nsISupports. Its FrameTree read `docShell.browsingContext`
without `QueryInterface(Ci.nsIDocShell)`, so the lookup found the frame for the
early navigations in a run and none for the later ones, and those navigation starts
were dropped. When the new document's element is inserted, Juggler finds no pending
navigation, so it never commits the document, never creates its execution context
and never runs init scripts there. Firefox itself loads the document normally, and
the sample becomes ready. Why the unqueried read works at first is inferred, not
observed: XPConnect reuses an earlier reflector of the docShell that was queried
for nsIDocShell until garbage collection frees it. Pages of window samples trigger
it: 18 window samples lost 2 to 11 frames per run, 12 plain samples none.

Evidence:
- A Juggler build patched to log its observer printed `frame=null` without the
  QueryInterface and the right frame with it, for every lost navigation; an
  independent observer on the same topic fired for all 18 loads.
- Upstream fixed it in Firefox r1564 (microsoft/playwright#43494, `const docShell =
  subject.QueryInterface(Ci.nsIDocShell)`). Playwright 1.65.0 ships r1572.
- The feature-gallery Firefox console test on this Mac, `-n 0`:
  - main, Playwright 1.64.1 (Firefox r1555): 1,213 s; 10 of 18 child frames
    timed out at 120 s each, 8 answered in 0.01 s.
  - main's harness on Firefox r1572: 14 s, none lost.
  - this change on Firefox r1572: 17 s, all 19 frames judged, the slowest child in
    0.03 s.
  - this change on r1555: fails after 136 s at the first lost frame, `Timeout
    120000ms exceeded`, "judging the watches in about:blank".

This change therefore lands with Playwright 1.65 in `uv.lock`. On 1.64.1, the
Firefox frames Juggler loses fail their test.

`test_words_in_a_firefox_frame_its_page_hides_fail_when_judged` is the control:
words typed in an opaque Firefox frame that its page then hides are reported only
by the judgement, since a hidden frame paints nothing. With Firefox child frames
skipped, it fails with no finding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the lock moves to Playwright 1.65, also raise the dev group's floor in pyproject.toml (dev = [ ... "playwright>=1.64", ...]) to >=1.65. Without _reachable, judgement depends on the r1572 Juggler fix, so on 1.64.x the Firefox frames it loses now fail their test after 120 s each instead of being skipped. uv lock --upgrade-package playwright moves only the lock. The floor is what states that requirement, and it is the pin a later uv lock resolution respects. The [project] dependency serves Chrome only, so it can stay where it is.

On 1.64.1 the frames Playwright's Firefox loses fail judge_watches by name; 1.65.0 ships Firefox r1572 with the upstream fix (microsoft/playwright#43494). The feature-gallery Firefox console test passes in 22 s.
@max-sixty max-sixty changed the title Judge every Firefox frame's watches, and fail a frame whose judgement never completes Judge every Firefox frame's watches on Playwright 1.65, and fail a frame whose judgement never completes Nov 10, 2026
@max-sixty
max-sixty marked this pull request as ready for review November 10, 2026 19:20
leaf-agent
leaf-agent previously approved these changes Nov 10, 2026
…s needs its Juggler fix

Without _reachable, a frame Playwright 1.64's Firefox loses fails its test after the deadline instead of being skipped. The [project] dependency serves Chrome only and stays at 1.64.
max-sixty added a commit that referenced this pull request Nov 10, 2026
…le as each engine reads it (#5803)

This moves the suite to Playwright 1.65.0 and changes how Leaf spells
`position-visibility: anchors-visible`, which Playwright's new Chromium
warns about. The CSS working group renamed the value to
`anchor-visible`. Chromium 158 warns in the console wherever it parses
the old plural, and `page check --render` reports that warning as a
finding against the page. So once Chrome 158 reaches stable, every
agent's render check would report a finding against Leaf's own
stylesheet. Firefox 159 still reads only the plural, so neither spelling
works on its own.

`--lf-anchor-visible` (`browser/styles/tokens.css`) holds the value: the
plural by default, and the singular where `@supports` reads it. The four
places that hide a box once its anchor is out of sight now read it: the
preview, the reaction palette, the response options and the target paint
boxes. A custom property's value is parsed only where a declaration uses
it, so Chromium never parses the plural and Firefox never the singular.
Writing both declarations, or putting the plural in a `@supports not`
block, still warns in Chromium 158, because it parses the rule either
way. `notes/browser-support.md` records the gap and gives the check that
says when Firefox reads the singular, after which the property can go.

| Engine | `anchors-visible` | `anchor-visible` |
|---|---|---|
| Chromium headless shell 158.0.8127.18 (Playwright 1.65.0) | read, with
a console warning | read |
| Google Chrome 157.0.8103.50, installed | read | read |
| WebKit 27.2 (Playwright build 2388) | read | read |
| Firefox 159.0 (Playwright 1.65.0) | read | refused |

Two private Playwright names that Leaf's tools reach into changed in
1.65, and `ty` fails on them: `playwright._impl._fetch` is now
`playwright._impl.fetch` (`test_public_api.py`), and `SyncBase._sync`
names its argument `awaitable` (`leaf-dev suite-profile`'s wrapper).

The Playwright move is here because only its Chromium shows the warning.
On [#5530's CI
run](https://github.com/max-sixty/leaf/actions/runs/42886152123), which
already moved to 1.65.0, this warning caused every failure: 1 failed and
9 errors in `tests/smoke`, out of 3,264 that passed. #5530 then only
needs its harness change and the dev group's floor.

Checked:
- `leaf-dev probe feature-gallery` in Chromium 158, Firefox 159 and
WebKit 27.2. The root property and the computed `position-visibility` of
the preview, the response options and an inline paint box are
`anchor-visible`, `anchors-visible` and `anchor-visible` respectively,
and the console is empty.
- The three smoke tests that failed on #5530
(`test_a_host_draws_each_widget_as_a_leaf_page_does`,
`test_a_shipped_page_passes_the_real_browser_gate`,
`test_ship_review_obligations_are_directly_answerable`) pass on Chromium
158.
- `pre-commit` on the changed files, `ty` on all files, and
`test_closing_an_output_observer_during_its_body_read_keeps_the_browser_usable`.

No test was added. Two tries with a focus preview couldn't tell the
spellings apart. When the window scrolls, the preview leaves the window
with its target. When a scroller hides the target, the preview doesn't
stay where the window had room for it. The comment at the property says
why each engine needs its spelling.

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit fcd157f into main Nov 10, 2026
4 checks passed
@max-sixty
max-sixty deleted the grind/firefox-lost-frames branch November 10, 2026 20:43
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