diff --git a/packages/studio/src/hooks/useStudioTestHooks.test.tsx b/packages/studio/src/hooks/useStudioTestHooks.test.tsx
index 847ccfd53b..17e81da6c7 100644
--- a/packages/studio/src/hooks/useStudioTestHooks.test.tsx
+++ b/packages/studio/src/hooks/useStudioTestHooks.test.tsx
@@ -5,6 +5,8 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import { usePlayerStore } from "../player/store/playerStore";
import {
createTimelinePerformanceFixture,
+ hasTimelinePerformanceFixtureLease,
+ setTimelinePerformanceFixtureLease,
type TimelinePerformanceFixtureProfile,
} from "../player/lib/timelinePerformanceFixture";
import { useStudioTestHooks } from "./useStudioTestHooks";
@@ -30,6 +32,7 @@ function Probe(): null {
describe("timeline performance fixture", () => {
afterEach(() => {
+ setTimelinePerformanceFixtureLease(false);
window.__studioTest = undefined;
usePlayerStore.getState().reset();
});
@@ -101,9 +104,11 @@ describe("timeline performance fixture", () => {
});
expect(usePlayerStore.getState().elements).toHaveLength(1_000);
expect(usePlayerStore.getState().expandedClipIds.size).toBe(1_000);
+ expect(hasTimelinePerformanceFixtureLease()).toBe(true);
unsubscribe();
act(() => root.unmount());
expect(window.__studioTest).toBeUndefined();
+ expect(hasTimelinePerformanceFixtureLease()).toBe(false);
});
it("does not mutate state when the fixture request is invalid", () => {
diff --git a/packages/studio/src/hooks/useStudioTestHooks.ts b/packages/studio/src/hooks/useStudioTestHooks.ts
index 3949c2d253..47467e2449 100644
--- a/packages/studio/src/hooks/useStudioTestHooks.ts
+++ b/packages/studio/src/hooks/useStudioTestHooks.ts
@@ -7,6 +7,7 @@ import {
} from "../player/lib/timelinePerformanceDiagnostics";
import {
createTimelinePerformanceFixture,
+ setTimelinePerformanceFixtureLease,
type TimelinePerformanceFixtureSpec,
type TimelinePerformanceFixtureSummary,
} from "../player/lib/timelinePerformanceFixture";
@@ -70,6 +71,7 @@ export function useStudioTestHooks({
},
loadTimelinePerformanceFixture: (spec) => {
const fixture = createTimelinePerformanceFixture(spec);
+ setTimelinePerformanceFixtureLease(true);
usePlayerStore.setState({
currentTime: 0,
duration: fixture.summary.duration,
@@ -91,6 +93,7 @@ export function useStudioTestHooks({
};
window.__studioTest = api;
return () => {
+ setTimelinePerformanceFixtureLease(false);
window.__studioTest = undefined;
};
}, [applyDomSelection, buildDomSelectionFromTarget, previewIframeRef]);
diff --git a/packages/studio/src/player/components/Timeline.tsx b/packages/studio/src/player/components/Timeline.tsx
index 61235d7af1..0bdfeae6df 100644
--- a/packages/studio/src/player/components/Timeline.tsx
+++ b/packages/studio/src/player/components/Timeline.tsx
@@ -513,6 +513,7 @@ export const Timeline = memo(function Timeline({
{
if (activeTool === "razor" && scrollRef.current) {
@@ -529,6 +530,7 @@ export const Timeline = memo(function Timeline({
>
{
diff --git a/packages/studio/src/player/hooks/useTimelinePlayer.ts b/packages/studio/src/player/hooks/useTimelinePlayer.ts
index 44bb17717d..a8a62338df 100644
--- a/packages/studio/src/player/hooks/useTimelinePlayer.ts
+++ b/packages/studio/src/player/hooks/useTimelinePlayer.ts
@@ -43,6 +43,7 @@ import {
shouldMutePreviewAudio,
} from "../lib/timelineIframeHelpers";
import { scrubMusicAtSeek, stopScrubPreviewAudio } from "../lib/playbackScrub";
+import { hasTimelinePerformanceFixtureLease } from "../lib/timelinePerformanceFixture";
import { applyCachedSourceDurations, probeMissingSourceDurations } from "../lib/mediaProbe";
import { shouldResumeForwardPlaybackAfterSeek, shouldStopAfterSeek } from "../lib/playbackSeek";
import { applyPreviewVariablesToUrl } from "../../hooks/previewVariablesStore";
@@ -68,6 +69,10 @@ function timelineElementsChanged(prev: TimelineElement[], next: TimelineElement[
});
}
+function resolveTimelineDuration(nextDuration: number | undefined, currentDuration: number) {
+ return nextDuration ?? currentDuration;
+}
+
export function useTimelinePlayer() {
const iframeRef = useRef
(null);
const rafRef = useRef(0);
@@ -85,10 +90,13 @@ export function useTimelinePlayer() {
const { setIsPlaying, setCurrentTime, setDuration, setTimelineReady, setElements } =
usePlayerStore.getState();
+ // The fixture lease belongs at this shared synchronization boundary so every
+ // iframe discovery path has the same owner for deciding whether it may write.
const syncTimelineElements = useCallback(
(elements: TimelineElement[], nextDuration?: number) => {
+ if (hasTimelinePerformanceFixtureLease()) return;
const state = usePlayerStore.getState();
- const resolvedDuration = nextDuration ?? state.duration;
+ const resolvedDuration = resolveTimelineDuration(nextDuration, state.duration);
// applyCachedSourceDurations re-applies the cached probe duration: re-derived
// elements (e.g. after a clip move) can arrive without sourceDuration, which
// otherwise makes trimmed waveforms lose their window.
diff --git a/packages/studio/src/player/lib/timelinePerformanceFixture.ts b/packages/studio/src/player/lib/timelinePerformanceFixture.ts
index 12707ea33c..8aed51bf01 100644
--- a/packages/studio/src/player/lib/timelinePerformanceFixture.ts
+++ b/packages/studio/src/player/lib/timelinePerformanceFixture.ts
@@ -29,6 +29,7 @@ export interface TimelinePerformanceFixture {
}
const TRACK_COUNT = 1_000;
+let fixtureLeaseActive = false;
const PROFILE_GEOMETRY: Readonly<
Record
> = Object.freeze({
@@ -39,6 +40,15 @@ const PROFILE_GEOMETRY: Readonly<
"remote-unsupported": { duration: 900, clipDuration: 12 },
});
+/** Prevent live iframe discovery from replacing an explicitly loaded dev fixture. */
+export function setTimelinePerformanceFixtureLease(active: boolean): void {
+ fixtureLeaseActive = active;
+}
+
+export function hasTimelinePerformanceFixtureLease(): boolean {
+ return fixtureLeaseActive;
+}
+
function validateFixtureSpec(spec: TimelinePerformanceFixtureSpec) {
if (spec.elementCount !== 1_000 && spec.elementCount !== 50_000) {
throw new RangeError("Timeline performance fixture elementCount must be 1000 or 50000");
diff --git a/packages/studio/tests/e2e/fixtures/timeline-virtualization/index.html b/packages/studio/tests/e2e/fixtures/timeline-virtualization/index.html
index 2846170bf5..ac56c980a3 100644
--- a/packages/studio/tests/e2e/fixtures/timeline-virtualization/index.html
+++ b/packages/studio/tests/e2e/fixtures/timeline-virtualization/index.html
@@ -1,8 +1,8 @@
-
+
-
-
+
+
Timeline virtualization QA fixture
-
+