Skip to content

Wait for first paint before reading a page's pre-runtime geometry - #807

Merged
max-sixty merged 1 commit into
mainfrom
fix/ci-35378363742
Sep 18, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/ci-35378363742

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

test_a_restored_auxiliary_surface_has_final_geometry_before_runtime_loads[saved0-…] failed on main's nightly for dd8e0de because its first geometry reading was taken before the page's render-blocking theme applied: it compared the user agent's own layout of the authored HTML against the themed page and reported the difference — the whole theme — as restoration moving the shell. The four pre-runtime measurements in the suite now wait for first contentful paint, through one new harness helper.

A box is not a paint. bounding_box, and Playwright's to_be_visible with it, force a layout that answers from the stylesheets that have arrived so far; a render-blocking stylesheet still in flight holds the paint back but not that forced layout. So expect(page.locator("h1")).to_be_visible() returns with a box the theme has never touched, and the reading behind it is the user agent's. Holding theme.css open on this page produces the nightly's two numbers exactly:

theme held:   {'x': 8,     'y': 21.4375, 'width': 1584}   sheets 0  paint 0
theme landed: {'x': 136.5, 'y': 42,      'width': 768}

displayed(page) waits on first-contentful-paint, which is the browser's own record that the render-blocking head has been applied and what it composed is on screen. That is the state each of these tests means to measure, since each one asks what a reader sees before the runtime loads — so the wait states the test's own premise rather than adding a tolerance to its assertion. Three other tests took the same reading behind element visibility alone and carried the same latent failure: test_authored_html_paints_while_runtime_startup_is_held beside it, and the two site shells in test_site.py. All four take the wait now, and tests/CLAUDE.md states the rule next to BOTH_STAMPS, where the readiness facts a test may consume are already listed.

No product code changes. The page's pre-runtime geometry was already right: every one of these tests passes once the theme has applied.

Bug-back and checks

The window is small enough that the case passes on a warm rerun, so the bug-back widens it with the browser rather than with repetition: 400ms of CDP-emulated latency on every response, applied to a copy of the failing test parameterized on whether it takes the wait. Without displayed it fails with the nightly's exact reading (x 136.5 vs 8 ± 1, y 42 vs 21.4375 ± 1, width 768 vs 1584 ± 1); with it, it passes. Held-route probing gave the reading above, which is where the numbers came from. Both were re-run on 78f9ba7a, this branch's base, after the theme change landed there.

  • uv run pytest tests/test_render_startup.py --run-nightly: 95 passed.
  • uv run pytest tests/test_site.py -n0 --run-nightly -k "paints_in_its_final_position or every_stage_of_site_startup": 2 passed.
  • uv run pre-commit run over the four changed files: passed.
  • The everyday gate, uv run pytest tests, on the same diff over dd8e0de: 1136 passed, 5 failed. Those five are this sandbox's: three test_interact_session.py cases and test_staged_writes_honor_umask_without_copying_a_replaced_symlink_mode fail on a read-only /tmp and on the file mode this container returns, and test_live_shell_artifact.py wants worker/'s node modules, which are not installed here. None of them load a browser.

The same nightly carried one more failure, test_a_refused_reopen_preserves_a_filter_typed_during_restoration, refused by the delivered page's CSP. That is #782's, and nothing here touches it.

`test_a_restored_auxiliary_surface_has_final_geometry_before_runtime_loads`
read `body > main` while the render-blocking theme was still in flight, so it
compared the user agent's own layout of the authored HTML with the themed page
and reported the whole theme as restoration moving the shell. A forced layout —
`bounding_box`, and `to_be_visible` with it — answers from the stylesheets that
have arrived, while the paint waits for the rest, so element visibility is not
the fact a pre-runtime measurement needs.

`displayed` waits on first contentful paint, the browser's own record that the
render-blocking head has been applied and what it composed is on screen. The
four measurements taken before the runtime lands take it first: the restored
auxiliary surface, the held authored paint beside it, and the two site shells,
which carried the same latent failure. `tests/CLAUDE.md` states the rule beside
the readiness stamps.
@max-sixty
max-sixty merged commit d72ce66 into main Sep 18, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/ci-35378363742 branch September 18, 2026 23:40
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