Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade rrweb to 2.0.0-alpha.12 #1115

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@rrweb/types": "2.0.0-alpha.11",
"@rrweb/types": "2.0.0-alpha.12",
"@sentry/types": "7.37.2",
"@testing-library/dom": "^9.3.0",
"@types/eslint": "^8.44.6",
Expand Down Expand Up @@ -86,8 +86,8 @@
"rollup": "^4.9.6",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-visualizer": "^5.12.0",
"rrweb": "2.0.0-alpha.11",
"rrweb-snapshot": "2.0.0-alpha.11",
"rrweb": "2.0.0-alpha.12",
"rrweb-snapshot": "2.0.0-alpha.12",
"sinon": "9.0.2",
"testcafe": "1.19.0",
"testcafe-browser-provider-browserstack": "1.14.0",
Expand All @@ -107,7 +107,7 @@
],
"pnpm": {
"patchedDependencies": {
"[email protected].11": "patches/[email protected].11.patch"
"[email protected].12": "patches/[email protected].12.patch"
}
}
}
69 changes: 69 additions & 0 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
diff --git a/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js b/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
index 8746997c9b849ac5c952fdbe0a8dd608d6680a3a..45c0076c7c36c75861cfc4234839ea621514cdff 100644
--- a/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
+++ b/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
@@ -91,11 +91,21 @@ class CanvasManager {
let rafId;
const getCanvas = () => {
const matchedCanvas = [];
- win.document.querySelectorAll('canvas').forEach((canvas) => {
- if (!isBlocked(canvas, blockClass, blockSelector, true)) {
- matchedCanvas.push(canvas);
- }
- });
+ const searchCanvas = (root) => {
+ root.querySelectorAll('canvas').forEach((canvas) => {
+ if (!isBlocked(canvas, blockClass, blockSelector, true)) {
+ matchedCanvas.push(canvas);
+ }
+ });
+ root.querySelectorAll('*').forEach((elem) => {
+ if (elem.shadowRoot) {
+ searchCanvas(elem.shadowRoot);
+ }
+ });
+ };
+
+ searchCanvas(win.document);
+
return matchedCanvas;
};
const takeCanvasSnapshots = (timestamp) => {
@@ -111,6 +121,12 @@ class CanvasManager {
const id = this.mirror.getId(canvas);
if (snapshotInProgressMap.get(id))
return;
+
+ // The browser throws if the canvas is 0 in size
+ // Uncaught (in promise) DOMException: Failed to execute 'createImageBitmap' on 'Window': The source image width is 0.
+ // Assuming the same happens with height
+ if (canvas.width === 0 || canvas.height === 0) return;
+
snapshotInProgressMap.set(id, true);
if (['webgl', 'webgl2'].includes(canvas.__context)) {
const context = canvas.getContext(canvas.__context);
@@ -118,12 +134,20 @@ class CanvasManager {
context.clear(context.COLOR_BUFFER_BIT);
}
}
- const bitmap = yield createImageBitmap(canvas);
- worker.postMessage({
+
+ const width = canvas.clientWidth;
+ const height = canvas.clientHeight;
+
+ const bitmap = yield createImageBitmap(canvas, {
+ resizeWidth: width,
+ resizeHeight: height
+ })
+
+ worker.postMessage({
daibhin marked this conversation as resolved.
Show resolved Hide resolved
id,
bitmap,
- width: canvas.width,
- height: canvas.height,
+ width: width,
+ height: height,
dataURLOptions: options.dataURLOptions,
}, [bitmap]);
}));
44 changes: 22 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading