Skip to content

Keep a page ready while a chart sample is out of view, and show a check every waiting sample - #6558

Merged
max-sixty merged 8 commits into
mainfrom
sample-offscreen
Nov 20, 2026
Merged

max-sixty merged 8 commits into
mainfrom
sample-offscreen

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

A live sample holding a chart, started just below the window, kept its page arriving for as long as the page stayed open. As a result, leaf-dev probe and page check --render gave up after 240 s. Chromium renders a sample's opaque-origin page once, then not again while its frame is off screen or in a closed disclosure, and both the chart and the widget upgrade waiting on it need a later rendering (notes/browser-support.md).

The sample host now owns the child's whole arrival; lf-sample counts none of it.

  • Loading counts wherever the frame stands.
  • What the child does after loading counts only while the browser renders the frame, as rendering.js already treats a hidden document as settled. Meanwhile the host marks the frame data-lf-unseen.
  • The check: start_near_work scrolls each marked frame into view, at any depth, waits for the page holding it, and scrolls back every box it moved.

To weigh:

  • wait_until_ready now polls on the probes' 4 ms timer instead of animation frames, for every reader, since a hidden framed page runs none.
  • A check reads a sample that a scroll can't show, in a closed disclosure, a shut tab or a box clipped to nothing, only up to its load. On main, the check stalled on any such sample that held a chart.

Found while building a decision page for Max; a fresh agent reviewed it.

Tests: the new hosting test fails on main with the stall. 32 sample, frame and gate browser tests, pnpm run test:runtime, and page check --render on two pages that stalled (12 s each) all pass.

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

A live sample whose child page holds a chart never finished arriving when its
frame stood off screen, so the page it sat on never read as ready: `leaf-dev
probe` and `page check --render` gave up after 240 s
with "work the page deferred past presentation never landed".

Chrome renders a frame whose document has an origin of its own, as a sample's
child has, once and then not again while the frame is off screen or folded
away. Measured in Chromium over 5 s: an on-screen opaque frame ran 300
animation frames, one 300 px below the window ran 1, one inside a closed
`<details>` ran 1, and an off-screen same-origin frame ran 300; a
ResizeObserver attached after the first second delivered nothing in either
hidden frame, while timers ran at full rate. No Chromium switch tried lifts it.
A chart draws only after a size delivery that follows Plot's import, so a
sample started while near the window but off screen held its arrival open for
as long as the page stayed open.

Behavior change: the page now counts a sample document's allocation and load
wherever its frame stands, since loading needs no rendering, and what the child
does after only while its frame shows (`frameArrival`, presentation.js), as
rendering readiness already reads a document nobody can see as settled. A check
that reads every document (`start_near_work`) brings each frame still waiting
into view in turn, waits for it, and puts the window back; a frame in a shut tab
or closed disclosure stays as the page has it.

On the three-sample incident report that stalled, and on a minimal page of
three chart samples, `leaf-dev probe` is ready in 5 s, with the two samples in
view drawn and the third waiting for the reader. The new hosting test fails on
main with the 240 s stall.
…frame

Review of the previous commit found its check-side half wrong at depth: a sample
inside a sample was skipped silently, only the window's scroll went back, a held
resize landed after the check returned, and the wait after each scroll stayed
open only because the scroll left rendering unsettled. Its page-side half was a
second watcher of the frame beside the host's own (`admitted`), exported as a
public `frameArrival` that only sample code called.

Behavior change: the sample host now counts its child document's whole arrival,
and `lf-sample` counts none of it. An allocation counts from when it begins until
its frame loads, wherever the frame stands. From the load, or a reload's
connection, until the child reports its arrival or departs, the host counts it
until the browser's first reading of the frame and then only while the user can
see the frame. The widget layer's upgrade waits on a rendering too: a hidden
child holding a chart stayed at readiness stage `upgraded` with two arrivals
outstanding, so counting through upgrade wherever the frame stands still stalled
the page. The `arrived` host notice is gone; the child still reports its arrival
to the host.

A check's `near-work` now answers once the child has started that work, and
`start_near_work` waits for each sample's own document instead: for every sample
frame at any depth whose readiness is not `ready`, outermost first, it scrolls the
frame into view with Playwright, waits for that frame's readiness, and puts back
every box holding the frame in each document; then it waits one rendering and for
the page. A frame in a closed disclosure or a shut tab is left as the page has it.

On the reviewer's pages: a chart sample two thousand pixels down inside another
sample draws and upgrades; a sample in a scrolling box leaves the box at 0; a held
block sample is at its final 846 px on return in 3 of 3 runs; a page with
`scroll-behavior: smooth` returns at 0. The extended hosting test covers the box,
the nested sample and the settled layout; with the scroll put-back disabled it
fails with the window at 3536 and the box at 1494. `page check --render` passes in
12 s on the incident page of three chart samples and on the skim-size decision page.

module-authoring.md also drops the host's `waiting` notice, removed in #6474.
Second review: `start_near_work` read "this frame is waiting" from the child's own
readiness, so a sample frame no longer holding a Leaf page reported `started`
forever and the check waited out its 240 s deadline. On `departs.html`, a sample
whose child leaves for `about:blank` once connected, main's check returned and the
previous commit's raised `PageNotReady started`. The fact has one owner, the host's
arrival stage.

Behavior change: the host marks a frame `data-lf-unseen` while its document is
drawing and not counted, and the check reveals only marked frames. Each frame, at
any depth, first waits for the page holding it, which counts the frame's loading and
the near work it starts. The previous commit's per-frame wait missed a hidden outer
sample's inner one on `nested-deep.html`: the outer's near work started the inner
after the outer had already arrived, and the check returned with the inner unloaded.
A departure now ends any stage. The host counts drawing while the browser renders
the frame (`rendered`) rather than while the user can see it (`admitted`), which
also excluded a frame under an inert ancestor or another sample's Full view while
Chrome kept drawing it.

`wait_until_ready` polls its reading on the probes' 4 ms timer rather than on
animation frames: a framed page out of sight runs none, and the nested case of
`test_the_gate_reads_a_sample_far_below_the_window` waited out its 240 s deadline on
the outer sample's readiness in 4 of 4 runs before the change, and took 5 s in 4 of 4
after.

The two departure pages now return at once, the nested and held pages draw and
settle, and the far-below gate test passes in 5 s per case.
leaf-agent
leaf-agent previously approved these changes Nov 20, 2026
Third review: a chart sample hidden by an ancestor's clipping, such as a
`max-height: 0; overflow: hidden` accordion, passed the check's `checkVisibility`
test while the host's IntersectionObserver reading kept it unseen. `start_near_work`
then waited out its deadline for the mark to clear and raised a raw Playwright
`TimeoutError`, which the gate reports as `gate-failed`. Main stalls at load on the
same page.

Behavior change: after scrolling a marked frame into view, the check lets the
holder's next rendering deliver its observers' readings and reads the host's mark
once. A frame still marked stays as the page has it. A box that never stops moving
is left the same way. The host now counts a frame's drawing before the browser's
first reading of it only while its own page shows, since a hidden page's observers
never deliver that reading.

The hosting test gains a sample clipped to nothing: the check returns with its
chart undrawn, and the test passes in 7 to 8 s.
leaf-agent
leaf-agent previously approved these changes Nov 20, 2026
Fourth review: a marked sample inside an outer sample that CSS clips cost the
check Playwright's whole actionability timeout before it was left alone, since
`scroll_into_view_if_needed` waits for a stable box in the outer document, which
never renders. That timeout is 15 s in the probe and 120 s in the render gate.

Behavior change: the check scrolls the chain outermost first and, before scrolling
inside a framed document, asks that document for one rendering. A document that
gives none within 5 s ends the attempt, and the frame stays as the page has it. On
the reviewer's `outer-clipped.html` the check returns in 5.4 s, where it took
15.3 s.
@max-sixty
max-sixty merged commit 9b14382 into main Nov 20, 2026
6 checks passed
@max-sixty
max-sixty deleted the sample-offscreen branch November 20, 2026 04:44
max-sixty pushed a commit that referenced this pull request Nov 20, 2026
…ebsite tests' page fake (#6596)

