Skip to content

test(harness): busyWindowProof reads a slow tail inside a fast window locally - #9233

Merged
cixzhang merged 3 commits into
meta:mainfrom
vjeux:bank/busy-slow-tail
Nov 1, 2026
Merged

cixzhang merged 3 commits into
meta:mainfrom
vjeux:bank/busy-slow-tail

Conversation

@vjeux

@vjeux vjeux commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

busyWindowProof failed a spring that settles through a busy window: the frames were all there, but the proof counted a freeze ("moved on 61 of the 62 frames the control moved", "longest stall 28.8 ms, longer than the control's 25.8 ms"). A component proof that judges an easing or spring animation through a blocked main thread can fail this way on any runner.

Intended invariant

busy.ts's verdict, as the README states it: a frame with no new position counts as moved only where the cast cannot show the motion on every frame; a freeze still fails.

Change

  • Cause: the spring moves 3.6 px a frame over the window but about 1.7 in its tail, on a 1 px cast grid.
    • There a frame delivered early can show no step, and the next carries two frames of motion: a 2 px catch-up.
    • The allowance for a run of unchanged frames accepted only a catch-up under 1.5 steps. That assumes motion under one step a frame, so the run counted as a miss.
  • Fix:
    • Where the component moved under two steps a frame over the four frames just before a run, the change that ends the run may carry the motion of every frame the run held at that pace, plus one step for rounding.
    • An early delivery hides one frame's motion. At one step a frame or more, the allowance therefore credits a run of one unchanged frame, so a credited early frame cannot let the next run hold two. Under one step a frame, the catch-up stays under 2.5 steps.
    • The slowing-curve rule still applies (a run at most one frame longer than the run before it), and so does the comparison with the control.
  • Note: the "under two steps" note was read from the window's first and last frames only, so a slow tail inside a fast window never showed. It is now read over four frames at a time and names each slow stretch with its time range. It still never fails a proof.
  • Docs: the README and busyWindowProof's doc state both.

