Skip to content

Conversation

@billyvg
Copy link
Member

@billyvg billyvg commented Aug 7, 2025

Adds an option to snapshot() to skip rAF. This should fix some cases where manual snapshots were not able to capture the canvas buffer.

Also cleans up the code a bit and fixes the initCanvasFPSObserver so we can properly clean-up the recording loop.

Changes `snapshot()` to skip rAF. This should fix some cases where manual snapshots were not able to capture the canvas buffer.

Cleaned up the code a bit and fixes the `initCanvasFPSObserver` so we can properly clean-up the recording loop.
@linear
Copy link

linear bot commented Aug 7, 2025

@billyvg billyvg changed the title fix(replay): Manual snapshots skip rAF feat(replay): Manual snapshots can skip rAF Aug 7, 2025
});
}

public snapshot(canvasElement?: HTMLCanvasElement) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved so its grouped with the other public methods.

rafId = onRequestAnimationFrame(rafCallback);

this.restoreHandlers.push(() => {
cancelAnimationFrame(rafId);
Copy link
Member Author

Choose a reason for hiding this comment

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

This didn't work as expected since takeSnapshot() loops on itself and this rafId is only for the first call.

Comment on lines 377 to 381
private getCanvasElements(
blockClass?: blockClass,
blockSelector?: string | null,
unblockSelector?: string | null,
): HTMLCanvasElement[] {
Copy link
Member Author

Choose a reason for hiding this comment

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

Extracted from inside of takeSnapshot

@billyvg billyvg marked this pull request as ready for review August 7, 2025 18:42
@billyvg billyvg requested a review from a team August 7, 2025 18:42
@billyvg billyvg merged commit 859c0c2 into sentry-v2 Aug 12, 2025
17 checks passed
@billyvg billyvg deleted the billy/js-829-replay-manual-snapshot-results-in-blank-or-missing-frames-in branch August 12, 2025 16:53
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.

3 participants