Skip to content

Commit 8eaace6

Browse files
committed
fix(studio): stop capping filmstrip render tiles at 33
computeThumbnailStrip no longer clamps frameCount; the decode-side cap already lives in quantizeThumbnailFrameCount. VideoThumbnail only acquires the rich filmstrip lease when requestFrameCount > 1, so a narrow clip issues one decode job instead of two identical ones. Deletes the unreachable duplicate defaults in createVideoThumbnailRequest.
1 parent 77de376 commit 8eaace6

4 files changed

Lines changed: 23 additions & 26 deletions

File tree

‎packages/studio/src/player/components/VideoThumbnail.test.tsx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ describe("VideoThumbnail", () => {
8686
expect(host.querySelectorAll("img").length).toBeGreaterThan(0);
8787
});
8888

89+
it("issues a single decode job for a narrow clip", async () => {
90+
vi.mocked(decodeVideoThumbnail).mockResolvedValue({
91+
value: { kind: "image", url: "blob:poster", aspect: 16 / 9 },
92+
weight: 128,
93+
});
94+
95+
await render(100);
96+
97+
expect(decodeVideoThumbnail).toHaveBeenCalledTimes(1);
98+
});
99+
89100
it("clears the loading shimmer when the scheduled decode fails", async () => {
90101
vi.mocked(decodeVideoThumbnail).mockRejectedValue(new Error("decode failed"));
91102

‎packages/studio/src/player/components/VideoThumbnail.tsx‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,13 @@ interface VideoThumbnailProps {
2626
}
2727

2828
function createVideoThumbnailRequest(
29-
props: Pick<
30-
VideoThumbnailProps,
31-
| "videoSrc"
32-
| "sourceStart"
33-
| "sourceRangeDuration"
34-
| "duration"
35-
| "projectId"
36-
| "sessionEpoch"
37-
| "priority"
38-
>,
29+
props: Pick<VideoThumbnailProps, "videoSrc" | "sourceStart" | "sourceRangeDuration"> &
30+
Required<Pick<VideoThumbnailProps, "duration" | "projectId" | "sessionEpoch" | "priority">>,
3931
frameCount: number,
4032
rich: boolean,
4133
) {
42-
const {
43-
videoSrc,
44-
sourceStart,
45-
sourceRangeDuration,
46-
duration = 5,
47-
projectId = videoSrc,
48-
sessionEpoch = 0,
49-
priority = "visible",
50-
} = props;
34+
const { videoSrc, sourceStart, sourceRangeDuration, duration, projectId, sessionEpoch, priority } =
35+
props;
5136
return {
5237
key: createThumbnailKey({
5338
kind: "video",
@@ -124,7 +109,7 @@ export const VideoThumbnail = memo(function VideoThumbnail({
124109
);
125110
const measured = containerWidth > 0;
126111
const posterSnapshot = useThumbnailLease(measured ? posterRequest : null);
127-
const richSnapshot = useThumbnailLease(measured ? richRequest : null);
112+
const richSnapshot = useThumbnailLease(measured && requestFrameCount > 1 ? richRequest : null);
128113
const snapshot = selectThumbnailSnapshot(posterSnapshot, richSnapshot);
129114
const value = snapshot.status === "ready" ? snapshot.value : null;
130115
const urls =

‎packages/studio/src/player/components/thumbnailUtils.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ describe("computeThumbnailStrip", () => {
2020
expect(frameCount * frameW).toBeGreaterThanOrEqual(500);
2121
});
2222

23-
it("caps rendered tiles at the shared visible-frame budget", () => {
24-
expect(computeThumbnailStrip(10_000, 1).frameCount).toBe(33);
23+
it("paints tiles across the full clip past the shared visible-frame budget", () => {
24+
expect(computeThumbnailStrip(14_400, 16 / 9).frameCount).toBeGreaterThan(33);
2525
});
2626

2727
it("returns one tile when the container width is unknown", () => {
@@ -61,6 +61,10 @@ describe("quantizeThumbnailFrameCount", () => {
6161
expect(quantizeThumbnailFrameCount(32)).toBe(32);
6262
expect(quantizeThumbnailFrameCount(34)).toBe(33);
6363
});
64+
65+
it("caps decode requests at the shared visible-frame budget", () => {
66+
expect(quantizeThumbnailFrameCount(124)).toBe(33);
67+
});
6468
});
6569

6670
describe("resolveMediaPreviewUrl", () => {

‎packages/studio/src/player/components/thumbnailUtils.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ export function computeThumbnailStrip(
7575
): ThumbnailStripLayout {
7676
const safeAspect = Number.isFinite(aspect) && aspect > 0 ? aspect : 16 / 9;
7777
const frameW = Math.max(minFrameWidth, Math.round(clipHeight * safeAspect));
78-
const frameCount =
79-
containerWidth > 0
80-
? Math.min(MAX_VISIBLE_THUMBNAIL_FRAMES, Math.max(1, Math.ceil(containerWidth / frameW)))
81-
: 1;
78+
const frameCount = containerWidth > 0 ? Math.max(1, Math.ceil(containerWidth / frameW)) : 1;
8279
return { frameW, frameCount };
8380
}
8481

0 commit comments

Comments
 (0)