diff --git a/packages/studio/src/player/hooks/useTimelineSyncCallbacks.emptyManifest.test.tsx b/packages/studio/src/player/hooks/useTimelineSyncCallbacks.emptyManifest.test.tsx
index c039a6690a..b4114ac3c8 100644
--- a/packages/studio/src/player/hooks/useTimelineSyncCallbacks.emptyManifest.test.tsx
+++ b/packages/studio/src/player/hooks/useTimelineSyncCallbacks.emptyManifest.test.tsx
@@ -4,6 +4,7 @@ import React, { act } from "react";
import { createRoot } from "react-dom/client";
import { describe, expect, it, vi } from "vitest";
import type { TimelineElement } from "../store/playerStore";
+import { detachedFakeIframe } from "./timelinePlayerTestHarness";
import { useTimelineSyncCallbacks } from "./useTimelineSyncCallbacks";
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
@@ -39,3 +40,48 @@ describe("processTimelineMessage with an empty manifest", () => {
expect(sync).toHaveBeenCalledWith([], undefined);
});
});
+
+/** An open preview of `src` showing a root composition with nothing in it. */
+function emptyRootPreview(src: string, compositionId: string) {
+ const iframe = detachedFakeIframe({});
+ Object.defineProperty(iframe, "src", { value: src, configurable: true });
+ iframe.contentDocument!.body.innerHTML = `
`;
+ const sync = vi.fn<(els: TimelineElement[], duration?: number) => void>();
+ let processTimelineMessage: ReturnType["processTimelineMessage"];
+ function Harness() {
+ ({ processTimelineMessage } = useTimelineSyncCallbacks({
+ iframeRef: { current: iframe },
+ probeIntervalRef: { current: undefined },
+ pendingSeekRef: { current: null },
+ isRefreshingRef: { current: false },
+ getAdapter: () => null,
+ syncTimelineElements: sync,
+ setDuration: () => {},
+ setCurrentTime: () => {},
+ requestTimelineReady: () => {},
+ setIsPlaying: () => {},
+ attachIframeShortcutListeners: () => {},
+ applyPreviewAudioState: () => {},
+ }));
+ return null;
+ }
+ act(() => createRoot(document.createElement("div")).render());
+ processTimelineMessage!({ clips: [], durationInFrames: 300 });
+ return sync.mock.calls.at(-1)?.[0].map((row) => row.id);
+}
+
+describe("an empty clip list's root row", () => {
+ // fails without the fix: a new blank project's timeline showed its own film as one 10 s clip named "main".
+ it("is left out for the project's own film, so a blank project opens on an empty timeline", () => {
+ expect(emptyRootPreview("http://localhost/api/projects/b/preview", "main")).toEqual([]);
+ });
+
+ it("is the one clip of a composition opened on its own", () => {
+ expect(
+ emptyRootPreview(
+ "http://localhost/api/projects/b/preview/comp/compositions/scene5.html",
+ "scene5",
+ ),
+ ).toEqual(["scene5"]);
+ });
+});
diff --git a/packages/studio/src/player/lib/sealedPreviewFrame.test-helpers.ts b/packages/studio/src/player/lib/sealedPreviewFrame.test-helpers.ts
index e8ca3f79de..f641966fe3 100644
--- a/packages/studio/src/player/lib/sealedPreviewFrame.test-helpers.ts
+++ b/packages/studio/src/player/lib/sealedPreviewFrame.test-helpers.ts
@@ -8,6 +8,9 @@ function postLater(init: MessageEventInit): void {
setTimeout(() => window.dispatchEvent(new MessageEvent("message", init)));
}
+const SCENE_OPENED_ON_ITS_OWN =
+ "http://localhost/api/projects/demo/preview/comp/compositions/scene5.html";
+
export interface SealedPreviewFrame {
iframe: HTMLIFrameElement;
/** The frame's window as Studio sees it: only `postMessage` answers, and it reaches the runtime. */
@@ -26,6 +29,7 @@ export function sealedPreviewFrame(
});
const iframe = detachedFakeIframe(frame);
Object.defineProperty(iframe, "contentDocument", { value: null });
+ Object.defineProperty(iframe, "src", { value: SCENE_OPENED_ON_ITS_OWN, configurable: true });
let onPageUntilPlayerRemovesIt = true;
Object.defineProperty(iframe, "isConnected", {
configurable: true,
diff --git a/packages/studio/src/player/lib/timelineDOM.ts b/packages/studio/src/player/lib/timelineDOM.ts
index e3657ca674..7a5e92054d 100644
--- a/packages/studio/src/player/lib/timelineDOM.ts
+++ b/packages/studio/src/player/lib/timelineDOM.ts
@@ -460,6 +460,7 @@ export function buildStandaloneRootTimelineElement(params: {
if (!Number.isFinite(params.rootDuration) || params.rootDuration <= 0) return null;
const compositionSrc = resolveStandaloneRootCompositionSrc(params.iframeSrc);
+ if (compositionSrc === undefined) return null;
return {
id: params.compositionId,