diff --git a/.changeset/healthy-glasses-shout.md b/.changeset/healthy-glasses-shout.md new file mode 100644 index 00000000..43a475d0 --- /dev/null +++ b/.changeset/healthy-glasses-shout.md @@ -0,0 +1,5 @@ +--- +"@rrweb/record": patch +--- + +Validate if WebGLRenderingContext exists before capturing it diff --git a/packages/rrweb/src/record/observers/canvas/webgl.ts b/packages/rrweb/src/record/observers/canvas/webgl.ts index 3c51323b..3a2bb362 100644 --- a/packages/rrweb/src/record/observers/canvas/webgl.ts +++ b/packages/rrweb/src/record/observers/canvas/webgl.ts @@ -95,16 +95,18 @@ export default function initCanvasWebGLMutationObserver( ): listenerHandler { const handlers: listenerHandler[] = []; - handlers.push( - ...patchGLPrototype( - win.WebGLRenderingContext.prototype, - CanvasContext.WebGL, - cb, - blockClass, - blockSelector, - win, - ), - ); + if (typeof win.WebGLRenderingContext !== 'undefined') { + handlers.push( + ...patchGLPrototype( + win.WebGLRenderingContext.prototype, + CanvasContext.WebGL, + cb, + blockClass, + blockSelector, + win, + ), + ); + } if (typeof win.WebGL2RenderingContext !== 'undefined') { handlers.push(