From a6dcc180e2ab0fccc9280f59ae5f92eef39be426 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Fri, 7 Oct 2022 15:28:25 +0100 Subject: [PATCH 1/2] `isContextLost` is particularly noisy, being called almost constantly by e.g. Figma to check whether there's a need to re initialize a canvas Juice10: We could perhaps look at https://github.com/microsoft/TypeScript/blob/5cd49f6cbcd2effe9d425dee3a39cb49209bb656/lib/lib.dom.d.ts#L14578 via https://stackoverflow.com/questions/60150251/how-to-import-an-interface-from-lib-dom-d-ts --- packages/rrweb/src/record/observers/canvas/webgl.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/rrweb/src/record/observers/canvas/webgl.ts b/packages/rrweb/src/record/observers/canvas/webgl.ts index f3397d76a9..64e7bf669e 100644 --- a/packages/rrweb/src/record/observers/canvas/webgl.ts +++ b/packages/rrweb/src/record/observers/canvas/webgl.ts @@ -24,6 +24,12 @@ function patchGLPrototype( const props = Object.getOwnPropertyNames(prototype); for (const prop of props) { + if ( + //prop.startsWith('get') || // e.g. getProgramParameter, but too risky + ['isContextLost', 'canvas', 'drawingBufferWidth', 'drawingBufferHeight'].includes(prop)) { + // skip read only propery/functions + continue; + } try { if (typeof prototype[prop as keyof typeof prototype] !== 'function') { continue; From 3083cff7e7d1e4e177bc2bb4713313dbdf3c58ae Mon Sep 17 00:00:00 2001 From: eoghanmurray Date: Fri, 7 Oct 2022 14:31:20 +0000 Subject: [PATCH 2/2] Apply formatting changes --- packages/rrweb/src/record/observers/canvas/webgl.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/rrweb/src/record/observers/canvas/webgl.ts b/packages/rrweb/src/record/observers/canvas/webgl.ts index 64e7bf669e..9e8bfbf468 100644 --- a/packages/rrweb/src/record/observers/canvas/webgl.ts +++ b/packages/rrweb/src/record/observers/canvas/webgl.ts @@ -26,7 +26,13 @@ function patchGLPrototype( for (const prop of props) { if ( //prop.startsWith('get') || // e.g. getProgramParameter, but too risky - ['isContextLost', 'canvas', 'drawingBufferWidth', 'drawingBufferHeight'].includes(prop)) { + [ + 'isContextLost', + 'canvas', + 'drawingBufferWidth', + 'drawingBufferHeight', + ].includes(prop) + ) { // skip read only propery/functions continue; }