Files
hyperframes/packages/core/src/previewProxyBox.test.ts
Miguel Ángel b66e8a195e perf(studio): preview decodes hard-to-play videos at the size they are shown (#5184)
* perf(studio): preview decodes hard-to-play videos at the size they are shown

Studio's copy of an HEVC or ProRes clip was made at the source's full size, so a 4K clip was decoded at 4K inside a preview a few hundred pixels wide, and back-to-back 4K clips flashed the background at their cuts. The player now reports how large it shows the composition, the runtime asks for a copy sized to the shown video (on a ladder of sizes, never above the source), and Studio stops pre-warming source-size copies. CLI play, static serving, publish and renders keep the source-size copy.

* fix(studio): sized preview copies follow zoom, hover previews and the newest size

Studio reports the preview's on-screen scale when a zoom settles and for composition hover previews, which no player measures. The runtime loads only the newest size asked for, regrows a first copy made while the frame grew, and never replaces a copy with one smaller on either side. The player's scale is measured against the frame's own layout width.

* fix(studio): keep comment shares and file sizes within the repo ratchets

* test(studio-server): end the sizing test's ffprobe options before its input

* fix(studio): hover previews report their size once their runtime is ready
2026-10-08 00:26:08 +00:00

22 lines
898 B
TypeScript

import { describe, expect, it } from "vitest";
import { parsePreviewProxyBox, quantizePreviewProxyBox } from "./previewProxyBox";
describe("preview proxy box", () => {
it("rounds each side up to the next rung", () => {
expect(quantizePreviewProxyBox(1080, 1920)).toEqual({ width: 1448, height: 2048 });
expect(quantizePreviewProxyBox(1, 256)).toEqual({ width: 256, height: 256 });
});
it("has no bound for an empty box or one past the largest rung", () => {
expect(quantizePreviewProxyBox(0, 1920)).toBeNull();
expect(quantizePreviewProxyBox(8193, 100)).toBeNull();
});
it("reads back only rungs", () => {
expect(parsePreviewProxyBox("1448x2048")).toEqual({ width: 1448, height: 2048 });
expect(parsePreviewProxyBox("1449x2048")).toBeNull();
expect(parsePreviewProxyBox("1448x2048x1")).toBeNull();
expect(parsePreviewProxyBox("")).toBeNull();
});
});