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

fix: lastSnapshotTime is always 0 when using manual snapshots #239

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

c298lee
Copy link
Member

@c298lee c298lee commented Feb 11, 2025

When taking manual snapshots, the lastSnapshot time was resetting to 0, causing a snapshot to always be taken. This change moves lastSnapshotTime into the class and ensures that the fps is adhered to.

Fixes getsentry/sentry-javascript#15334

@c298lee c298lee requested a review from billyvg February 11, 2025 22:50
@c298lee c298lee changed the title fix: lastSnapshotTime is accurate when using manual snapshots fix: lastSnapshotTime is always 0 when using manual snapshots Feb 11, 2025
Copy link
Member

@billyvg billyvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there tests for manual snapshot?

Otherwise, code changes look good. Could improve the tests a bit

await waitForRAF(ctx.page);

// should yield a frame for only first change because it's only 5 fps
assertSnapshot(stripBase64(ctx.events));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a snapshot I would use an assertion that we only have 1 canvas mutation frame so that the check is very explicit (snapshot changes are easily ignored).

I would also add additional timeouts so that we know it continues to work.

@@ -394,7 +396,6 @@ export class CanvasManager implements CanvasManagerInterface {
canvasElement?: HTMLCanvasElement,
) {
const timeBetweenSnapshots = 1000 / fps;
let lastSnapshotTime = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subtle, i guess when it's called more than once (user is interacting with the page? or no... when our mobile replays are loading we can play/pause really quickly!) it gets cleared out and the new set of closures start at 0 again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we recommend putting the snapshot function in the paint loop, so everytime it was repainted, it would be reset to 0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@c298lee
Copy link
Member Author

c298lee commented Feb 18, 2025

Merging this without manual snapshot tests since we want to fix this bug sooner, will add tests in a followup PR

@c298lee c298lee merged commit 579a355 into sentry-v2 Feb 18, 2025
11 checks passed
@c298lee c298lee deleted the cl/fix-snapshot-fps branch February 18, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Replay Canvas] Quality not followed when manually snapshotting canvas
3 participants