Skip to content

fix(studio): a sealed save draws in the reply's task and spares a regrab's draft - #8563

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/sealed-patch-draws-in-own-task
Nov 23, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/sealed-patch-draws-in-own-task

Conversation

@miguel-heygen

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

Copy link
Copy Markdown
Collaborator

What

On a sealed preview, a move's save that the frame applies is now drawn in the same step as the reply, so the frame answers "patched" and Studio skips the soft-reload fallback. And a layer grabbed again before the previous drag's save lands keeps its new draft: the older save no longer ends it.

Both target the one-frame flash on the edit bench's seqheldtwice-tlhold-px case: the held layer showed 312 px away, where the drag began, in 3 of 3 sealed runs (unsealed: 0.1 px). The flash is reduced, not gone. Something else still causes it, and it isn't rooted yet (see Test plan).

Why

There were two causes, each enough to flash on its own.

A patch the frame applied but didn't draw. A sealed save asks the frame to patch the live tweens (patch-tweens), and the drag's draft end rides that message (#8473). The frame ends the draft only if the patch is on screen, and patchTweens checks that through GSAP's _initted, as of #8517. A Studio preview's seek paints asynchronously (seekWhenReady routes to the native preview seek), so in a live preview the patched tween hadn't rendered when the reply was computed. The frame answered patched: false, and Studio sent the draft end alone and soft-reloaded. The end painted first, with the layer at the old held value under the drag's drawn offset, then the reload drew the saved place.

An older save that ended a newer gesture's draft. When a layer is grabbed again before the previous drag's save goes out, the new drag draws into the same draft entry (drawPreviewDraft merges onto it), which is still armed for the older save. The older save then took that end with it, and its patch cleared the new drag's drawn offset for a frame, until the next pointer move drew it again.

Related work

Refs #7846 (Studio's preview sealed by default). Follows #8473 (the draft end rides the save) and #8517 (the patch reply reads whether the tween rendered).

How

  • Frame (patchTween.ts): after a seeking patch, patchTweens redraws, in its own task, the timeline of any patched tween the playhead has reached but the seek left undrawn, at that timeline's total time so a repeating or yoyo timeline stays on its pass. It uses redrawGsapTimelineAt, the redraw the runtime already uses for held scenes. The reply is then true, and the draft end paints in the same task as the patched value. An unsealed preview's seek draws synchronously, so it never reaches the redraw.
  • Studio (previewDrafts.ts): a draw onto a draft entry already armed for a save disarms it. A new draw there means a newer gesture owns the element. The older save carries no end, its .finally already skips a gesture that's no longer current, and the newer gesture arms its own end when it's released.
  • The two patchTween.sceneRest rows that pinned patched: false (a set in a child timeline that already ended, and no player) now draw and answer patched.

No visible change

On a sealed preview, a held layer's save no longer goes through a reload, and a quick second grab keeps following the pointer. 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: "draws a patched root hold in the patch's own task, and answers patched", "draws the patched set in a child timeline that already ended, and answers patched", "draws the patch itself when no player seeks the scene it changed", "draws a patched hold on a yoyo timeline's second pass without rewinding it to the first" (fails with the redraw at the timeline's local time);
  • packages/studio/src/components/editor/gsapMoveSealedPreview.test.ts: "leaves the regrab's draft alone when the older save lands", "ends only the newest gesture's draft when three saves land out of order".

"puts a cancelled regrab back where the older save left it, not where the older drag began" and "leaves the regrab's draft alone when the older save fails" pass on main too. They pin that disarming keeps a cancelled regrab and a failed older save right. In previewDrafts.test.ts, #8537's flush row now arms after the last draw, the order a real release takes.

  • With the fix, Core src/runtime/editing (17 files, 208 tests) and Studio gsapMoveSealedPreview and previewDrafts (40 tests) pass three runs in a row on Linux.
  • Studio (833 files, 9,411 tests), core src/runtime (164 files, 3,597 tests) and producer unit (1,540 tests) pass; core and Studio typecheck clean. Producer integration failed 1 of 344 and engine failed 1 of 3,644 (deliveryEncoderOptions VBV bound); both passed when rerun on the branch, and the engine file passed twice.
  • Edit bench on Linux, main vs this branch, 45 cases (every resize-* case plus the row's 12 sequences), 3 jobs, 2 sealed and 2 unsealed runs each; each run read its preview frame's origin in-run (null sealed, http://127.0.0.1:5800 unsealed). Unsealed: no failing check on either side. Sealed, seqheldtwice-tlhold-px worst drag-step jump: root 312.4 and 234.3 px on main, 203.1 and 312.4 on the branch; nested 312.4 and 312.4 on main, 171.8 and 218.6 on the branch. The other sealed failing checks are the same set on both sides (seqfastkeys-none-px teleport 2/2 each; a tracking miss in 1-2 runs of seqheldtwice and seqplainkeys-none-center; resize-scale-px-on teleport 1/2 on main, 2/2 here).
  • Not done: the remaining flash's cause. In a probe run of this branch every save answered patched and no soft reload ran, so it's neither cause above.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 58 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)

  • seqfastkeys-none-px-r0-root-z100: tracking 193.72, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 — The fallback redraw can rewind a repeating timeline. In patchTween.ts, drawWhatTheSeekLeft passes parent.time() to redrawGsapTimelineAt, which seeks with totalTime(). At total time 1.25 on a one-second yoyo timeline, the local time is 0.75. I checked with GSAP: this redraw seek moves the timeline from iteration 2 to iteration 1. The tween can then look initialized and the frame can answer patched after drawing the wrong iteration. Please preserve the repeat position and add a test with a deferred seek and a patched tween in a later iteration.

— tai (automated review)

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Fixed in 254ed00: drawWhatTheSeekLeft now redraws at the timeline's totalTime(), so a repeating or yoyo timeline stays on the pass it's on.

New row in patchTween.sceneRest.test.ts, "draws a patched hold on a yoyo timeline's second pass without rewinding it to the first". It seeks into the second pass of a one-second yoyo timeline, defers the player's seek and patches the hold. It fails with the local time() (the timeline is rewound to the first pass) and passes with the fix. Core src/runtime/editing passes 3 runs in a row (208 tests), and core src/runtime passes (3,597).

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fallback redraw now preserves the repeating timeline’s total position. The new second-pass yoyo regression checks both the patched value and the position. I ran 91 targeted core tests, including the redraw adapter tests. The PR still documents residual flashes in the broader edit bench. Required CI is still running.

— tai (automated review)

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 44c1e0c Nov 23, 2026
148 of 150 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-patch-draws-in-own-task branch November 23, 2026 07:57
miguel-heygen added a commit that referenced this pull request Nov 23, 2026
moses-y pushed a commit to moses-y/hyperframes that referenced this pull request Nov 23, 2026
* chore: release v0.9.85

* chore: release notes for v0.9.85 list heygen-com#8563

* chore: release notes for v0.9.85 list heygen-com#8561 and heygen-com#8570
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