Skip to content

perf(studio): a long film's media durations write the store once per file, not once per clip - #6745

Open
miguel-heygen wants to merge 1 commit into
mainfrom
fix/studio-probe-batch
Open

miguel-heygen wants to merge 1 commit into
mainfrom
fix/studio-probe-batch

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

When a timeline loads, Studio probes the duration of every media file its clips play and writes each result into the player store. It wrote once per clip: a film that cuts one voice-over file into twenty clips wrote the store twenty times when that file's probe came back, each write a new elements array, and every subscriber (the timeline, and the Desktop app's Script panel on top) recomputed each time.

Each timeline sync re-probes every clip still missing a duration, so on a long film (600 clips over 30 files) the store was written about 3,600 times while the durations loaded.

probeMissingSourceDurations now groups the clips by file, probes each file once (as before), and hands back all of that file's clips in one apply. useTimelinePlayer writes them in one store update. That makes one write per file instead of one per clip, with no scheduling or delay added.

What I measured

fails without the fix: hands back every clip of one file in a single apply, so the store is written once per file in packages/studio/src/player/lib/mediaProbe.test.ts. With the per-clip version put back, it and the existing same-origin probe test fail.

  • mediaProbe.test.ts: 8 passed, 3 runs in a row. src/player/hooks/: 202 passed. Studio tsc --noEmit: clean.
  • The Desktop app on a generated long project (600 clips over 30 silent files, 23 minutes), on a Linux box with the published Studio and only this change applied, 3 runs each, first 15 s after opening: probe-driven store writes 3,600 before and 180 after, every run. Long-frame time over the same window did not measurably change (849 / 2,146 / 1,645 ms before, 854 / 1,300 / 2,395 ms after, on a shared box at load 5 to 10), so this removes repeated work but I have not measured a playback gain from it.

What I did NOT exercise

  • A real project with remote (https) media, where probes take longer. The change only groups writes; each file's probe and its timing are unchanged.

@github-actions

Copy link
Copy Markdown
Contributor

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

@miguel-heygen miguel-heygen changed the title fix(studio): a film that cuts one file into many clips plays smoothly while their durations load perf(studio): a long film's media durations write the store once per file, not once per clip Oct 29, 2026

This branch has not been deployed

No deployments
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