fix: createImageBitmap throws DOMException if source is 0 (#1422)
* fix: createImageBitmap throws DOMException if source is 0 * code review * fix * Create breezy-cats-heal.md * fix format --------- Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
e223399c7c
commit
3d1877cff8
5
.changeset/breezy-cats-heal.md
Normal file
5
.changeset/breezy-cats-heal.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'rrweb': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: createImageBitmap throws DOMException if source is 0 width or height
|
||||||
@@ -184,6 +184,12 @@ export class CanvasManager {
|
|||||||
.forEach(async (canvas: HTMLCanvasElement) => {
|
.forEach(async (canvas: HTMLCanvasElement) => {
|
||||||
const id = this.mirror.getId(canvas);
|
const id = this.mirror.getId(canvas);
|
||||||
if (snapshotInProgressMap.get(id)) return;
|
if (snapshotInProgressMap.get(id)) return;
|
||||||
|
|
||||||
|
// The browser throws if the canvas is 0 in size
|
||||||
|
// Uncaught (in promise) DOMException: Failed to execute 'createImageBitmap' on 'Window': The source image width is 0.
|
||||||
|
// Assuming the same happens with height
|
||||||
|
if (canvas.width === 0 || canvas.height === 0) return;
|
||||||
|
|
||||||
snapshotInProgressMap.set(id, true);
|
snapshotInProgressMap.set(id, true);
|
||||||
if (['webgl', 'webgl2'].includes((canvas as ICanvas).__context)) {
|
if (['webgl', 'webgl2'].includes((canvas as ICanvas).__context)) {
|
||||||
// if the canvas hasn't been modified recently,
|
// if the canvas hasn't been modified recently,
|
||||||
|
|||||||
Reference in New Issue
Block a user