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:
Manoel Aranda Neto
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 169e10e94a
commit 8a93739766
2 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
'rrweb': patch
---
fix: createImageBitmap throws DOMException if source is 0 width or height

View File

@@ -184,6 +184,12 @@ export class CanvasManager {
.forEach(async (canvas: HTMLCanvasElement) => {
const id = this.mirror.getId(canvas);
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);
if (['webgl', 'webgl2'].includes((canvas as ICanvas).__context)) {
// if the canvas hasn't been modified recently,