Evidence

  • Failure before the change: busy.test.ts replays the recorded run (busy.slowtail.fixture.ts: the spring's and the control's frames from one Chromium run). With main's busy.ts the proof fails both checks.
  • Success after the change: the replay passes, and the note names the tail.
  • Still fails:
    • the same run with the tail frame held one frame longer (a two-frame freeze);
    • at 1.75 px a frame against a control that moves on every frame, one frame with no step followed by a two-frame freeze (positions 50, 50, 54, 54, 54, 59);
    • at 0.8 px a frame, a two-frame freeze that ends in a three-step catch-up (32, 32, 33, 33, 33, 36), and the same doubled on a 2 px grid; one early frame at that pace still reads as moved;
    • a 3 px-a-frame animation with one repeated frame against a control that moves on every frame.
  • Unchanged: every other busy.test.ts and busy.control.test.ts case; the harness unit cases pass (97).
  • The five busy-main-thread browser self-tests:
    • Under the WebKit CI job's own profile (4 CPUs, CI=1, LP_NUM_THREADS=4, one worker) ×10: 50 of 50 passed.
    • At 3 CPUs with one worker ×10 (at the previous head f907c0e): 50 of 50.
    • In Chromium pinned to two cores ×10: 49 of 50 (main's busy.ts gave 42 of 50 there in an earlier session). The failure is in a test this change does not reach, and no frame in it was credited by the allowance: frames the main thread committed before the block reach the screen inside it on two starved cores, so the rAF control showed new positions on 2 frames where the test expects at most 1.
    • At 3 CPUs with 16 workers (with LP_NUM_THREADS=3, so the software compositor's threads match the cap) the screencast delivers frames 100 to 250 ms apart, and most runs fail on main and here alike (per test, main: 10, 2, 10, 10, 8 of 10 failed; here: 10, 4, 9, 10, 4): a limit of the starved runner, not a pass.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project node internal/interaction-harness
  • The busy-main-thread self-tests in harness.interaction.browser.spec.ts, in Chromium and through internal/interaction-harness/scripts/webkit-container.mjs.

Local gates at 0d6acba: prettier and strict eslint on the changed files, the harness typecheck, the harness unit cases (97 passed, the recorded slow-tail replay among them), and the five busy-main-thread self-tests under the WebKit CI job's own profile (50 of 50). The whole harness spec passed at f907c0e in Chromium (77) and WebKit (65 passed, 12 skipped).

… locally

A spring settling through a busy window moves 3.6 px a frame on average but
about 1.7 in its tail, on a 1 px cast grid. There a frame delivered early can
show no step, and the next carries two frames of motion: a 2 px catch-up. The
allowance for a run of unchanged frames only accepted a catch-up under 1.5
steps, which assumes motion under one step a frame, so the run counted as a
miss and the proof failed ("moved on 61 of the 62 frames the control moved",
"longest stall 28.8 ms, longer than the control's 25.8 ms").

Where the component moved under two steps a frame over the four frames just
before a run, the change that ends the run may now carry the motion of every
frame the run held at that pace, to the nearest step. The slowing-curve rule
(a run at most one frame longer than the run before it) still applies, so a
two-frame freeze in a slow tail and a repeated frame in a fast window still
fail. The "under two steps" note is read over four frames at a time and names
each slow stretch, so a slow tail inside a fast window shows.
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 1, 2026 2:25am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 1, 2026
@astracat-bot

astracat-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 1, 2026, 2:33 AM UTC

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 0d6acba

Storybook · Sandbox · built from this PR's head

Package size: no published package changed; no new dependencies.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: the slow-tail allowance fixes the recorded spring run, but it also passes a two-frame freeze that directly follows one credited early frame (positions 50, 50, 54, 54, 54, 59 at 1.75 px a frame, with the control moving on every frame). main fails that case, and the description says such a freeze still fails. Limiting the new branch in underStep to one unchanged frame when the pace is at least one step a frame, (pace < stepPx || unchanged <= 1), makes that case fail while the recorded fixture and the existing unit cases still pass; please add it as a regression test, and move slowStretches above busyWindowProof's doc comment, which the helper now detaches from the function.

[Automated review]

Comment on lines +861 to +865
const shown =
catchUp < 1.5 * stepPx ||
(pace != null &&
pace < 2 * stepPx &&
catchUp <= (unchanged + 1) * pace + stepPx);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This branch also credits a two-frame freeze right after one credited repeat. The slowing-curve rule allows unchanged = 2 once the previous run had one repeat, and the catch-up limit (2 + 1) * pace + stepPx admits it. For example, positions 50, 50, 54, 54, 54, 59 at 1.75 px a frame, against a control that moves every frame, pass here and fail on main. At one step a frame or more, an early delivery can hide only one frame, so consider:

(pace != null &&
  pace < 2 * stepPx &&
  (pace < stepPx || unchanged <= 1) &&
  catchUp <= (unchanged + 1) * pace + stepPx)

With this, that case fails, the recorded slow-tail fixture still passes, and all 95 harness unit cases pass. A regression case for it would pin the claim that a two-frame freeze still fails.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a9d3255 with your condition: at one step a frame or more the allowance now credits only a one-frame run (pace < stepPx || unchanged <= 1), so a credited early frame cannot let the next run hold two. Your case (50, 50, 54, 54, 54, 59 at 1.75 px a frame against a control moving on every frame) is a unit case and fails; the recorded slow-tail run and the other 95 harness cases still pass. slowStretches now sits above busyWindowProof's doc comment, so the contract is attached again.

* `maxMedianFrameMs`, when given, still applies; `minMovedFraction` and the
* absolute stall, frame and motion limits do not.
*/
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Inserting slowStretches here puts its doc block between busyWindowProof's doc comment (lines 364-450) and export function busyWindowProof. TypeScript attaches only the last doc block before a declaration, so busyWindowProof now has no documentation in editor quick info (0 characters, against 5,076 on main). Moving slowStretches above line 364 keeps the contract attached.

…a slow tail

At one step a frame or more, an early delivery hides only the frame it
lands on, so the slow-tail allowance now credits a run of one unchanged
frame there. Before, the slowing-curve rule let the run after a credited
early frame hold two frames, and the catch-up limit admitted it: positions
50, 50, 54, 54, 54, 59 at 1.75 px a frame passed against a control that
moved on every frame. That case is a unit test now, and fails. `slowStretches`
moves above `busyWindowProof`'s doc comment, which it had detached from the
function.
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 1, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 1, 2026 00:49

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: the follow-up fixes the two-frame freeze at one step a frame and reattaches busyWindowProof's doc, but under one cast step a frame the new branch still credits a two-frame freeze that ends in a three-step catch-up. For example, positions 32, 32, 33, 33, 33, 36 at 0.8 px a frame (or 64, 64, 66, 66, 66, 72 at 1.6 px a frame on a 2 px grid), with the control moving on every frame, pass here and fail on main. Capping that catch-up at two steps, (pace < stepPx ? catchUp < 2.5 * stepPx : unchanged <= 1) in place of (pace < stepPx || unchanged <= 1), makes both fail while the recorded fixture, every single-early-frame case and the existing busy unit cases still pass; please add the 0.8 px case as a regression test. The doc and comment at busy.ts:473-474 and :810-814, the belowStep and componentStallMs docs, and the summary label still describe the old one-step rule.

[Automated review]

Comment on lines +865 to +868
(pace != null &&
pace < 2 * stepPx &&
(pace < stepPx || unchanged <= 1) &&
catchUp <= (unchanged + 1) * pace + stepPx);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Under one cast step a frame this gate does not apply, so the only limit on the catch-up is (unchanged + 1) * pace + stepPx, a full step over the run's motion. At 0.8 px a frame on a 1 px grid, positions 32, 32, 33, 33, 33, 36 (honest frames 33, 34, 35, 36) pass here against a control moving on every frame and fail on main: one early frame adds at most one step, so this is a two-frame freeze. Capping the catch-up at two steps there keeps the fixture and every single-early-frame case passing:

(pace != null &&
  pace < 2 * stepPx &&
  (pace < stepPx ? catchUp < 2.5 * stepPx : unchanged <= 1) &&
  catchUp <= (unchanged + 1) * pace + stepPx)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 0d6acba with your cap: under one step a frame an early frame adds at most one step, so the catch-up there stays under 2.5 steps (pace < stepPx ? catchUp < 2.5 * stepPx : unchanged <= 1). Your 0.8 px case (32, 32, 33, 33, 33, 36) and the 2 px-grid one (64, 64, 66, 66, 66, 72) are unit cases and fail, one early frame at that pace still reads as moved, and the recorded slow-tail run still passes. The doc and comment you pointed to, the belowStep and componentStallMs docs and the summary label now describe the rule as it is.

* step too, so the change may carry the motion of every frame the run held
* at that pace, to the nearest step. The run also has to read as a slowing
* curve, at most one frame longer than the component's run before it. A freeze ends in a
* catch-up of more than one step, a stall in a frame-counted animation is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This still says a freeze ends in a catch-up of more than one step, while the README now says "more than that"; the file header asks the two to match. The comment at lines 810-814, the belowStep and componentStallMs docs (144-152) and the summary label at 964 ("under one cast step a frame") describe the same old rule.

…e step to a catch-up

Under one cast step a frame the slow-tail allowance limited a run's
catch-up only by the run's motion plus a step, so a two-frame freeze that
ended in a three-step catch-up passed: positions 32, 32, 33, 33, 33, 36 at
0.8 px a frame (or 64, 64, 66, 66, 66, 72 at 1.6 px on a 2 px grid), with
the control moving on every frame. An early frame hides one frame's motion,
so there the catch-up is now under 2.5 steps. Both cases are unit tests and
fail; one early frame at that pace still reads as moved, and the recorded
slow-tail run still passes. The docs, the comment and the summary label now
describe the rule as it is.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Recommending approval: both earlier findings are fixed (a two-frame freeze under one cast step a frame now fails, and the field docs and summary label describe the new rule), the recorded slow-tail run passes, and every new freeze case fails. One optional follow-up: the README's busy-main-thread section and busyWindowProof's doc state the pace allowance but not its two limits (only a one-frame run at one step a frame or more, and a catch-up under 2.5 steps below one), which the code comment at busy.ts:856-862 spells out; a sentence in each would explain why a two-frame run at 1.5 px a frame still fails.

[Automated review]

@cixzhang
cixzhang merged commit 3a2d3d9 into meta:main Nov 1, 2026
54 checks passed
@vjeux
vjeux deleted the bank/busy-slow-tail branch November 1, 2026 02:37

This branch was successfully deployed

1 active deployment
Preview — 0d6acba5 Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants