Skip to content

fix(motion): a call on a settle tail starts at the browser's commit - #9733

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/f1-animator-settle-tail-start
Nov 3, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/f1-animator-settle-tail-start

Conversation

@vjeux

@vjeux vjeux commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

User impact

On a busy page, a Switch tapped back just after its thumb settles jumps up to about 14 px as its return starts. Any motion retargeted as it settles skips its first frames the same way.

Problem and solution fit

  • Why it occurs: a call that continues motion starts at its own time. On a starved main thread the browser commits it 50–100 ms later, so the new curve shows that far in.
  • Why it harms the task: a tail that already looks still has nothing to continue, so the step is pure skip.
  • Why that matters: tapping back right after a toggle is common, and the jump reads as a glitch.
  • The fix: a curve within two sample tolerances of its target and slower than one a frame at 60 Hz (0.5 px and 15 px/s for a position) shows as at rest. A call on it starts at the browser's start, from the value and velocity on screen.

Expected behavior and authority

spec:AST-094 FR6: a caught animation's "value and its velocity MUST come from the curve". FR6 now also states the owner's decision for curves that still move: "On a starved page, a retarget may skip ahead by up to the browser's commit delay (start-at-call)."

Smallest restoration

One condition, showsAtRest, in the animator's continuing-motion test, with its two constants and the docs that describe the start. A call on a moving curve starts at the call, as before.

Evidence

  • Reproduction before the change: on main, a call inside x 0→300's tail starts at the call ("expected 1691 to be null"), so an 80 ms late commit draws the new curve 80 ms in.
  • Result after the change: the call waits for the browser's start, and its first frame shows the call's value.
  • Representative unchanged path: a call at 1100, while the curve still moves, starts at 1100.
  • Regression test or other mutation-sensitive proof: "a call on a settle tail starts at the commit too…" fails on main and passes here.

Writing rubric results

spec:AST-094, FR6's added sentence and its new verification row:

R1 narration: none; both state the system in the present tense.
R2 research: none.
R3 evidence: no cell names a pull request, issue or commit.
R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: none answered or added.

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

On this head, on main aa55b7a: pnpm install --frozen-lockfile, build, type check, test:ui (19,013), the node suites (16,082, with 2 expected failures), check:repo, ASTRYX_STRICT_LINT=1 pnpm lint (0 errors), check:changesets, changeset coverage, check:knowledge and pnpm review:pre pass. On a fresh Storybook build, the Switch accessibility contract passes (12 of 12). The public and internal animators' browser specs, with the Switch and SegmentedControl interaction specs, pass in Chromium pinned to 2 cores at 1 worker (122 of 122) and under the CI WebKit job's command (104 passed; 18 skip by their own engine conditions). At 0f12f49, which has this head's code, the animators' browser specs also passed ×3 in both engines.

Switch's frame proofs (P10, P14 and the late first frame) at 4 workers on 2 pinned cores, ×10 per run, four runs per arm in the order A B B A B A A B (A = main aa55b7a, B = this change, each arm on its own install and Storybook build): a step out of a thumb held still at its end (38 px for two to four frames, then a 4–11 px jump) shows 8 times on main (per run 2, 4, 1, 1) and once here (0, 0, 1, 0). Steps in mid-travel, the Known limit, stay within this setup's run-to-run noise (28 on main, 35 here; per run 3–11 and 6–13), as do P10's compositor reds (75 and 69) and the late first frame (11 and 11), so the total red count does not fall at this load.

@vercel

vercel Bot commented Nov 3, 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 3, 2026 11:39am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 11:50 AM UTC

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

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · ad5ae03

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC
Slider 88.9 kB (+76 B) · 9.4 kB CSS (0) —
Switch 87.1 kB (+69 B) · 10.5 kB CSS (0) —
SegmentedControl 81.9 kB (+65 B) · 7.8 kB CSS (0) —
5 more components
Component Size LoC
lab/MobilePowerSearch 214.0 kB (+46 B) · 1.2 kB CSS (0) —
DateTimeInput 158.8 kB (+5 B) · 17.0 kB CSS (0) —
TimeInput 90.1 kB (+2 B) · 14.3 kB CSS (0) —
DateInput 103.3 kB (0) · 15.3 kB CSS (0) —
PowerSearch 184.5 kB (0) · 20.6 kB CSS (0) —

