Skip to content

Commit

Permalink
fix: createImageBitmap throws DOMException if source is 0 (#1422)
Browse files Browse the repository at this point in the history
* fix: createImageBitmap throws DOMException if source is 0

* code review

* fix

* Create breezy-cats-heal.md

* fix format

---------

Co-authored-by: Justin Halsall <[email protected]>
  • Loading branch information
marandaneto and Juice10 authored Apr 5, 2024
1 parent e223399 commit 3d1877c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-cats-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

fix: createImageBitmap throws DOMException if source is 0 width or height
6 changes: 6 additions & 0 deletions packages/rrweb/src/record/observers/canvas/canvas-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3d1877c

Please sign in to comment.