Skip to content

Commit 45b019b

Browse files
authored
Merge pull request #4009 from Tyriar/vscode157444
Ensure canvas device dims are > 0x0 when firing callback
2 parents c021571 + 81a6230 commit 45b019b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/browser/renderer/DevicePixelObserver.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ export function observeDevicePixelDimensions(element: HTMLElement, callback: (de
2424
return;
2525
}
2626

27-
callback(
28-
entry.devicePixelContentBoxSize[0].inlineSize,
29-
entry.devicePixelContentBoxSize[0].blockSize
30-
);
27+
// Fire the callback, ignore events where the dimensions are 0x0 as the canvas is likely hidden
28+
const width = entry.devicePixelContentBoxSize[0].inlineSize;
29+
const height = entry.devicePixelContentBoxSize[0].blockSize;
30+
if (width > 0 && height > 0) {
31+
callback(width, height);
32+
}
3133
});
3234
observer.observe(element, { box: ['device-pixel-content-box'] } as any);
3335
return toDisposable(() => observer?.disconnect());

0 commit comments

Comments
 (0)