Skip to content

Commit

Permalink
fix: manual snapshot in rAF loop (#210)
Browse files Browse the repository at this point in the history
## Background

I followed [Set Up Session Replay | Sentry for
Javascript](https://docs.sentry.io/platforms/javascript/session-replay/#3d-and-webgl-canvases)
and got CPU high usage.

![CleanShot-2024-07-10-at-15 22
35@2x](https://github.com/getsentry/rrweb/assets/1590707/c20f51de-716f-43b5-a1f2-6ce4fab4d9d3)


## Solution

The takeCanvasSnapshots should not be in rAF loop when the
`isManualSnapshot` is true. I also checked the
[rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.ts at
master ·
rrweb-io/rrweb](https://github.com/rrweb-io/rrweb/blob/master/packages/rrweb/src/record/observers/canvas/canvas-manager.ts#L172)
and confirmed it's Sentry customized logic.

Co-authored-by: Billy Vong <[email protected]>
  • Loading branch information
ShinyChang and billyvg authored Aug 15, 2024
1 parent 62093d4 commit 781b2a1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/rrweb/src/record/observers/canvas/canvas-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,10 @@ export class CanvasManager implements CanvasManagerInterface {
})();
});
});
rafId = onRequestAnimationFrame(takeCanvasSnapshots);

if (!isManualSnapshot) {
rafId = onRequestAnimationFrame(takeCanvasSnapshots);
}
};

rafId = onRequestAnimationFrame(takeCanvasSnapshots);
Expand Down

0 comments on commit 781b2a1

Please sign in to comment.