Skip to content

test(interaction-harness): a WebKit touch play that does not watch each step waits for each answer, so no gap reaches the page more than 2 ms short - #9956

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:harness/answer-pacing
Nov 4, 2026

Conversation

@vjeux

@vjeux vjeux commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

WebKit stamps an injected touch when it arrives, no later than it answers the dispatch. The paced play sent each touch its interval after the one before left, so a touch the page took late reached it 1 to 3 ms before the next. The page then read a bunched, far faster release. In 100 loaded runs of the Slider's busy proof, one read 6,493 px/s against the script's 910; its coast hit the track's end within 58 ms (BusyWindowTooLateError). #9887 fixed the same burst on WebKit's default play before the paced play existed; this carries its rule onto today's code.

Evidence

  • What reaches the page: a local probe, not part of this change, timed 360 touches of 40 paced WebKit flicks (the CI job's profile). Each was stamped before WebKit answered its dispatch; most flicks had a 1 to 3 ms gap where the script spaces 8.3.
  • Self-test, red first: a new WebKit self-test drags at 120 Hz on a page whose timer takes the main thread 6 ms in every 9. Main's pacing failed 10 of 10 runs under each pacing (gaps as short as 2 ms); this change passed 10 of 10.
  • ANSWER_SLACK_MS: on a 2-thread pin (one physical core), an idle WebKit answered 253 of 260 dispatches within 2 ms; the longest took 8.
  • Units: seven touch.pacing.test.ts cases fail on main's pacing and pass here, including a bound: with answers of 1 to 30 ms, no two stamps come more than 2 ms closer than the script.
  • test(interaction-harness): a WebKit touch driver keeps each scripted gap after a stall #9887: the same rule took the pager's slow-drag proof from failing 67 of 110 runs to passing 30 of 30.
  • Product behavior unchanged: only the harness changes.

Intended invariant

Unless it is a 'schedule' play that watches each step (onEvent), a WebKit touch play reaches the page with no gap more than 2 ms shorter than the script's: a stall stretches it instead.

Change

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

Local gates at 72503cb (browser runs and typecheck at 2c623ed, which differs only in comments and the README), on main f59ffe1: typecheck (after a fresh build), CI=true pnpm lint (no errors, and no warnings in changed files), Prettier, check:knowledge, changeset coverage (nothing ships), the harness's and Core's gesture unit tests (934), pnpm review:pre (no findings) and the full unit suites (test:ui 19,955 passed; test:node 16,448 passed). Browser runs at c4897ce, which differs from this head only in comments and the README, in WebKit in the CI job's container profile (4 CPUs, one worker): the new self-test ×10 (10 passed; main's pacing failed 10 of 10 under each pacing), and the Slider's busy proof ×20 with #9694's commit on top (20 passed). Every interaction spec that drives touch (11 files), at 2c623ed on a fresh Storybook build: 244 passed and 39 skipped in WebKit in that profile, and 275 passed and 8 skipped in Chromium.

@vercel

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

Request Review

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

astracat-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 72503cb

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 8 rows; 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

@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 pacing fix looks right, and the new unit cases fail on the old rule and pass here, but the pull request's stated claim is broader than what the change does.

  • The title and the Intended invariant say every WebKit touch play waits for each answer so no gap reaches the page short, but a play that passes onEvent keeps its scripted times (keepsGaps in touch.ts) and the bound is 2 ms (ANSWER_SLACK_MS), so please retitle along the lines of "a WebKit touch play that does not watch each step waits for each answer, so no gap reaches the page more than 2 ms short" and add the onEvent exception to the invariant, the README engine-limits row and the touch.ts header.

Separately, and not blocking: the PlayOptions.pacing doc still gives a burst after a stall as the reason to choose 'spacing', which on WebKit now only happens to plays that watch each step.

[Automated review]

