Repository navigation
fix(studio): a sealed motion path stays on its layer after a seek - #8679
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Requesting changes at 67a42ee6 for one regression the early return adds. The fix itself is right for the case it targets.
What holds:
useMotionPathDatanow waits while a sealed frame's x/y read hasn't arrived, instead of drawing the other axis from 0.- It recomputes as soon as the read arrives, through
useGsapSnapshotVersion. - A regular preview is unchanged, because its read never comes back empty.
useMotionPathData.test.tsxpasses 11/11 here, including the new test.
Blocker: a new selection keeps the previous element's path while the read is pending.
The early return in recompute skips setGeometry. Nothing clears geometry when selector changes, so the path still in state is the last selection's. In a sealed preview the read stays pending for the whole of playback, not just for a moment after a seek: frameGsap returns null unless the playhead is paused (fresh → pausedPlayhead).
So if you select box A, press play, then select box B, MotionPathOverlay draws A's nodes from B's home until playback pauses. Before this PR it drew B's own path, only with the axis B's tween leaves alone at 0.
Probe: the same mocks as useMotionPathData.test.tsx, with a sealed iframe.
- Render with
#a. A's tween is x 0→500 and the read is{x: 0, y: 10}. The path is0,10 500,10. - Re-render with
#b. B's tween is y 0→300 and the read is pending (null). - Advance timers by 1 s. The path is still
0,10 500,10, which is A's path.
Suggested fix:
- Only keep the shown path while it belongs to the same selector. For example, return early only when
resolvedForRef.current === selector. Otherwise setgeometryto null and leavegeometryResolvedfalse. - Add a test that switches the selector while the read is pending.
— Rames
Edit accuracy: accurate 273 (base branch 271), smooth 52 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
jrusso1020
left a comment
There was a problem hiding this comment.
Approving at 4828c329. My change request from 67a42ee6 is fixed.
- The fix: while a sealed read is pending,
recomputenow keeps the shown path only when it was drawn for the current selector (resolvedForRef.current === selector). Otherwise it clearsgeometry. Selecting B while A's path is kept, such as during playback, now draws nothing instead of A's path at B's position. Going back from B to A while the read is still pending stays clear too. - Fails without the fix (checked): with
useMotionPathData.tsfrom67a42ee6put back, "drops the kept path when another layer is selected before a sealed read lands" fails. At head, the threeuseMotionPathDatatest files pass 17/17.
Nit, not blocking: the clearing happens in the effect, so the first render with the new selector can still show the old path for one frame before the effect runs.
What
In a sealed preview, a motion path whose tween moves only one axis is now drawn through the layer, as in a regular preview. Before, after a seek it could be drawn at 0 on the other axis: for a box held at
y: 200with an x-only tween, the path sat 200 px above the box.Why
The motion path draws an axis the tween leaves alone at GSAP's current value for that axis. Studio reads it with
readGsapPositionFromIframe. A sealed frame answers that read only once its GSAP values at the paused playhead have arrived over the port (frameGsapinhooks/gsapFrameSnapshot.ts), so right after a seek it returns nothing for a moment.useMotionPathDatathen built the path from{ x: 0, y: 0 }and kept it.In sealed Studio on main (devbox, the fixture below), six seeks by the timeline ruler left the path at y 0 while the box stayed at y 200, and some frames during those seeks drew it elsewhere again. A regular preview reads the frame's GSAP directly and never draws it off.
Related work
Refs #7846 (Studio's preview sealed by default): one of the sealed readers that must give the same result as a regular preview.
How
components/editor/useMotionPathData.ts:useGsapSnapshotVersion, the signal other sealed readers use), not only on its 250 ms tick.A regular preview is unchanged: its read never comes back empty.
Test plan
drops the kept path when another layer is selected before a sealed read landsinsrc/components/editor/useMotionPathData.test.tsxfailed on the first version of this branch (67a42ee) withexpected '60,30 120,30' to be undefined: layer B showed layer A's path.waits for a sealed frame's x/y before drawing the axis the tween leaves aloneinsrc/components/editor/useMotionPathData.test.tsxfailed on main withexpected '60,0 120,0' to be undefined: the path was drawn at y 0 before the frame's x/y arrived.useMotionPathData.test.tsx,useMotionPathData.sealed.test.tsanduseMotionPathData.reply.test.ts, 3 runs each, green. The 6 Studio test files that cover the changed file, green. tsc, Fallow and the pre-push hooks clean.VITE_STUDIO_OPAQUE_PREVIEW_ENABLED=true) and regular. Fixture: a box withtl.set("#box", { y: 200 })and an x-only keyframed tween. Select the box, seek by the ruler to 1.0, 3.0, 0.5, 2.5, 1.5 and 3.5 s, and sample the drawn path every frame for 900 ms after each seek:Before
Sealed preview on main, after the seeks: the path is drawn above the box.
After
Sealed preview on this branch, after the same seeks: the path runs through the box.
Regular preview on this branch, for comparison: