Repository navigation
fix(core): the animator rechecks a finished animation's end in frame callbacks from a frame before it - #9285
Conversation
15c5e8b to
e7b7445
Compare
|
Addressed in e7b7445: the title, changeset and description now describe the frame-callback recheck that a timer starts a frame before the curve's end, and say that a timer running more than a frame late can still leave the animation on for that frame; "keeping it promoted" is gone from the description. The non-blocking note on |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Types · interface FieldStatusProps |
message: string |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {message: …} |
| + | core |
. · Types · interface FieldStatusProps |
ref?: React.Ref<HTMLDivElement> |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {ref: …} |
| + | core |
. · Types · interface FieldStatusProps |
type: InputStatusType |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {type: …} |
| + | core |
. · Types · interface FieldStatusProps |
variant?: FieldStatusVariant = 'attached' |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {variant: …} |
| + | core |
. · Types · interface FieldStatusProps |
xstyle?: StyleXStyles |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {xstyle: …} |
| + | core |
. · Types · interface FieldStatusProps |
inherits AriaAttributes, DOMAttributes, HTMLAttributes |
import type {FieldStatusProps} from '@astryxdesign/core' |
| + | 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 |
. · Components · component ComplexSelector |
prop statusVariant?: FieldStatusVariant = 'attached' for input selectors; 'detached' for secondary and ghost selectors → prop statusVariant?: FieldStatusPlacement = 'attached' for input selectors; 'detached' for secondary and ghost selectors |
<ComplexSelector statusVariant="attached" /> |
| ~ | core |
. · Components · component DateInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<DateInput statusVariant="attached" /> |
| ~ | core |
. · Components · component DateRangeInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<DateRangeInput statusVariant="attached" /> |
| ~ | core |
. · Components · component Field |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<Field statusVariant="attached" /> |
| ~ | core |
. · Components · component FieldStatus |
component FieldStatus(props: FieldStatusProps) → component FieldStatus @deprecated |
<FieldStatus /> |
| ~ | core |
. · Components · component FieldStatus |
prop variant?: FieldStatusVariant = 'attached' → prop variant: FieldStatusVariant = 'attached' |
<FieldStatus variant="attached" /> |
| ~ | core |
. · Components · component FileInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<FileInput statusVariant="attached" /> |
| ~ | core |
. · Components · component MultiSelector |
prop statusVariant?: FieldStatusVariant = 'attached' for input selectors; 'detached' for secondary and ghost selectors → prop statusVariant?: FieldStatusPlacement = 'attached' for input selectors; 'detached' for secondary and ghost selectors |
<MultiSelector statusVariant="attached" /> |
| ~ | core |
. · Components · component NumberInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<NumberInput statusVariant="attached" /> |
| ~ | core |
. · Components · component PowerSearch |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<PowerSearch statusVariant="attached" /> |
| ~ | core |
. · Components · component Selector |
prop statusVariant?: FieldStatusVariant = 'attached' for input selectors; 'detached' for secondary/ghost selectors → prop statusVariant?: FieldStatusPlacement = 'attached' for input selectors; 'detached' for secondary/ghost selectors |
<Selector statusVariant="attached" /> |
| ~ | core |
. · Components · component TextArea |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<TextArea statusVariant="attached" /> |
| ~ | core |
. · Components · component TextInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<TextInput statusVariant="attached" /> |
| ~ | core |
. · Components · component TimeInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<TimeInput statusVariant="attached" /> |
| ~ | core |
. · Components · component Tokenizer |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<Tokenizer statusVariant="attached" /> |
| ~ | core |
. · Components · component Typeahead |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<Typeahead statusVariant="attached" /> |
| ~ | core |
. · Types · interface FieldStatusProps |
interface FieldStatusProps extends BaseProps<HTMLDivElement> (props of FieldStatus) → interface FieldStatusProps extends BaseProps<HTMLDivElement> |
import type {FieldStatusProps} from '@astryxdesign/core' |
| ~ | core |
. · Types · interface FieldStatusVariantMap |
tooltip: true → tooltip: true @deprecated |
import type {FieldStatusVariantMap} from '@astryxdesign/core'; const x: FieldStatusVariantMap = {tooltip: …} |
| ~ | 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: …} |
| ~ | core |
. · Types · interface UseInputStatusIconOptions |
statusVariant?: FieldStatusVariant → statusVariant?: FieldStatusPlacement |
import type {UseInputStatusIconOptions} from '@astryxdesign/core'; const x: UseInputStatusIconOptions = {statusVariant: …} |
| ~ | richtext |
. · Components · component RichTextEditor |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusVariant | 'tooltip' = 'attached' |
<RichTextEditor statusVariant="tooltip" /> |
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
There was a problem hiding this comment.
Requesting changes for wording only; the code fix looks sound, and its updated unit case fails on the base animator and passes here. The title and changeset say a finished animation retires "in the first frame that reaches its curve's end", but the frame looks are started by a timer one frame early, so a timer that runs more than a frame late still leaves the animation on for that frame (the browser proof also allows one such frame). Please reword them to describe the frame-callback recheck that starts a frame before the end, and drop "keeping it promoted" from the description, since will-change stays for 500 ms past the curve either way.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [chore] Internal: the touch presentations' animator retires a finished animation in the first frame that reaches its curve's end, looking in frame callbacks from a frame before it, instead of on a timer that a loaded page can run a frame or two late. The timers remain for a page that draws no frames. Not exported from the package entry point. |
There was a problem hiding this comment.
"In the first frame that reaches its curve's end" is stronger than the mechanism. The frame looks start from the retireLooks timer one frame before the end (animator.ts:1467-1476), so a timer that runs more than a frame late still lets that frame paint with the animation on. The browser proof also accepts one present frame. Suggested: "…retires a finished animation from frame callbacks that start a frame before its curve's end, instead of re-arming a timer when its time reads a fraction short…".
| // past its curve. The timers stay, for a page that draws no frames (a | ||
| // hidden tab). | ||
| const lookAtFrame = () => { | ||
| if (requestFrame == null || retireFrames.has(channel)) { |
There was a problem hiding this comment.
Non-blocking: retireFrames is keyed by channel, and neither rebuild nor scheduleRetire clears it. A look still pending from a replaced animation makes the new animation's first look return here, and that pending callback then exits at the running.get(channel) !== animation check. It only matters for a new curve that ends within about a frame of a retarget, which falls back to the timer, but keying the pending set by animation would close it.
There was a problem hiding this comment.
Requesting changes: the frame-callback recheck works in the common case, and the updated unit case fails on the base animator and passes here, but the chain of frame looks stops after one look whenever that look's frame is dated before the look timer was due, because retire(true) then reads more than END_RECHECK_MS left and requests no further frame (animator.ts:1414). In that case a slightly late end timer again decides the end frame, as on the base.
- Let a frame callback keep looking while up to two frames are left, for example
remaining <= (atFrame ? 2 : 1) * END_RECHECK_MS. - Add a unit case where the end timer runs after the frame that reaches the end: deleting the early look timer currently leaves the whole animator suite green.
- Qualify the changeset's "so the frame that reaches the curve's end drops the animation before it paints" for a timer that starts the looks more than a frame late.
[Automated review]
| ), | ||
| ); | ||
| const paused = animation.playState === 'paused'; | ||
| if (!paused && remaining <= END_RECHECK_MS) { |
There was a problem hiding this comment.
From a frame callback this gate ends the chain when the frame is dated before the look timer's due time (a frame already in flight, or the timer firing early because setTimeout truncates its fractional delay): the first look reads a little more than END_RECHECK_MS left and requests nothing, so the end frame falls back to the end timer. With the frame dated 3 ms early and the end timer 14 ms late, the animation is still on in the frame that reaches the end, as on the base. Widening it in the frame path, e.g. remaining <= (atFrame ? 2 : 1) * END_RECHECK_MS, fixes that and keeps the animator suite green.
| flushReleases(); | ||
| }; | ||
| retireTimers.set(channel, setTimeout(retire, Math.max(0, end - now()))); | ||
| if (requestFrame != null) { |
There was a problem hiding this comment.
Nothing tests this early look timer: deleting this block still passes all 196 animator unit cases, and the browser proof allows the end frame. A case where the end timer runs after the frame that reaches the end fails on the base and without this block, and passes here; please add it.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [chore] Internal: the touch presentations' animator rechecks a finished animation's end in frame callbacks, starting a frame before it, instead of only on timers that a loaded page can run a frame or two late, so the frame that reaches the curve's end drops the animation before it paints. The timers remain for a page that draws no frames. Not exported from the package entry point. |
There was a problem hiding this comment.
"So the frame that reaches the curve's end drops the animation before it paints" holds only when the timer that starts the looks runs less than a frame late, which this same sentence says a loaded page does not guarantee. Suggested ending: "…drops the animation before it paints, unless the timer that starts the looks runs more than a frame late."
…callbacks from a frame before it The animator drops a finished animation, writing its end value inline, when a timer at the curve's end finds the animation's own time there. The animation's time moves only at frames, so under load the timer could land between two frames, find the time a fraction short, and look again a frame later: the animation stayed on the element for one or two frames past its curve (the retire proof failed 7 of 120 runs in Chromium pinned to 2 cores at 4 workers). Now a timer a frame before the end starts a recheck in frame callbacks, which keeps looking while up to two frames remain (the frame it runs in can be dated before that timer was due), and the first frame callback whose time reaches the end drops the animation before that frame paints; only a timer running more than a frame late can still leave it on for one frame. The timers stay as the fallback for a page that draws no frames.
e7b7445 to
4b346ad
Compare
|
Addressed in 4b346ad:
|
There was a problem hiding this comment.
Recommending approval: a look from a frame callback now keeps going while up to two frames remain, and the new unit case fails on the earlier animator, without the early look timer, and with the one-frame gate, so each part of the fix is protected. One non-blocking follow-up remains, as you noted: retireFrames is keyed by channel, so a look still pending from a replaced animation can swallow the next animation's first look, and keying the pending looks by animation would close it.
[Automated review]
User impact
This is a product-side timing change in the touch presentations' animator, not a test change. When a motion ends, the animator drops its animation and writes the end value inline. That drop ran on a timer at the curve's end; the animation's own time moves only at frames, so under load the timer could land between two frames, find the time a fraction short, and look again a frame later. The animation then stayed on the element for one or two frames past its curve. The animator is internal and not yet used by a shipped component, so no consumer sees it today; every touch component built on it would.
Problem and solution fit
Expected behavior and authority
The animator's retire contract: a finished animation leaves the element once the curve ends, with its end value inline (the animator's header, "retiring"). The proof "a finished animation leaves the element once the curve ends" requires it gone by the second frame at or after the end.
Smallest restoration
Within the animator's
scheduleRetire: a look in the next frame callback when the time is short of the end by less than a frame (by less than two frames from a look already in a frame callback), and a timer a frame early that starts those looks. The timers, their constants and every other path are unchanged; dispose clears the new timer and looks with the others.Evidence
Status at this head: every gate has finished. Build, type check, lint,
check:knowledge,check:changesets,test:ui(17,393) andcheck:repopass; the node suites fail only the twocache.test.mjslock cases that fail on main. The animator spec passes in Chromium pinned to 2 cores at 1 worker ×3 (51) and under the CI WebKit job's command ×10 (130, with 40 Chromium-only skips). Under that command at 4 workers, a load CI does not run, the proof fails 4 of 200 runs (main 13 of 200): in each, the timer that starts the frame looks ran more than 20 ms late, after the first frame past the end had begun.Scope
Testing
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=4and 1 worker.