Skip to content

Commit 626539e

Browse files
fix(replays): Handle non-canvas elements and toDataURL errors in canvas replayer
1 parent bbdeeff commit 626539e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

static/app/components/replays/canvasReplayerPlugin.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ export function CanvasReplayerPlugin(events: eventWithTime[]): ReplayPlugin {
174174
* written to when replay is being played.
175175
*/
176176
function cloneCanvas(id: number, node: HTMLCanvasElement) {
177+
if (!(node instanceof HTMLCanvasElement)) {
178+
return null;
179+
}
177180
const cloneNode = node.cloneNode() as HTMLCanvasElement;
178181
canvases.set(id, cloneNode);
179182
document.adoptNode(cloneNode);
@@ -286,7 +289,9 @@ export function CanvasReplayerPlugin(events: eventWithTime[]): ReplayPlugin {
286289

287290
const img = containers.get(e.data.id);
288291
if (img) {
289-
img.src = target.toDataURL();
292+
if (target instanceof HTMLCanvasElement) {
293+
img.src = target.toDataURL();
294+
}
290295
img.style.maxWidth = '100%';
291296
img.style.maxHeight = '100%';
292297
}

0 commit comments

Comments
 (0)