fix(core): a capture page loads a clip with no set length only when it is due (#7938)

* fix(core): a capture page loads a clip with no set length only when it is due

* fix(core): keep the capture-page comment within the comment share
This commit is contained in:
Miguel Ángel
2026-11-16 16:10:40 +00:00
committed by GitHub
parent 51ae925105
commit 9e50487720
3 changed files with 27 additions and 5 deletions
+20
View File
@@ -511,6 +511,26 @@ describe("runtime entry", () => {
expect(loadsOf(now, soon, later)).toEqual([2, 0, 0]);
});
it("in a hidden capture page a clip with no authored length waits until due, and keeps its length once loaded", async () => {
spyLoad();
servePreview().setAttribute("content", STUDIO_PREVIEW_CAPTURE_MODE);
const clips = videos(mountRoot(), "0", "1.5", "9");
for (const clip of clips) clip.removeAttribute("data-duration");
const [now, soon, later] = clips;
await evaluateRuntime();
expect(armed(now!, soon!, later!)).toEqual([true, false, false]);
expect(loadsOf(now!, soon!, later!)).toEqual([1, 0, 0]);
Object.defineProperty(now!, "readyState", { value: 1 });
Object.defineProperty(now!, "duration", { value: 2 });
window.__player?.seek(9.4);
// The loaded clip is never reloaded, which would drop the length it is timed by; one with no length
// known that started before the playhead may still be on screen, so it loads.
expect(armed(now!, soon!, later!)).toEqual([true, true, true]);
expect(loadsOf(now!)).toEqual([1]);
});
// Three takes of one file, each a picture and a sound, as an edit cut from a single source is.
const takesOfOneFile = () => {
const root = mountRoot();
+5 -3
View File
@@ -3111,10 +3111,12 @@ export function initSandboxRuntimeModular(): void {
};
// Where Studio's loop wraps to (window.__hf.setLoopStart); null when it does not loop.
let loopStartSeconds: number | null = null;
// A clip with no authored length loads as in a render: a reload would drop the duration it is
// timed by.
// An unauthored length stays loaded (a reload drops it); on a capture page an unloaded one waits
// until due, or a thousand such clips run the renderer out of memory.
const inPreloadWindow = (el: HTMLMediaElement) =>
mediaDeferred && el.hasAttribute("data-start") && lengthIsAuthored(el);
mediaDeferred &&
el.hasAttribute("data-start") &&
(lengthIsAuthored(el) || (!loadsAhead && el.readyState === HTMLMediaElement.HAVE_NOTHING));
// Media on screen or due within the look-ahead loads; the rest stops holding a connection to
// the origin that also serves Studio's thumbnails.
+2 -2
View File
@@ -10,7 +10,7 @@ import {
import { createRuntimeStartTimeResolver } from "./startResolver";
import { readMediaRenderId } from "./renderFrameSibling";
import { defersMedia } from "./timedClipHide";
import { inPlayerFrame } from "../studioPreviewMark";
import { capturePageIn, inPlayerFrame } from "../studioPreviewMark";
import { swallow } from "./diagnostics";
import { isWebKit, mediaElementTime } from "./mediaClock";
@@ -216,7 +216,7 @@ export function deferMediaUntilDue(): void {
if (!defersMedia()) return;
const defer = (el: Element, startInFilm: (el: Element) => number, parsedEarly = false) => {
const start = parseStrictFiniteTimingNumber(el.getAttribute("data-start"));
if (start == null || !lengthIsAuthored(el)) return;
if (start == null || (!lengthIsAuthored(el) && !capturePageIn(document))) return;
const media = el as HTMLMediaElement;
const authoredPreload = media.preload;
const later = startInFilm(el) > 0;