Skip to content

fix(core): a sealed move inside a nested composition shows where it was dropped - #8517

Merged
miguel-heygen merged 5 commits into
mainfrom
fix/sealed-patch-renders-nested-timeline
Nov 22, 2026
Merged

miguel-heygen merged 5 commits into
mainfrom
fix/sealed-patch-renders-nested-timeline

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

On a sealed preview, moving an element that lives inside a nested composition now shows the move. Before, the save landed in the file, the frame said the edit was applied, and the element stayed where it was. When Studio then removed the drawn offset, the element jumped back to its old spot.

Why

A sealed save patches the live GSAP tween in the frame and asks for a redraw at the current time. The runtime seeks each nested composition's timeline on its own, and skips one that already rests at the time it would draw. That skip is right for playback and renders: nothing changed, so nothing needs drawing. After a patch, though, the scene still rests at the same time, so it was skipped. Even a seek to that same time draws nothing in GSAP. The root timeline doesn't have this problem because its seek redraws afterwards; the scene seek never did.

The frame then answered patched: true anyway. Studio trusted that answer, so the save's end dropped the drawn offset and the element showed its old position.

The edit-accuracy sequence seqheldtwice-tlhold-px-r0-nested-z100 shows it on every sealed run: after the move, the element sits 312 px from where it was dropped, while the saved file is right. Unsealed, it passes.

Related work

Refs #7846 (Studio's preview sealed by default): its edit-accuracy gate flags this sequence. Builds on #8473, whose save carries the end of the drawn offset and falls back when the frame says it could not apply the edit.

How

  • sceneRest.ts (new) owns the record of where each scene timeline last rested, which init.ts kept in a private map, plus a "redraw due" mark.
  • patchTween marks the resting timelines above the patched tween as due. The scene seek loop never skips a due scene, and redraws it after its seek with the same redraw the root timeline uses. That redraw is now one helper, redrawGsapTimelineAt, called by the root path, seekGsapTimeline and the scene path, instead of two copies.
  • The frame answers patched only when each patched tween that the playhead has reached has rendered since the patch. The check reads GSAP's internal _initted: invalidate() clears it and the tween's next render sets it again. The runtime already reads GSAP internals (_zTime, _act, _ts) in its redraw code; a test pins this one against the GSAP version we ship.
  • When nothing redraws a patched tween, the frame now answers patched: false, and Studio's existing fallback applies the edit by reloading instead of showing a stale element.
  • A keyframe-step edit replaces its tween, so the patch tracks the new tween for that check.

Limit: a patched tween inside an author's own child timeline that has already ended is still not redrawn, by this change or by the root's redraw. It now answers patched: false, so the edit shows after the fallback reload rather than staying stale.

No visible change

On a sealed preview, a move of an element inside a nested composition now shows where it was dropped. The interface itself doesn't change.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments"

fails without the fix:

  • packages/core/src/runtime/editing/patchTween.sceneRest.test.ts, run against the real runtime and real GSAP:
    • "draws the patched set on a scene 1 composition deep, and only then answers patched";
    • "draws the patched set on a scene 2 composition deep, and only then answers patched";
    • "answers not patched when the patched set sits in a child timeline that already ended";
    • "answers patched for a keyframe-step edit once the tween that replaced it renders";
    • "answers not patched when nothing draws the scene it changed".

"still skips a scene at rest that no patch touched" passes before and after; it fails if every scene is redrawn, so the skip stays. "is cleared by invalidate() and set again by the tween's next render" pins GSAP's _initted. With the reply trusting the redraw bookkeeping instead of the render, the ended-child and nothing-draws rows fail.

  • Every test under packages/core/src/runtime (163 files, 3,570 tests) passes three runs in a row on Linux.
  • Producer tests that load the runtime pass: coreRuntimeBrowser, bundleScriptPolicy, vfxDeterminism and hiddenClipCascade (130 tests), and fileServer, htmlCompiler and probeStage under bun (380 tests).
  • Producer regression renders with scenes, sub-compositions and GSAP redraws pass, 12 of 12: gsap-call-render-seek, gsap-redraw-start-and-overlap, hf2550-video-subcomposition-ghost, nested-sequential-video-local-start, nested-subcomp-depth-3, static-dedup-nested-visibility, sub-comp-class-selector, sub-comp-height-percent, sub-comp-id-selector, sub-comp-t0, sub-composition-video, subcomp-bare-fragment.
  • On the edit-accuracy bench, sealed: in seqheldtwice-tlhold-px-r0-nested-z100 the move now shows where it was dropped. Its drop and reload checks pass 3 of 3; before, they failed 3 of 3. Its undo check still fails sealed, from a separate cause.
  • Unsealed, the 12 sequences this work covers ran alternating between main and this branch, 6 runs each at 3 parallel jobs: this branch passed 72 of 72, main 71 of 72. Main's miss was a redo that landed 312 px off under load, a flake that main already has.
  • Pre-commit (format, lint, fallow, typecheck) passes.

@github-actions

Copy link
Copy Markdown
Contributor

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

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

Quarantined, measured but not gated (0)

Unstable (1)

  • seqrotatenudge-none-pct-r0-root-z100: tracking 0.03, pressJump 0, drop 0, reload 3.03, render 0.04, renderKey -, undo false, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.08, renderKey -, undo true, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.08, renderKey -, undo true, teleport true

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

A sealed move inside a nested composition now redraws that composition, and the frame answers patched only once the patched tween has actually rendered.

Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅
Risk: low. Redraw marks come only from patchTween, so playback and renders keep the skip for scenes at rest. The new patched: false answers go to Studio's existing reload fallback.

  • Which tests fail without the fix: with main's gsap.ts, patchTween.ts and init.ts put back, all 5 rows named in the body fail. In the 1-deep scene case the element stays at 40 instead of 300; the others get the wrong patched answer. At this head all 7 pass, and so do the 1,460 tests under runtime/editing, runtime/adapters and runtime/init*.
  • Scene skip: takeSceneRedrawDue is read before restsAt, so a marked scene is always seeked once, then redrawn by redrawGsapTimelineAt when the seek itself drew nothing. markRestingScenesForRedraw only marks timelines that are already in restingAt, so the root and scenes never seeked are left alone. A mark on a scene the loop doesn't visit just stays put: its tween doesn't render, and the frame answers patched: false, so Studio reloads.
  • patched check: renderedOnceReached compares against the parent's local time(), so a tween the playhead hasn't reached doesn't block the answer. A _initted false-negative only costs a reload; it can't make a stale edit look applied.
  • Keyframe rebuild: the children snapshot is taken after kill(), so find returns the replacement tween. If getChildren were missing, the patch would now report not-applied instead of applied. That's safe, and real GSAP always has it.
  • Reuse: the root path and seekGsapTimeline now share redrawGsapTimelineAt, which removes the duplicated bind block in init.ts.
  • Nit: redrawGsapTimelineAt returns early when there is no totalTime, but seekGsapTimeline still returns true (redrawn) on that path. Main threw there instead. It's unreachable for GSAP timelines, so this is not a blocker.

— Rames (hf-review)

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit ec9a3a8 Nov 22, 2026
101 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-patch-renders-nested-timeline branch November 22, 2026 16:38
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