Skip to content

Commit 8bb30b5

Browse files
authored
test(interaction-harness): a busy-window proof can judge a component against a compositor-only control (#8906)
## Why A busy-window proof judges a compositor animation against a display-rate bound. On a two-core or loaded runner the compositor presents fewer frames than that bound allows though the animation moves on every one: Lightbox's double-tap zoom missed it in 7 of 10 two-core runs. A short fade gives one window too few frames. ## What led to it Both were written for Lightbox's proofs; only its pull requests carried them. ## Options and tradeoffs - Loosen the bound: it can't then tell a starved compositor from a frozen element. - Keep them in Lightbox's pull requests: other proofs would carry its base. - Their own harness pull request, on main (this one). ## Why this choice `startBusyControl(page)` mounts a small top-layer box that the compositor animates, tracked from the same screencast. `busyWindowProof(frames, window, {control})` passes when the component moves on every frame the control moves and never stalls longer. Same frames, so no tolerance. One exception: on an easing tail, a run of unchanged frames counts as moved when a single cast step ends it and it is at most a frame longer than the run before; a freeze ends in a larger catch-up. At least four control frames need a visible move. - `pooledBusyProof(runs)` judges short runs together. - `{within: dialog}` mounts the control inside an open dialog, for a backdrop proof. `waitForAnimation` and `blockMainThread`'s `during` never count the control's own animation, so on a dialog they still wait for the backdrop's. - A hold that starts before the block is judged from its first presented change inside it: WebKit presents a just-started compositor animation 130 to 300 ms late. Every frame after that change is judged, so a freeze later in the block still fails. - Main's three busy self-tests judge against the control. ## How to check it 1. `pnpm exec vitest run --project node internal/interaction-harness/src/busy.control.test.ts` 2. `pnpm test:interaction internal/interaction-harness/src/harness.interaction.browser.spec.ts --grep "busy|control|pooled"`: a compositor animation passes; a rAF one, timed or frame-counted, fails. ## Evidence - Noise floor: a compositor animation missed no control frame in 180 single and 90 pooled proofs. - Margin: the rAF mutant moved on at most 1 of 40 to 47 control frames (the one presented as the block starts) and always stalled longer; a frame-counted loop failed all 20 pools. - Lightbox's five busy proofs: Chromium 30 of 30; WebKit 33 of 40, the rest too few frames. - Load: main's first busy self-test failed 6 of 32 at 16 workers (every frame moved, stalls 63 to 109 ms); against the control, 48 of 48. Main's other two failed the same way (3 of 16 Chromium runs at 16 workers: "31/31 moved, longest stall 169 ms"); against the control, 32 of 32 per engine. - The first self-test's rAF run blocked right after cancelling the compositor run, so the compositor kept playing the cancelled animation into the block (the rAF mutant read 6 to 8 changed frames). With two animation frames before the block, a cancel-then-block probe kept moving in 0 of 8 Chromium runs, against 1 of 8 without them. - BottomSheet's dim in WebKit: under the top-layer control it held 155 to 225 ms into the block while the control moved; with `within` it moves in step with the sheet. On a dialog that animates nothing else, the two waits resolved at once on the control's animation; now they wait for the dialog's own, 6 of 6 per engine. - Wrapped self-test animations: a turnaround in the block failed 7 of 12; now 12 of 12. - Red first: every new case fails on main's `busy.ts`. Local gates at 187ee49: Prettier, ESLint and the harness typecheck pass on the changed files; the root build passes; the core UI suite passes; the node project passes except two process-timing cases in `packages/cli/foundation/release/cache.test.mjs`, which pass when that file runs alone (34 of 34), on this head and on main; the harness browser spec passes in Chromium (56 of 56, in two runs) and in WebKit apart from the backward self-test, a flake on main that #8535 fixes.
1 parent 5171ac1 commit 8bb30b5

5 files changed

Lines changed: 1472 additions & 46 deletions

File tree

‎internal/interaction-harness/README.md‎

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,63 @@ later in WebKit on a loaded machine). When the cast saw the element at rest
148148
before the block (wait for `cast.frameCount()` to pass 0 before starting the
149149
animation), judging starts at its first presented change: the judged part still
150150
ends with the block and still needs four intervals, and `onScreenFromMs` and the
151-
summary report when it came. An element already moving is judged from the
152-
block's start. WebKit's casts are 2 px quantized: the frames come at the
151+
summary report when it came. So is an element that moved, then held from
152+
before the block until its first presented change inside it: WebKit presents
153+
a just-started compositor animation late (a sheet's release held on screen for
154+
130 to 300 ms while its timeline ran), and its cast reaches Node about 0.7 s
155+
late on a loaded runner, too late to wait on before blocking. Only a hold that
156+
starts before the block, on two frames at least, is excused, and every frame
157+
after its first change is judged, so a freeze later in the block still fails.
158+
Any other element already moving is judged from the block's start. WebKit's
159+
casts are 2 px quantized: the frames come at the
153160
viewport's size, but the page in them is captured at half resolution, so
154161
positions move in 2 CSS px steps (Chromium's in 1). With under two steps of
155162
motion per frame, a frame delivered a few ms early shows no step and reads as
156163
not moved. The proof reports `stepPx` and `pxPerFrame` and notes motion under
157164
two steps per frame, which never fails it. Move a proof's element at least two
158165
steps a frame: the self-tests move 560 px in 1,600 ms, about 4.8 px a frame.
159166

167+
On a two-core runner the software compositor and the screencast share the core
168+
the block spins on, so every compositor animation presents fewer frames there:
169+
Lightbox's double-tap zoom, pinned to two cores, missed a display-rate bound in
170+
7 of 10 runs while it moved on every frame the compositor presented. Judge such
171+
a proof against a control instead of a rate: `startBusyControl(page)` shows a
172+
small `CONTROL_RGB` box in the top layer (a manual popover, so above a modal
173+
dialog opened before it; `raise()` after one opened later) whose transform
174+
moves it along the top edge for as long as the page runs. A proof of a
175+
dialog's backdrop mounts the control inside the dialog with
176+
`startBusyControl(page, {within: dialog})`, a plain fixed box with no top-layer
177+
entry: in WebKit, with the popover above BottomSheet's open modal dialog, the
178+
sheet's dim held for 155 to 225 ms into a block while the control moved, and
179+
inside the dialog it moves in step with the sheet. `waitForAnimation` and
180+
`blockMainThread`'s `during` never count the control's own animation, so on
181+
a dialog they still wait for the backdrop's. Track it from the
182+
same screencast (`trackMarker(page, frames, {rgb: CONTROL_RGB})`) and pass it
183+
as `control`: the component passes when it moved on every frame the control
184+
moved and its longest stall is no longer than the control's. Both are read from
185+
the same screencast frames, so a compositor animation misses none. A window in
186+
which the control moved on fewer than four frames fails, since the machine
187+
presented too little to judge. A run of frames with no new position counts as
188+
moved when the change that ends it is a single cast step: the component moves
189+
under one step a frame there, as on an easing tail, which the cast cannot show
190+
on every frame. The run must also read as a slowing curve, at most one frame
191+
longer than the component's run before it. A freeze ends in a catch-up of more
192+
than one step, a stall in a frame-counted animation is longer than its runs
193+
before it, and a run that no change ends stays a miss. The component still has
194+
to show a new position on at least four of the control's frames. The cast step (`stepPx`)
195+
is read from the value's changes in the judged part, so a position the page
196+
commits off the grid once the block ends does not shrink it.
197+
A main-thread animation still fails: the control moves and it does not.
198+
199+
An animation that lasts a fraction of a second, such as a 0.2 s fade, leaves a
200+
block only a few frames to judge: in WebKit, or on a loaded machine, the control
201+
can present fewer than four, and one run cannot decide. Play it several times
202+
and judge the runs pooled (`pooledBusyProof(runs)`, each run with its own
203+
tracked frames, control and window): the control must move on at least four
204+
frames over all the runs, the component on every one of them, and in each run
205+
its longest stall may be no longer than that run's control's, since a stall
206+
belongs to its run.
207+
160208
On a loaded machine Chromium's screencast can skip frames the compositor
161209
still presents. `startCompositorTrace(page)`, started with the screencast and
162210
stopped after the block, records when the compositor presented each frame

0 commit comments

Comments
 (0)