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
This commit is contained in:
Miguel Ángel
2026-11-17 17:26:46 +00:00
committed by GitHub
parent 2749aafb36
commit f1f8ca31c3
2 changed files with 18 additions and 1 deletions
@@ -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);
+2 -1
View File
@@ -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);
}