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-04-01 12:00:00 +08:00
committed by GitHub
parent 42c203d24f
commit 8df3133af5
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(