Skip to content

test(usePager): judge the report two frames into the settle, not 20 ms - #10778

Merged
cixzhang merged 2 commits into
meta:mainfrom
vjeux:bank/pager-moving-frames
Nov 9, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
vjeux:bank/pager-moving-frames

Conversation

@vjeux

@vjeux vjeux commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

One test in usePager.interaction.browser.spec.ts sometimes fails in Chromium on a loaded runner. Its title starts "callbacks: the new page once the settle is moving". The report arrives as index:2:drag, without :moving. On main fa30cff, with 4 workers on 2 pinned cores, it failed 6 of 420 runs.

Intended invariant

createPager's documented timing does not change: onIndexChange reports a release's page "once its settle runs on the compositor, two frames after the frame it started in."

Change

The fixture marked a report :moving when a running animation had currentTime > 20 ms. Chromium dates the start anywhere inside its frame, up to about 15 ms in. The pager reports two frames after the start's frame, so the report can find the settle only 18–20 ms in.

The fixture now counts frames instead of milliseconds, from the frame the pager counts from. The browser must also have told the settle's start. In Chromium, the pager counts from the frame that commits the settle (animator.ts: "the call starts at the frame that commits it"). That is the first frame whose callbacks run after the settle is made. A preempted main thread can run that frame late with a stale stamp, and Chromium then dates its own start a frame later. WebKit stamps its start frame at or after the start, so the count starts there.

This is a cause fix, not a loosening: the old bar measured the wrong quantity, and a report one frame early fails in both engines.

Evidence

  • Failure before the change: the 6 of 420 above. Each read currentTime 18.0–19.7 ms, under the 20 ms bar.
  • Counting from Chromium's own start, as 5db6ef4 does, failed 3 of 2440 runs. Each was the preempted case.
  • Success after the change, at 0210354 with 1 worker: Chromium passed 120 of 120. WebKit passed 20 of 20 in CI and 20 of 20 under load. Harsher extra runs passed too: Chromium 200 of 200 with 4 workers. A copy that dumps each frame passed 120 of 120 with 8 workers, 2 preempted.
  • Mutation proof: usePager.ts changed to report one frame early (afterFramesPastStart(1, …)). The check fails it 10 of 10 in each engine.
  • Product/runtime behavior verified unchanged: the diff touches only the test. At 0210354 the whole spec file passes in Chromium (24 passed, 2 skipped) and in WebKit (23 passed, 3 skipped).
  • CI impact: none.

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

CI=1 taskset -c A,B pnpm exec playwright test --config playwright.interaction.config.ts --project=chromium packages/core/src/hooks/__tests__/usePager.interaction.browser.spec.ts -g "callbacks: the new page" --repeat-each=40 --workers=4

WebKit runs the same filter through internal/interaction-harness/scripts/webkit-container.mjs with CI=1 --repeat-each=20 --workers=1.

The callbacks test checked that a release's report found the settle
more than 20 ms past the browser's start. The pager reports two frames
after the frame that the settle started in. Chromium dates that start
anywhere inside its frame, up to about 15 ms in under load. So the
report can find the settle 18-20 ms in, and the check failed. It now
counts the page's frames from the browser's start to the report, and
asks for two. A report one frame early still fails it.
@vercel

vercel Bot commented Nov 9, 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 9, 2026 2:20pm UTC

Request Review

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

astracat-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 9, 2026, 2:38 PM UTC

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 0210354

Storybook · Sandbox · built from this PR's head

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

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 36 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

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

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 9, 2026
@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 5db6ef4

@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 claim that the new check catches an early report holds only in Chromium, so the description and commit message need to say so (or the WebKit count needs a fix).

  • The description says the new check "still fails when the report comes early" and the commit message says "A report one frame early still fails it", but in WebKit the settle's start frame is stamped after the animation's startTime, so the count at usePager.interaction.browser.spec.ts:181-182 includes that frame and a pager that reports one frame early still gets :moving (it passes 10 of 10 runs in WebKit and fails 10 of 10 in Chromium); either say in the description, the commit message and one line of the fixture comment that the early-report proof is Chromium's (the unit tests at usePager.test.ts:588 and :605 cover WebKit's frame order), or make the WebKit count skip the start's own frame.

The Chromium fix itself holds up: counting frames from the browser's start matches the pager's documented two-frame timing, and the whole spec file passes in both engines. The WebKit gap is not new, since the old 20 ms bar passed the same early report.

[Automated review]

The report check counted frames from the browser's own start. WebKit
stamps the frame that starts an animation at or after the start, so the
check counted that frame too, and a report one frame early passed. In
Chromium, a preempted main thread runs the frame that commits the
settle late, with a stale stamp. Chromium then dates its start a frame
later, so the report came one frame after it, and the check failed.
The check now counts from the frame that the pager counts from: in
WebKit, the frame that its start falls in, and in Chromium, the first
frame whose callbacks run after the settle is made.
@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 0210354

@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.

Approved pending CI: CI has not run on this head yet because the pull request is a draft, and it runs once the pull request is marked ready for review.

The earlier WebKit gap is fixed: the check no longer counts the settle's own start frame in WebKit, so a pager that reports one frame early now fails the callbacks case in both engines, while the shipped two-frame timing passes in both. The whole spec file also passes in Chromium and WebKit.

[Automated review]

@vjeux
vjeux marked this pull request as ready for review November 9, 2026 15:38
@cixzhang
cixzhang merged commit c28d286 into meta:main Nov 9, 2026
291 of 309 checks passed
@vjeux
vjeux deleted the bank/pager-moving-frames branch November 9, 2026 19:45

This branch was successfully deployed

1 active deployment
Preview — 02103545 Deployed Nov 9, 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