Skip to content

perf(core): a video edit with no animation timeline stops rewriting every clip each frame - #6786

Closed
miguel-heygen wants to merge 2 commits into
mainfrom
perf/no-timeline-clip-reveal
Closed

miguel-heygen wants to merge 2 commits into
mainfrom
perf/no-timeline-clip-reveal

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

A composition with no animation timeline, such as a long cut list of video clips, no longer rewrites every hidden clip twice on each frame of playback.

Why

On each forward seek the runtime briefly shows the hidden clips whose tweens draw for the first time, so GSAP reads their authored style, then hides them again. When the page has no captured timeline there is nothing to ask, firstRendered is null, and null?.size !== 0 is true, so it took the fallback that shows every hidden clip. A 140-clip edit with no GSAP timeline removed and re-added data-hf-clip-hidden on 139 clips every frame, about 33,000 attribute writes a second, each one a style invalidation on a video.

Related work

None open on this path. The reveal check was last changed by #6189 and #5690.

How

The reveal now also needs a timeline that can draw: the root timeline or a registered scene timeline. The "registered timelines other than the root's" list moves into one helper that the scene seek and this check both use.

Test plan

  • Unit test in init.test.ts: on a page with no timeline, seeks across two video clips never query [data-hf-clip-hidden].
  • fails without the fix: removing the timeline condition fails leaves hidden clips alone on every jump when the page has no timeline and nothing else.
  • vitest run src/runtime in packages/core: 108 files, 2645 tests passed. oxfmt, oxlint, core tsc and the comment ratchet clean.
  • Manual testing in Studio preview, Chrome 156 on an M4 Pro MacBook Pro, 140 graded clips cut from one 44-minute synthetic 1080p file with no GSAP, 3 runs of 30 s per side:
per run, main → this branch
data-hf-clip-hidden writes a second 33,340, 33,357, 33,365 → 1, 1, 1
main thread idle in a 20.5 s CPU profile 6.86 s → 8.66 s (about 88 ms a second freed)
setProperty self time in that profile 329 ms → 37 ms
frame interval p95 10.2-10.4 ms → 10.3-10.4 ms
frames held 2+ periods 4, 3, 4 → 3, 5, 1

On this machine the freed time does not show up as smoother frames; the work goes away, and slower machines have less headroom to absorb it.

  • Documentation updated (not applicable)
  • Comments follow CONTRIBUTING.md "Comments"

@github-actions

Copy link
Copy Markdown
Contributor

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

  • seqplainkeys-none-center-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true
  • seqplainkeys-none-pct-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

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

Verdict: APPROVE · 0 blocker · 0 important · 0 nits · head e0c1e238

Scope
  • Read init.ts seek path end to end: hideClipsAgain() runs before the adapters seek, so only the root and scene timelines ever read inside the reveal. With neither, the reveal had no reader, and skipping it changes no frame. sceneTimelines() filters the same way the old inline loop did.
  • fails without the fix: confirmed locally. Dropping (tl || sceneTimelines().length > 0) fails only leaves hidden clips alone on every jump when the page has no timeline (262/263).
  • e0c1e238 vs 69d05c5c only trims comments (ratchet). CI, Windows render verification, regression, Comments and edit accuracy (271 = base) are green at this head.

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Folded into #6785 with its tests and numbers, so the three preview fixes for long cut-list edits review and land as one.

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.

1 participant