Package size: @astryxdesign/core 6.09 MB packed (+720 B); 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.

Requesting changes for one documentation update; the start-time change itself looks right, and its regression test fails on main and passes here.

  • The animator's header (animator.ts line 67), the start option's JSDoc (lines 246–258, including 'presented'), beginGroup's JSDoc and comment (lines 2061–2063 and 2098–2101) and the motion README's start bullet still say a retarget always starts at the call, so please state there that a curve whose tail shows as at rest counts as rest and takes the browser's start (and, under 'presented', waits its two frames).

Two optional touch-ups: the comment on REST_FRAMES_PER_SECOND could name its subject and say "at most" to match the <= check, and the changeset's "5–10 px" understates the Switch's 22 px return, which skips about 6, 11 and 14 px at 50, 80 and 100 ms late commits.

[Automated review]

segment.group.resolved ||
shownSince(property, segment) != null)
shownSince(property, segment) != null) &&
!showsAtRest(property, segment, time)

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.

With this clause a retarget on an at-rest tail takes the browser's start, but the file header (line 67), the start option's JSDoc (lines 246–258, including the 'presented' bullet), beginGroup's JSDoc and the comment above this loop (lines 2061–2063, 2098–2101), and the motion README's start bullet still say a retarget always starts at the call. Under start: 'presented' such a call now also waits its two frames. Please update those places to say a curve that shows as at rest counts as rest.

Comment thread packages/core/src/motion/animator.ts Outdated
*/
const REST_DISTANCE_TOLERANCES = 2;

/** It must also move less than one sample tolerance a frame at this rate. */

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.

Optional wording: "It" has no referent here, the check below accepts equality (<=), and "sample tolerance" can read as the device-pixel tolerance SAMPLE_TOLERANCE's doc describes. Suggested: /** A curve shows as at rest only while it moves at most one SAMPLE_TOLERANCE (CSS px) a frame at this rate. */

'@astryxdesign/core': patch
---

[fix] Motion: a call made while an animation settles, with the element already still on screen, waits for the browser's first frame as a call from rest does. A busy page no longer skips the start of the new motion, a 5–10 px jump at a Switch's return.

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.

Optional: the Switch's 22 px return on its 0.3 s spring skips about 6, 11 and 14 px at 50, 80 and 100 ms late commits, so "a jump of up to about 14 px" fits better than "5–10 px".

@vjeux
vjeux force-pushed the uikit/f1-animator-settle-tail-start branch from 0f12f49 to 2dc14bc Compare November 3, 2026 10:43
@vjeux

vjeux commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated in 2dc14bc: the start option's docs, beginGroup's notes and the motion README now say that a curve whose tail already shows as at rest counts as rest, so a call on it takes the browser's start, and under 'presented' waits its two frames. REST_FRAMES_PER_SECOND names its subject and says "at most", and the changeset says "up to about 14 px". The file header is unchanged: its sentence is about "a call that continues motion on screen", and a tail that already shows as at rest is not motion on screen. The browser A/B is in the Testing section.

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

Approval recommended: a retarget on a tail that already shows as at rest now waits for the browser's commit, the new regression tests fail on main and pass here, and a Chromium run of the Switch tap-back with a 100 ms block shows the return no longer skipping into its curve.

Two optional touch-ups:

  • The file header of animator.ts (lines 56–75) still says every retarget keeps a call-time start; the start option's sentence "A curve whose tail already shows as at rest counts as rest." would keep it in step.
  • The changeset's "up to about 14 px" assumes UIKit's 22 px travel; the md Switch travels 16 px, so a 50–100 ms late commit skips about 4–10 px, and "up to about 10 px" fits better than the earlier 14 px suggestion.

[Automated review]

'@astryxdesign/core': patch
---

[fix] Motion: a call made while an animation settles, with the element already still on screen, waits for the browser's first frame as a call from rest does. A busy page no longer skips the start of the new motion, a jump of up to about 14 px at a Switch's return.

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.

