fix: Validate if WebGLRenderingContext exists before capturing it (#1777)

* Update webgl.ts

---------

Co-authored-by: Paul D'Ambra <paul.dambra@gmail.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
This commit is contained in:
Christopher Arredondo
2026-02-06 06:04:09 -03:00
committed by GitHub
parent 0fe7dfb0e1
commit 3b8daa6034
2 changed files with 17 additions and 10 deletions

View File

@@ -0,0 +1,5 @@
---
"@rrweb/record": patch
---
Validate if WebGLRenderingContext exists before capturing it

View File

@@ -95,6 +95,7 @@ export default function initCanvasWebGLMutationObserver(
): listenerHandler {
const handlers: listenerHandler[] = [];
if (typeof win.WebGLRenderingContext !== 'undefined') {
handlers.push(
...patchGLPrototype(
win.WebGLRenderingContext.prototype,
@@ -105,6 +106,7 @@ export default function initCanvasWebGLMutationObserver(
win,
),
);
}
if (typeof win.WebGL2RenderingContext !== 'undefined') {
handlers.push(