Skip to content

Commit 25062f0

Browse files
committed
fix(engine): an image outside the frame no longer stops a render
1 parent e842960 commit 25062f0

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎packages/engine/src/services/frameCapture.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,13 +2566,22 @@ export async function waitForShownLateImages(
25662566
);
25672567
const loaded = found.filter((img) => img.complete && img.naturalWidth > 0);
25682568
await Promise.allSettled(loaded.map((img) => img.decode()));
2569-
const box = (img: HTMLImageElement) => img.getBoundingClientRect();
2569+
const inViewport = (img: HTMLImageElement) => {
2570+
const box = img.getBoundingClientRect();
2571+
return (
2572+
box.width > 0 &&
2573+
box.height > 0 &&
2574+
box.right > 0 &&
2575+
box.bottom > 0 &&
2576+
box.left < window.innerWidth &&
2577+
box.top < window.innerHeight
2578+
);
2579+
};
25702580
const shown = found.filter(
25712581
(img) =>
25722582
!loaded.includes(img) &&
25732583
img.checkVisibility({ opacityProperty: true, visibilityProperty: true }) &&
2574-
box(img).width > 0 &&
2575-
box(img).height > 0,
2584+
inViewport(img),
25762585
);
25772586
return {
25782587
arrived: loaded.map((img) => img.src),

0 commit comments

Comments
 (0)