Comment thread internal/interaction-harness/README.md Outdated
| ------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Trusted touch + pointer events, multi-touch | yes | yes (a `touchstart` lists only the fingers that landed in it; pointer events exact) |
| Page sees the scripted timestamps | yes, exactly | no: real dispatch time; pacing keeps velocities within ~1 ms on an idle runner, but a CPU-starved one sends some steps late, then back to back; `pacing: 'spacing'` keeps the script's spacing after a stall instead, and fails a play whose page read a resting finger where the script moves, a throw where the script rests, or fewer than two moves, or, given `releaseTolerance`, a release that strays further than that from the script's (each read as Core's velocity tracker reads it): `TouchPageStallError` when the page's own touch or pointer listeners held an event back, `TouchPacingError` otherwise; the lift's `release` names what the page read |
| Page sees the scripted timestamps | yes, exactly | no: real dispatch time; pacing keeps velocities within ~1 ms on an idle runner, after a stall each step waits for its gap, less 2 ms, from WebKit's answer to the step before, so it stretches; `pacing: 'spacing'`, too, fails a play whose page read a resting finger where the script moves, a throw where the script rests, or fewer than two moves, or, given `releaseTolerance`, a release that strays further than that from the script's (each read as Core's velocity tracker reads it): `TouchPageStallError` when the page's own touch or pointer listeners held an event back, `TouchPacingError` otherwise; the lift's `release` names what the page read |

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 row reads as if every WebKit play now waits for WebKit's answer after a stall, but a play that passes onEvent keeps its scripted times (keepsGaps in touch.ts), so it can still bunch behind a stall. Suggest adding "unless the play watches each step (onEvent)" here and in the matching touch.ts header line.

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.

Done in 72503cb: the row now says each step waits for its gap, less 2 ms, after WebKit's answer "unless a 'schedule' play has onEvent". A 'spacing' play waits even when it watches each step.

Comment on lines +27 to +29
* ~1 ms on an idle runner; after a slow dispatch each step waits for its
* gap, less 2 ms, after WebKit answered the step before, so a stall
* stretches the gesture instead of bunching it);

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.

Same gap as the README row: keepsGaps is false for a play with onEvent (line 558), so such a play does not wait for the answer and a stall can still bunch it. The TouchPacing doc below states the exception; this header (kept in sync with the README) should too.

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.

Done in 72503cb: the header names the same exception ("unless a 'schedule' play watches each step, onEvent").

…ch step waits for each answer, so no gap reaches the page more than 2 ms short

WebKit stamps a touch when it arrives, no later than it answers the
dispatch. A paced play sent the next touch its interval after the one
before left. So a touch the page took late, then answered quickly, could
reach the page 1 to 3 ms before the next one, and the page read a
bunched, far faster release.

Each touch now also waits for its interval, less 2 ms, after WebKit
answered the one before: under `pacing: 'spacing'`, and on a WebKit
`'schedule'` play that does not watch each step (`onEvent`), which keeps
its scripted times. No other gap reaches the page more than 2 ms short of
the script's. A stall stretches the gesture, and a
slow runner reads a slower release. This is meta#9887's rule, carried onto the
paced play.
@vjeux
vjeux force-pushed the harness/answer-pacing branch from 2c623ed to 72503cb Compare November 4, 2026 14:25
@vjeux vjeux changed the title test(interaction-harness): a WebKit touch play waits for each answer, so no gap reaches the page short test(interaction-harness): a WebKit touch play that does not watch each step waits for each answer, so no gap reaches the page more than 2 ms short Nov 4, 2026
@vjeux

vjeux commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Retitled, and the invariant now names the exception: a 'schedule' play that watches each step keeps its scripted times. A 'spacing' play waits for each answer either way, so the bound holds for it. The PlayOptions.pacing doc no longer gives a burst as the reason to pick 'spacing'; it says 'spacing' keeps each gap from the event before, even in a play that watches each step.

@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. The new pacing rule bounds each page gap as the retitled description and invariant now say, and the seven new unit cases fail on the old rule and pass here. CI starts once the pull request is marked ready for review and, since the branch lives in a fork, a maintainer adds the ci:run label.

[Automated review]

@vjeux
vjeux marked this pull request as ready for review November 4, 2026 14:48
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 4, 2026
@cixzhang
cixzhang marked this pull request as draft November 4, 2026 15:03
@cixzhang
cixzhang marked this pull request as ready for review November 4, 2026 15:03
@cixzhang
cixzhang merged commit ffa495b into meta:main Nov 4, 2026
159 of 164 checks passed
@vjeux
vjeux deleted the harness/answer-pacing branch November 5, 2026 00:01

This branch was successfully deployed

1 active deployment
Preview — 72503cba Deployed Nov 4, 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