Repository navigation
fix(core): a retarget after a late first frame continues from the screen - #9401
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Changes requested: the late-first-frame bound fixes the direct retarget, but a rebase() or set() in the same window keeps latest on the rebuilt animation's group, so get() and the next retarget read ahead of the screen. In a unit fixture (first frame at 1070 ms with the start unread, then rebase({x: -16}) at 1170 ms), the rebuilt animation starts at 91.3 px while get('x') reads 204.3 px, and a retarget one frame later starts at 217.0 px. Please clear latest when commit adds a pending animation to a waiting group outside that group's own call, re-arm it from the rebuilt animation's first frame, and add a unit case for a rebase after a late first frame.
[Automated review]
| const latest = segment.group?.latest; | ||
| if (latest == null || time <= latest) { | ||
| return segment.at(0); | ||
| } | ||
| return time - latest >= segment.duration | ||
| ? segment.target | ||
| : segment.at(time - latest); |
There was a problem hiding this comment.
After a late first frame, a rebase() (or a set() on the other axis) rebuilds the channel as a new pending animation in this same group, but latest still dates the cancelled animation's first frame. This then reads the rebuilt curve, which already starts at the value at the rebase, time - latest in. In a unit fixture (first frame at 1070 ms, rebase({x: -16}) at 1170 ms), the rebuilt animation starts at 91.3 px while get('x') reads 204.3 px, and a retarget one frame later starts at 217.0 px. Clearing latest when commit adds a pending animation to a waiting group outside its own call, and re-arming it from that animation's first frame, would keep reads on the screen.
f63753a to
4d01619
Compare
|
Fixed in 4d01619: when While checking this, I measured Chromium's reported start against the recorded time. It is near the compositor's start, not exact, so I reworded the comments and the changeset that called it the latest possible start. The PR body's Known limit gives the numbers. |
There was a problem hiding this comment.
Changes requested: the late-first-frame read and the same-channel rebuild path now hold, but latest is one value per call while rebuild replaces only one channel's animation. In a call that moves translate and opacity, a rebase({x: -16}) or set({y: 10}) after a late first frame clears latest for both (packages/core/src/motion/animator.ts:1464), so get('opacity') drops from 0.642 (0.643 on screen) to 1.0, reads 0.982 a frame later while 0.507 is on screen, and an opacity retarget there jumps back. Please keep the recorded time per channel, clear and re-arm only the rebuilt channel, and add a unit case for a two-channel call with a rebase of translate.
[Automated review]
| // frame that commits it, from its first keyframe, not where the old | ||
| // one had got to. Reads take its first value until that frame, which | ||
| // dates its start again. | ||
| waiting.latest = undefined; |
There was a problem hiding this comment.
This clears the recorded time for every channel of the call, but rebuild replaces only channel's animation. In an {x: 300, opacity: 0} call with a late first frame, rebase({x: -16}) here makes get('opacity') read 1.0, then 0.982 after the next frame, while the untouched opacity animation shows 0.643, then 0.507, so an opacity retarget jumps back. Keeping latest per channel, cleared and re-armed only for channel, keeps the other channels' reads.
|
Fixed in ae3c1dc: the recorded time is kept per channel. The first frame records it for each moving channel of the call. A rebuild outside the call clears and re-arms only the rebuilt channel's, and A read of a later time now takes the curve from the recorded time too, as the velocity already did: at 1170, |
4d01619 to
ae3c1dc
Compare
There was a problem hiding this comment.
Changes requested: the per-channel recorded time fixes the late-first-frame reads and both earlier rebuild findings, but rebuild still reads the old frame's time when it sets the hit-test origin and the inline translate (packages/core/src/motion/animator.ts:1311 and :1327), because the channel's time is cleared only later, at :1469. After animate({x: 300}), a first frame at 1070 ms with the start unread, and rebase({x: -16}) at 1170 ms, the inline translate is 204.3 px while the rebuilt animation starts at 91.3 px, and presentedOffsetOf reports −113 px, then 0 for the rest of the curve while the element is drawn 113 px from where its animation started. Please clear the rebuilt channel's time before those reads, and assert the inline value and a zero presented offset in the rebase and set cases at animator.test.ts:939 and :962.
[Automated review]
| // starts at the frame that commits it, from its first keyframe. Its | ||
| // reads take that first value until then, and that frame dates its | ||
| // start again. The call's other channels keep their own. | ||
| waiting.latest?.delete(channel); |
There was a problem hiding this comment.
This delete runs after rebuild has already read valueAt for hitTested (line 1311) and for the inline write (line 1327), so both come from the old frame's time instead of this animation's first keyframe. With a first frame at 1070 ms and the start unread, rebase({x: -16}) at 1170 ms writes 204.3 px inline while the first keyframe is 91.3 px, and presentedOffsetOf reports −113 px, then 0 for the rest of the curve while the element is drawn 113 px from where its animation started. Clearing this channel's time before those reads keeps them on the first keyframe.
| * its start until its first frame runs. After that frame, the curve is read | ||
| * from that frame, at any time. Without that frame, a later time reads the |
There was a problem hiding this comment.
Non-blocking: "After that frame, the curve is read from that frame, at any time" does not hold for a channel a rebuild cleared, a paused animation, or a time at or before that frame. A shorter version that keeps only the reason: "Until the browser reports its start, a held curve shows its first value. A frame that ran without that start dates the curve. Without that frame, a later time reads from the provisional start, so a companion that samples ahead follows the curve's shape."
ae3c1dc to
6c4fb4a
Compare
|
Fixed in 6c4fb4a: |
There was a problem hiding this comment.
Changes requested: the late-first-frame reads, and the rebase and set paths with their inline value and hit-test origin, now hold, but a retarget of the other axis without a clock still reads the old call's recorded time. After animate({x: 300}), a first frame at 1070 ms with the start unread, and animate({y: 50}) at 1170 ms, rebuild writes x = 107.3 px as the inline value and the hit-test origin (packages/core/src/motion/animator.ts:1328 and :1344) before it adopts the x curve, whose rebuilt animation starts at 0, so presentedOffsetOf stays 107.3 px off for the rest of the curve where main reports it correctly. Please clear the rebuilt channel's time on the call the rebuild adopts or joins before those reads (the waiting !== callGroup condition at :1317 skips both), and add a unit case for the other-axis retarget that asserts the inline first keyframe and a zero presented offset.
[Automated review]
| .find(group => group != null && !group.resolved) ?? | ||
| null; | ||
| const rebuiltAfterFirstFrame = | ||
| waiting != null && waiting !== callGroup && waiting.framed === true; |
There was a problem hiding this comment.
This skips both rebuilds that run inside a call: a retarget of the other axis without a clock (a new call, which adopts the old x curve at lines 1378-1396) and an explicit-clock join (callGroup === waiting). In the first, with a first frame at 1070 ms unread and animate({y: 50}) at 1170 ms, the hit-test origin and the inline x below read 107.3 px from the old call's time while the rebuilt animation starts at x = 0, so presentedOffsetOf stays 107.3 px off for the rest of the curve. Clearing this channel's time on every waiting call the rebuild takes a curve from, before those reads, keeps them on the first keyframe.
The animator's first frame after a call made in a task starts that call itself when the browser has not reported a start yet, but only when that frame comes within LATE_START_MS of the call: after a longer gap it cannot tell a call made in a task from one a page's own frame callback made, and it waits for the browser's start. Under CPU contention the first frame alone can come late, with no block of the page's: Chromium's compositor starts the call at that frame and tells the page a frame or more later, and a read or a retarget in between read the call as not started. A retarget then restarted the curve from its first value while the screen had it moving, so the screen stepped back (the retarget proof failed 4 of 36 runs pinned to 2 cores at 6 workers, each with a first frame 57 to 74 ms after the call). A first frame that leaves the start unknown now records, for each moving channel, the time it ran. Chromium's compositor starts a call made in a task at the frame it draws after the one that commits it, within about a frame of that time, and one an earlier frame committed before it. Until the browser reports its start, which still decides, reads and retargets of that channel take the curve from that frame, at now and at later times, dated as the browser's start would date it: a curve that joined the call by an older clock keeps its lead over the call's own time. A rebase, a set or a retarget with a later clock that rebuilds one channel's animation after that frame starts a new animation at the frame that commits it, from its first keyframe: that channel's reads take that first value until then, and that frame dates its start again. The rebuild clears that channel's time before it writes the inline value and the hit-test origin, so both show that first keyframe too. The call's other channels keep their own times. A retarget that joins the waiting call by its clock rebuilds the channel the same way. A retarget of the other axis made without a clock after a late first frame takes the first axis's curve into its own call and still restarts it from its first value at the next commit, as on main. In both, the rebuild clears that channel's time on each waiting call it joins or takes a curve from, so its reads, the inline value and the hit-test origin show that first value.
6c4fb4a to
1d1e2fa
Compare
|
Fixed in 1d1e2fa: Also in this head: a held curve read from the recorded time is now dated as the browser's start would date it, so a curve that joined the call by an older clock keeps its lead over the call's own time. A third new case covers that join; it fails on 6c4fb4a, which read the joined curve 10 ms late. |
There was a problem hiding this comment.
Ready to approve: after a late first frame, reads and same-axis retargets now continue from where the compositor has the element, as spec:AST-094 FR6 requires, and the rebuild-path issues raised on earlier revisions are fixed. Seven of the new unit cases fail against the base animator, and all 212 cases in the file pass at this head. Two optional touch-ups: trim the valueAt comment that repeats the datedFromLatest JSDoc, and correct the description's note that all nine listed cases fail on main (the other-axis and clock-join rebuild cases pass there, since they guard state this change adds).
[Automated review]
| // The compositor starts the call near its first frame. The curve is | ||
| // dated as the browser's start would date it. A curve that joined by an | ||
| // older clock keeps its lead over the call's own time. |
There was a problem hiding this comment.
Non-blocking: the second and third sentences repeat the datedFromLatest JSDoc a few lines up. Keeping only the platform reason reads as:
// The compositor starts the call near its first frame.
User impact
A follow-up to #9255 in the touch presentations' animator, which is internal and drives no shipped component yet, so the changeset is
[chore]. Under CPU contention, a retarget made before Chromium reported a call's start could restart the curve from its first value while the screen already had it moving, and the screen stepped back. #9255 covers the same retarget when the call's first frame comes promptly; this covers a first frame that comes late with no block of the page's own.Problem and solution fit
LATE_START_MS(34 ms) of the call. After a longer gap that frame cannot tell a call made in a task from one a page's own frame callback made, so the animator waits for the browser's start. Under contention the first frame alone can come that late; until the start notice arrives, the call reads as not started, and a retarget then starts from the curve's first value.rebase(), aset()or a retarget with a later clock that rebuilds one channel's animation after that frame makes a new pending animation, which the browser starts from its first keyframe at the frame that commits it. So that channel's recorded time is cleared before the rebuild reads it, its reads take the rebuilt animation's first value, and that next frame records its time again. The inline value and the hit-test origin the rebuild writes show that first value too. The call's other channels keep their own times. A retarget that joins the waiting call by its clock rebuilds the channel the same way. A retarget of the other axis made without a clock takes the channel's curve into its own call and starts it again from its first value; that rebuild also clears the channel's time on the call it takes the curve from, so its reads, inline value and hit-test origin show that first value.Expected behavior and authority
spec:AST-094FR6, as #9255 holds it: a retarget made before the page can read a call's start begins where the screen shows the element, and the screen never steps back.Smallest restoration
Within the animator: the first-frame callback records
latest, per channel, on a call it leaves waiting;valueAtandvelocityAtread a waiting channel's curve from itslatestonce it is set, at any later time, dated as the browser's start would date it (datedFromLatest); andrebuildclears the channel'slateston each waiting call it restarts a curve from (a call it joins after that call's first frame, and a call whose curve it takes into its own) before it reads the value for the inline style and the hit-test origin, and records it again at the next frame. Nothing else changes: the first-frame start, the frame-callback and block exclusions,syncGroupandstartAfterBlockare as on main.Evidence
animator.test.ts, each failing onmain's animator (5a4e8fa) and passing here:{x: 300}, then{y: 50}joining with a clock 10 ms older;get('x')andget('y')equal the joined animation's keyframes 100 ms past the first frame. It fails on its fourth version, which read the joined curve 10 ms late;{x: 300, opacity: 0}call, thenrebase({x: -16})orset({y: 10}), whereget('opacity')follows the untouched fade and an opacity retarget starts there. They fail on the second version and on a mutant that clears every channel's time;get('x', 1186)andgetVelocity('x', 1186)at 1170 take the curve from 1070. It fails where only reads up to now use the recorded time.main; a follow-up carries that axis on from the screen. The same follow-up covers the presented offset a touch-down reads, which still takes a waiting curve's value at its own start (not the first keyframe, for a curve that joined by an older clock) in that window, as onmain.main.Status at this head: build, type check,
test:ui(17,806), the node suites (15,728, with 2 expected failures),check:repo,ASTRYX_STRICT_LINT=1 pnpm lint(0 errors),check:changesetsand changeset coverage pass. The animator spec passes ×3 in Chromium pinned to 2 cores (54 of 54), the retarget case ×36 at 6 workers on that pin (36 of 36), and ×10 under the CI WebKit job's command (140 passed, 40 skipped by design). Merged withmain, strict lint with the comment-provenance rule is clean on the changed files, and this change adds no provenance baseline entry.Scope
Testing
For contention, pin Chromium to 2 cores (
taskset -c 2,3) and run the retarget case at 6 workers. 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.