From f1f8ca31c3dcf752fb4aadb4933f43b903ebd2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Tue, 17 Nov 2026 17:26:46 +0000 Subject: [PATCH] fix(core): hover and thumbnail captures never wait for a 4K clip's preview copy (#8079) * test(core): a hover capture page keeps a 4K clip's file instead of waiting for its copy * fix(core): hover and thumbnail captures never wait for a 4K clip's preview copy * fix(core): keep mediaProxy's comment share flat * test(core): keep the capture-page test comment within 120 characters --- packages/core/src/runtime/mediaProxy.test.ts | 16 ++++++++++++++++ packages/core/src/runtime/mediaProxy.ts | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/core/src/runtime/mediaProxy.test.ts b/packages/core/src/runtime/mediaProxy.test.ts index 60ef1fdf08..cc36e5a1df 100644 --- a/packages/core/src/runtime/mediaProxy.test.ts +++ b/packages/core/src/runtime/mediaProxy.test.ts @@ -27,6 +27,7 @@ vi.mock("./bridge", () => ({ import { postRuntimeMessage } from "./bridge"; import { resetSeekDispatchState, waitForSeekCompletion } from "./adapters/seek-dispatch"; import { resetCopyReporting } from "./previewCopies"; +import { STUDIO_PREVIEW_CAPTURE_MODE, STUDIO_PREVIEW_MARK_META } from "../studioPreviewMark"; const postRuntimeMessageMock = vi.mocked(postRuntimeMessage); @@ -1247,6 +1248,21 @@ describe("preview quality: lighter copies of heavy files", () => { expect(proxySrc.unproxiedSrc(el)).toBe("/video.mp4"); }); + // A hover capture timed out at 8 s waiting for the copy; a capture page never plays, so it takes the file. + it("on a hidden capture page keeps its file and asks for no copy", async () => { + const mark = document.head.appendChild(document.createElement("meta")); + mark.name = STUDIO_PREVIEW_MARK_META; + mark.content = STUDIO_PREVIEW_CAPTURE_MODE; + try { + const { el, asks } = await waitingForItsCopy(making); + await vi.advanceTimersByTimeAsync(10_000); + + expect([el.getAttribute("src"), asks()]).toEqual(["/video.mp4", 0]); + } finally { + mark.remove(); + } + }); + it("is not given its file back as its clip comes due", async () => { const { el, preload } = await waitingForItsCopy(making); diff --git a/packages/core/src/runtime/mediaProxy.ts b/packages/core/src/runtime/mediaProxy.ts index 3fd05e9322..73565c2491 100644 --- a/packages/core/src/runtime/mediaProxy.ts +++ b/packages/core/src/runtime/mediaProxy.ts @@ -46,6 +46,7 @@ import { type PreviewSourceFacts, wantsLighterCopy, } from "../previewProxyBox"; +import { capturePageIn } from "../studioPreviewMark"; /** * One entry per project-root-relative asset pathname, injected by the @@ -573,7 +574,7 @@ export function maybeProxyProactively(el: HTMLMediaElement): void { } function lightenIfHeavy(el: HTMLMediaElement, entry: MediaCodecMapEntry | null): void { - if (swappedElements.has(el) || proxyRequested.has(el)) return; + if (capturePageIn(document) || swappedElements.has(el) || proxyRequested.has(el)) return; const facts = sourceFactsOf(el); if (facts) swapToProxy(el, entry, "light", facts); }