Six developer-tool tests failed in [scheduled run
44722728605](https://github.com/max-sixty/leaf/actions/runs/44722728605)'s
`dev-tests` job because two tests lagged behind changes to what they
check:

- `test_generated_fields_are_checked_through_record_reads_and_writes`:
the dependency bump in #6530 moved ty from 0.0.99 to 0.0.104, which
reports an unknown TypedDict key as `error[invalid-typed-dict-key]`
rather than `error[invalid-key]`. ty still rejects the probe's bad key,
so the test now expects the new rule name.
- Five tests in `dev/tests/process/test_website_server.py`, such as
`test_the_agent_pass_waits_out_an_allocation_the_rollout_has_not_reached`:
#6558 made `render_checks`' handover wait poll on a timer
(`polling=PROBE_POLL_MS`), and the test's `_DeployedPage` fake didn't
accept that keyword, so each test raised `TypeError` before reaching its
assertions. The fake now accepts and ignores it, as the fake in
`tests/model/test_render_gate.py` already does.

Before this change, all six failed on `d714c2e60` (current main). After
it, all 31 tests in the two files pass. Neither PR's own CI runs
`dev/tests`. Only the daily `dev-tests` job does, so this went unnoticed
until the scheduled run.

The same job's eval smoke test (`test_ui_review_setup.cjs`) also failed.
That failure isn't covered here; it has its own cause issue.

Refs #4225 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 23, 2026
#6783)

A block live sample that starts just out of view stood at its 32rem
loading height when the page first read as ready, and shrank to its
page's height 100–200 ms later. On the feature gallery,
`#bg-margin-layer-status` drops from 552px to 309px, so `leaf-dev
stills` caught the taller side in one arm and reported the whole frame
changed: four of the seven stills that differed on #6715, and two of
four states on identical arms in each engine here. With this change on
both arms, those four states read unchanged in all 7 runs per engine.

Three gaps closed, each needed:

- **Host** (`sample.js`): a block's document now counts toward the
page's arrival wherever its frame stands, until it arrives, since the
frame takes its height. Before, it counted only while the frame was on
screen (#6558). A window sample's frame keeps its own height, so it
counts as before, and so does a block once a check asks for all near
work, since `start_near_work` then brings the frame into view itself.
- **Child** (`sample-child.js`): it reads its height again as it
arrives. Chromium delivers no ResizeObserver change off screen, so a
page whose recorded history changes its height after upgrading kept the
upgrade's height (381px for a page of 326px).
- **`settle`** (`leaf-dev`): it lets one rendering update pass before
reading readiness, after the input and again after the motion
`pageSettled` waits out. In Chromium the near observer reports a
scrolled-to sample only in that update.

To weigh: Chromium gives an off-screen opaque frame no rendering (0
animation frames in 5 s; Firefox ran 600), so a block sample whose page
waits on a rendering, such as a chart, never arrives there. A 20 s
deadline ends that wait, so `leaf-dev stills` and `probe` read such a
page as ready after 20 s rather than never, with the frame still at its
loading height; `page check --render` doesn't wait. No page in
`examples/` or `docs/` has one; the chart journey test, which covers the
deadline, now takes about 28 s.

Asked for by Max as "fix" on a question in the theme session's Leaf
page. Reviewed by a fresh Claude agent (two rounds), Codex and the
automated review; the fixes for their findings are in.

Tests: two new browser tests, one failing on main (readiness `None`, and
381 vs 326 without the child's change), the other checking a check's
near-work ask ends the wait; the off-screen chart journey gains a block
chart sample. The hosting, frame-visibility and sample-delivery tests,
`pnpm run test:runtime` and `pnpm run check:browser` pass.

> _This was written by Claude Code on behalf of max-sixty_
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