Skip to content

Commit

Permalink
fix: createImageBitmap throws DOMException if source is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto committed Mar 7, 2024
1 parent e607e83 commit 5d7b575
Showing 1 changed file with 6 additions and 0 deletions.
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 @@ -207,6 +207,12 @@ export class CanvasManager {
context.clear(context.COLOR_BUFFER_BIT);
}
}

// 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;

const bitmap = await createImageBitmap(canvas);
worker.postMessage(
{
Expand Down

0 comments on commit 5d7b575

Please sign in to comment.