Skip to content

fix(core): a retarget before Chromium reports a call's start continues from the screen - #9255

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/f1-animator-start-at-commit-frame
Nov 1, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/f1-animator-start-at-commit-frame

Conversation

@vjeux

@vjeux vjeux commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Core's touch animator (internal, and not yet driving a shipped component) lost its place in Chromium when a motion it started from rest was retargeted or rebased right after the start: it replayed the curve from its beginning while the screen had moved on, so the element stepped back for a frame before going on (61 px in the proof below). A retarget must continue from what the screen shows (spec:AST-094 FR6), so every touch component built on the animator would show that jump at the moment the user acts.

Problem and solution fit

  • Why it steps back. A call from rest has no start time until the browser commits it. Chromium's compositor starts a composited animation at the frame that commits it, but tells the page that start a frame or more later, longer under load. In that window the animator read the call as not started, so a retarget or a rebase replayed the curve from its start.
  • Why it matters. FR6's catch-and-retarget is the basis of every interruptible touch motion.
  • The fix. A call made in a task, still waiting in the first frame after it, starts at the time that frame runs, and that start is set on its animations, so the compositor takes the same one. The frame's timestamp would not do: after a block it is the frame time from before the block.
  • Where it does not apply. A call made in an animation-frame callback was committed by that frame, so the frame after it is not the one that starts it; and after a block between the call and its first frame (more than LATE_START_MS, the animator's existing measure of a block), that frame cannot tell a call made in a task from one a page's own frame callback made. Both keep the browser's start, as before.

Expected behavior and authority

spec:AST-094 FR6: a retarget continues from the current value and velocity. Its verification row gains this state ("a retarget before the browser reports the call's start"), the test below being its evidence.

Smallest restoration

One condition in the first-frame callback of a call from rest (motion/animator.ts), plus a count of the animator's own frame callbacks so a call made in one is known. The requestFrame option, the animator's API and every other path are unchanged.

Evidence

  • Reproduction before the change (main): "a retarget made before the page can read a call's start begins where the screen shows the element (spec:AST-094 FR6)", a Chromium screencast proof, fails 5 of 5: the box steps back to 0 px, held 0 against at least 60. Three new unit cases fail on main.
  • Result after the change: the proof and the unit cases pass.
  • The paths it must leave alone: "a call made in an animation-frame callback, whose next frame a busy task delays, keeps the start its own frame gave it: the screen never steps back", once from a page's own frame callback and once presented. Without the two limits it failed 2 of 20 in Chromium pinned to 2 cores (the element jumped back), and two new unit cases failed; with them it passes 20 of 20, as on main.

Status at this head: every gate has finished; the tree is identical to 272366d, where they ran. Build, type check, CI-strict lint, check:knowledge, check:changesets, test:ui (17,185) and check:repo pass; the node suites fail only the two cache.test.mjs lock cases that fail on main. The animator's browser spec passes ×10 in Chromium pinned to 2 cores at 1 worker (170), ×10 under the CI WebKit job's command with LP_NUM_THREADS=4 (130, with 40 Chromium-only skips), and once at 3 CPUs with 1 and 16 workers (13 each, 4 skips).

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm exec vitest run --project ui packages/core/src/motion/animator.test.ts
pnpm test:interaction packages/core/src/motion/__tests__/animator.interaction.browser.spec.ts --project chromium --workers=1

For WebKit, use the CI WebKit job's container command (internal/interaction-harness/scripts/webkit-container.mjs) with podman --cpus=4, CI=1, LP_NUM_THREADS=4 and 1 worker.

Writing rubric results

The record touched is spec:AST-094, with one representative state added to its FR6 verification row.

  • R1 narration: none found (no proposes, we decided, previously, a port of); the added state is present tense.
  • R2 research: none in the record; none added.
  • R3 evidence: the added state names the case, not a change.
  • R4 rejected alternatives: 14, each one line inside its decision; none added.
  • R5 change references: none (no # followed by digits, /pull/ or /issues/).
  • R6 open questions: OQ6 and OQ8 are resolved and list no options; the rest are unanswered; none touched.

@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 4:42am 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, 4:52 AM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 5e8517e

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/core 6.56 MB packed (+1.1 kB); no new dependencies.

API changes: core +2 · ~1 · −0 (report stale: run pnpm api:report)

3 API changes (advisory)
Package Where Signature Usage
+ core . · Types · interface SearchContext interface SearchContext<T extends SearchableItem = SearchableItem> import type {SearchContext} from '@astryxdesign/core'
+ core ./Typeahead · Also exported from an earlier entry point · SearchContext SearchContext (.) import {SearchContext} from '@astryxdesign/core/Typeahead'
~ core . · Types · interface SearchSource search: (query: string) => Promise<T[]> | T[] → search: (query: string, context?: SearchContext<T>) => Promise<T[]> | T[] import type {SearchSource} from '@astryxdesign/core'; const x: SearchSource = {search: …}

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 fix works for the case it targets (the new Chromium proof fails on main and passes here), but it adds a jump on a neighbouring path, and the release note overstates the impact.

  • A call created inside an animation-frame callback, whether a plain animate() from requestAnimationFrame or start: 'presented', is already committed when its first frame callback runs a frame later, so after a busy task the new branch dates it after the block and the element jumps back about 120 px in Chromium (3 of 10 runs each, none on main); please limit the first-frame start to calls created before that frame and cover the callback case in the unit harness and the proof.
  • No component uses the animator yet and it is not exported, so the changeset's Switch example describes a change consumers cannot see; please word it as an internal animator change, like .changeset/uikit-motion-animator-pseudo-element.md.

[Automated review]

Comment on lines +1955 to +1962
if (
!group.resolved &&
group.animations.some(
animation =>
animation.startTime == null && animation.playState === 'running',
)
) {
resolveGroup(group, now());

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 assumes the first frame callback runs in the frame that commits the animations. For a call created inside a frame callback (the start: 'presented' path through flushDeferredThrough, or a caller's own requestAnimationFrame), the browser commits it in that same frame and this callback runs one frame later. When a busy task delays that frame, Chromium has still not reported the start, so the call is dated after the block and the element jumps back to its start: about 120 px in 3 of 10 Chromium runs each for a plain animate() and for presented, and in none on main. Could this branch apply only to calls created before this frame, and leave the browser's start alone otherwise?

* `startUnread`, the frame's callbacks run before the page can read those
* starts, as in Chromium, whose compositor starts a composited animation at
* the frame that commits it and tells the page that start a frame or more
* later (`noticeStarts`).

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.

Nothing named noticeStarts exists in the repository at this head; point to the startUnread option instead.

@vjeux
vjeux force-pushed the uikit/f1-animator-start-at-commit-frame branch from dda4a38 to 272366d Compare November 1, 2026 03:57
@vjeux

vjeux commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in 272366d:

  • The first-frame start now applies only to a call made in a task whose first frame came within LATE_START_MS of it. A call made in a frame callback (an animator's own, which covers start: 'presented') keeps the browser's start, and so does one whose first frame comes after a block: at that frame a call made in a page's own frame callback looks the same as a task's (both play-pending with a null start). New browser case, once from a page frame callback and once presented, with a busy task delaying the next frame: it failed 2 of 20 on dda4a38 and passes 20 of 20 now, as on main. Two unit cases cover both limits and failed on dda4a38.
  • The changeset is now an internal [chore] note.
  • The test harness comment points to the startUnread option.

@vjeux
vjeux force-pushed the uikit/f1-animator-start-at-commit-frame branch from 272366d to e3128e2 Compare November 1, 2026 04:03
@cixzhang

cixzhang commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

/approve-spec e3128e2

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 1, 2026

@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 animator fix itself checks out (the new Chromium proof fails on main and passes here, and calls made in a frame callback keep the browser's start as before), but the changeset again announces a Switch fix. No component uses the animator yet and it is not exported, so please restore the internal [chore] wording from your previous revision, in the style of .changeset/uikit-motion-animator-pseudo-element.md.

[Automated review]

…s from the screen

A call from rest has no start time until the browser commits it. Chromium's
compositor starts a composited animation at the frame that commits it, but
tells the page that start a frame or more later, longer under load. In that
window the animator read the call as not started, so a retarget or a rebase
replayed the curve from its start while the screen had moved on: the box
stepped back 61 px in one frame (spec:AST-094 FR6). In the frame that
commits a call still waiting for its start, the animator now starts it at
that frame, the start the compositor takes. Only a call made in a task
whose first frame is the one that commits it: a call made in a frame
callback was committed by that frame, and after a block before the first
frame the two cannot be told apart, so both keep the browser's start.
@vjeux
vjeux force-pushed the uikit/f1-animator-start-at-commit-frame branch from e3128e2 to 5e8517e Compare November 1, 2026 04:34
@vjeux

vjeux commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Restored in 5e8517e: the changeset is the internal [chore] note again. The tree is identical to 272366d, and the user-facing wording moves to the pull request that adopts the animator in a component.

@cixzhang

cixzhang commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 5e8517e

@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 04:46

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

This looks ready to approve: the new Chromium proof steps back from 61 px to 0 px on main and never on this branch, and calls made in a frame callback, plain or start: 'presented', keep the browser's start as before. The changeset is the internal note again, and the FR6 verification-row addition carries an engineering owner's approval for this head, so nothing else is needed from you.

[Automated review]

@cixzhang
cixzhang merged commit d29d841 into meta:main Nov 1, 2026
89 checks passed
@vjeux
vjeux deleted the uikit/f1-animator-start-at-commit-frame branch November 1, 2026 05:08

This branch was successfully deployed

1 active deployment
Preview — 5e8517e9 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