Skip to content

fix(studio): a sealed motion path stays on its layer after a seek - #8679

Merged
miguel-heygen merged 4 commits into
mainfrom
fix/studio-sealed-motion-path-base
Nov 24, 2026
Merged

miguel-heygen merged 4 commits into
mainfrom
fix/studio-sealed-motion-path-base

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

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: 200 with 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 (frameGsap in hooks/gsapFrameSnapshot.ts), so right after a seek it returns nothing for a moment. useMotionPathData then 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:

  • While a sealed frame's x/y read has not arrived, the path keeps what it shows instead of drawing from 0, but only for the layer it was drawn for. Selecting another layer meanwhile clears it, so one layer's path never shows on another (during playback the read stays pending the whole time).
  • It recomputes as soon as a read arrives (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

  • fails without the fix: drops the kept path when another layer is selected before a sealed read lands in src/components/editor/useMotionPathData.test.tsx failed on the first version of this branch (67a42ee) with expected '60,30 120,30' to be undefined: layer B showed layer A's path.
  • fails without the fix: waits for a sealed frame's x/y before drawing the axis the tween leaves alone in src/components/editor/useMotionPathData.test.tsx failed on main with expected '60,0 120,0' to be undefined: the path was drawn at y 0 before the frame's x/y arrived.
  • On the devbox with the fix: useMotionPathData.test.tsx, useMotionPathData.sealed.test.ts and useMotionPathData.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.
  • Real app: Studio's dev server on the devbox, sealed (VITE_STUDIO_OPAQUE_PREVIEW_ENABLED=true) and regular. Fixture: a box with tl.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:
path after the seeks frames drawn off the settled path
sealed, main at y 0, 200 px above the box 2 to 13 of ~328 per run (5 runs; 3 of them with a plain x tween instead of keyframes)
sealed, this branch through the box 0 of ~328 (3 runs)
regular, main and this branch through the box 0 of ~330

Before

Sealed preview on main, after the seeks: the path is drawn above the box.

Sealed preview on main after seeks: the motion path drawn 200 px above the box

After

Sealed preview on this branch, after the same seeks: the path runs through the box.

Sealed preview on this branch after seeks: the motion path through the box

Regular preview on this branch, for comparison:

Regular preview on this branch after seeks: the motion path through the box

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes at 67a42ee6 for one regression the early return adds. The fix itself is right for the case it targets.

What holds:

  • useMotionPathData now 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.tsx passes 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.

  1. Render with #a. A's tween is x 0→500 and the read is {x: 0, y: 10}. The path is 0,10 500,10.
  2. Re-render with #b. B's tween is y 0→300 and the read is pending (null).
  3. 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 set geometry to null and leave geometryResolved false.
  • Add a test that switches the selector while the read is pending.

— Rames

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 273 (base branch 271), smooth 52 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Newly passing (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Quarantined, measured but not gated (0)

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 4828c329. My change request from 67a42ee6 is fixed.

  • The fix: while a sealed read is pending, recompute now keeps the shown path only when it was drawn for the current selector (resolvedForRef.current === selector). Otherwise it clears geometry. 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.ts from 67a42ee6 put back, "drops the kept path when another layer is selected before a sealed read lands" fails. At head, the three useMotionPathData test 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.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit efb797a Nov 24, 2026
127 checks passed
@miguel-heygen
miguel-heygen deleted the fix/studio-sealed-motion-path-base branch November 24, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants