Skip to content

Commit

Permalink
fix rrweb canvas recording crash (#79)
Browse files Browse the repository at this point in the history
slow canvas loading can cause the canvas manager worker to crash.
also fix a merge conflict in rrweb styles file.
  • Loading branch information
Vadman97 authored Aug 2, 2022
1 parent 7c39523 commit 8168bc6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/rrweb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@highlight-run/rrweb",
"version": "2.0.17",
"version": "2.0.18",
"description": "record and replay the web",
"scripts": {
"prepare": "npm run prepack",
Expand Down
5 changes: 5 additions & 0 deletions packages/rrweb/src/record/observers/canvas/canvas-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ export class CanvasManager {
context?.clear(context.COLOR_BUFFER_BIT);
}
}
// canvas is not yet ready... this retry on the next sampling iteration.
// we don't want to crash the worker if the canvas is not yet rendered.
if (canvas.width === 0 || canvas.height === 0) {
return;
}
const bitmap = await createImageBitmap(canvas);
worker.postMessage(
{
Expand Down
1 change: 0 additions & 1 deletion packages/rrweb/src/replay/styles/inject-style.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const rules: (blockClass: string) => string[] = (blockClass: string) => [
`.${blockClass} { background: currentColor }`,
'noscript { display: none !important; }',
`.${blockClass} { background: currentColor; border-radius: 5px; }`,
`.${blockClass}:hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}`,
Expand Down
12 changes: 12 additions & 0 deletions packages/rrweb/src/replay/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,15 @@
height: 10px;
}
}

.rr-player {
position: relative;
background: white;
float: left;
border-radius: 5px;
box-shadow: 0 24px 48px rgba(17, 16, 62, 0.12);
}

.rr-player__frame {
overflow: hidden;
}

0 comments on commit 8168bc6

Please sign in to comment.