Optional: "up to about 14 px" assumes UIKit's 22 px travel (63 × 28 track). The md Switch (40 × 24) travels 16 px, so a 50–100 ms late commit skips about 4–10 px (a 100 ms block measured 9.9 px in Chromium); "a jump of up to about 10 px" fits better.

A call that continues motion starts at its own time, from the value and
velocity on screen. Under a starved main thread the browser commits it
50-100 ms later and draws the new curve that far into itself, while it
drew the old curve until then. For a curve that still moves, that step
is the least of the two choices. For one whose tail already shows as at
rest, the step is the new curve's first frames, 5-10 px for a Switch's
return.

A curve within two sample tolerances of its target, moving less than one
tolerance a frame at 60 Hz, now shows as at rest, so a call on it starts
at the browser's start, as a call from rest does, and its first frame
shows its first keyframe. A call while the curve still moves starts at
the call, as before. The frame-look case that retargeted inside the old
curve's last frame now commits that start first. The start option's
docs, the notes on starting from rest and the motion README say so.

spec:AST-094 FR6 records the owner's decision for a curve that still
moves: on a starved page, a retarget may skip ahead by up to the
browser's commit delay. A verification row names the starvation probe.
@vjeux
vjeux force-pushed the uikit/f1-animator-settle-tail-start branch from 2dc14bc to ad5ae03 Compare November 3, 2026 11:26
@vjeux

vjeux commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated in ad5ae03: spec:AST-094 FR6 now states the owner's decision for a curve that still moves, "On a starved page, a retarget may skip ahead by up to the browser's commit delay (start-at-call)", and a new verification row names the starvation probe. No code changed.

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

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec ad5ae03

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 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.

Approval recommended: a retarget on a tail that already looks still now waits for the browser's commit, the new regression tests fail on main and pass here, and the spec:AST-094 FR6 amendment has an engineering owner's approval for this head.

Optional touch-ups, left inline: the changeset's "up to about 14 px" fits a commit about 170 ms late (about 10 px matches the 50–100 ms delays the description names), the new FR6 sentence reads as part of the paging paragraph, and the first sentence of the showsAtRest JSDoc restates its name. The animator.ts header (lines 56–57 and 74–75) also still defines rest without the at-rest tail.

[Automated review]

'@astryxdesign/core': patch
---

[fix] Motion: a call made while an animation settles, with the element already still on screen, waits for the browser's first frame as a call from rest does. A busy page no longer skips the start of the new motion, a jump of up to about 14 px at a Switch's return.

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.

Optional: the md Switch travels 16 px on its 0.3 s critically damped spring, so a commit 50–100 ms late skips about 4.5–9.9 px; 14 px needs a commit about 170 ms late. "a jump of up to about 10 px" matches the description's 50–100 ms.

(UIKit zeroes steady releases at 175 and 200 pt/s and keeps 249 pt/s, iOS
26.2 simulator, 2026-10-23) until a measurement replaces it (FR2). A page
change during a drag starts from rest (DEC-25).
change during a drag starts from rest (DEC-25). On a starved page, a

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.

Optional: this sentence follows the DEC-25 pager sentence, and DEC-25 narrows FR6 "for paging only", so it can read as a paging rule. Starting it on its own line, or before the pager text, makes plain that it covers every retarget.

};

/**
* Whether a curve's tail already shows as at rest at `time`. Under a

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.

Optional (comment style): the first sentence restates the name. Keeping only the reason reads: "Under a starved main thread the browser commits a call late. A call that starts at its own time then skips that far into its curve. One that starts at the commit holds an element that hardly moves."

@vjeux
vjeux marked this pull request as ready for review November 3, 2026 13:22
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 3, 2026
@cixzhang
cixzhang marked this pull request as draft November 3, 2026 13:44
@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 13:44
@cixzhang
cixzhang merged commit 49ac70d into meta:main Nov 3, 2026
151 of 156 checks passed
@vjeux
vjeux deleted the uikit/f1-animator-settle-tail-start branch November 3, 2026 14:28

This branch was successfully deployed

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