From a595755a35f4d7ad49b83a47f4e39445562bf3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sat, 7 Nov 2026 18:16:25 +0000 Subject: [PATCH] fix(core): a film moves on past a video the browser never starts loading (#7368) --- packages/core/src/runtime/init.test.ts | 24 ++++++++++++++ packages/core/src/runtime/media.test.ts | 36 +++++++++++++++++++-- packages/core/src/runtime/media.ts | 43 +++++++++++++++++-------- 3 files changed, 87 insertions(+), 16 deletions(-) diff --git a/packages/core/src/runtime/init.test.ts b/packages/core/src/runtime/init.test.ts index a477da0f80..143c9359fe 100644 --- a/packages/core/src/runtime/init.test.ts +++ b/packages/core/src/runtime/init.test.ts @@ -6583,6 +6583,30 @@ describe("initSandboxRuntimeModular", () => { expect(seeks.filter((t) => t > 0.1)).toEqual([]); }); }); + describe("a video the browser never starts loading", () => { + it("moves the film on past it after the wait and names it", async () => { + const raf = createManualRaf(); + vi.spyOn(performance, "now").mockImplementation(() => raf.now()); + window.requestAnimationFrame = + raf.requestAnimationFrame as typeof window.requestAnimationFrame; + window.cancelAnimationFrame = raf.cancelAnimationFrame as typeof window.cancelAnimationFrame; + const warn = vi.spyOn(console, "warn").mockImplementation(() => {}); + const video = mountAudio("/assets/clip.mp4", { muted: "" }, "video"); + // What Safari reports for a video it never requested: loading, with no data and no bytes. + Object.defineProperty(video, "readyState", { value: 0, configurable: true }); + Object.defineProperty(video, "networkState", { value: 2, configurable: true }); + + await startPlayback(); + for (let frame = 0; frame < 60 * 7; frame++) raf.step(1000 / 60); + + expect(window.__player?.getTime()).toBeGreaterThan(1); + expect( + warn.mock.calls.some(([line]) => + String(line).includes('clip.mp4": the browser never started loading it'), + ), + ).toBe(true); + }); + }); describe("an audible