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

feat(canvas): Add "maxCanvasSize" option for canvas #174

Merged
merged 8 commits into from
Apr 15, 2024

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented Apr 11, 2024

This adds a configuration option to set a max size for canvas snapshots. This will scale down canvas snapshot images if they are larger than the configure size limit. The size configuration is width * height.

This adds a configuration option to set a max size for canvas snapshots. This will scale down canvas snapshot images if they are larger than the configure size limit. The size configuration is width * height.
@billyvg billyvg marked this pull request as ready for review April 11, 2024 21:11
@billyvg billyvg changed the title feat(canvas): Add "maxSize" option for canvas feat(canvas): Add "maxCanvasSize" option for canvas Apr 11, 2024
Copy link

github-actions bot commented Apr 11, 2024

size-limit report 📦

Path Size
rrweb - record only (gzipped) 16.77 KB (+0.1% 🔺)
rrweb - record & CanvasManager only (gzipped) 19.58 KB (+0.85% 🔺)
rrweb - record only (min) 57.2 KB (+0.11% 🔺)
rrweb - record with treeshaking flags (gzipped) 15.56 KB (+0.12% 🔺)

@billyvg billyvg requested a review from a team April 11, 2024 21:20
const resizedBitmap =
targetWidth === width && targetHeight === height
? bitmap
: // resize bitmap to fit within maxsize
Copy link
Member

Choose a reason for hiding this comment

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

what will happen if this is not supported? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure tbh, it could throw or it could ignore the options.

Copy link
Member Author

Choose a reason for hiding this comment

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

My previous commit did the resizing manually with drawImage(), but I'd rather use the builtin since it's pretty well-supported. I think throwing and not capturing exceptions and in the other case, if it doesn't throw and just ignores the options and captures the original size, are both acceptable outcomes.

I'm going to merge as-is, but let me know what you think and I can follow-up.

billyvg added a commit to getsentry/sentry-javascript that referenced this pull request Apr 15, 2024
We do not want to allow users to capture super large canvases, enforce a max size limit

Requires getsentry/rrweb#174
billyvg added a commit to getsentry/sentry-javascript that referenced this pull request Apr 15, 2024
We do not want to allow users to capture super large canvases, enforce a max size limit

Requires getsentry/rrweb#174
@billyvg billyvg merged commit 2c114ec into sentry-v2 Apr 15, 2024
14 checks passed
@billyvg billyvg deleted the feat-canvas-add-max-size-for-canvas branch April 15, 2024 18:49
billyvg added a commit to getsentry/sentry-javascript that referenced this pull request Apr 18, 2024
We do not want to allow users to capture super large canvases, enforce a max size limit

Requires getsentry/rrweb#174
billyvg added a commit to getsentry/sentry-javascript that referenced this pull request Apr 19, 2024
We do not want to allow users to capture super large canvases, enforce a max size limit

Requires getsentry/rrweb#174
billyvg added a commit to getsentry/sentry-javascript that referenced this pull request Apr 22, 2024
We do not want to allow users to capture super large canvases, enforce a
max size limit

Requires getsentry/rrweb#174

Closes #10498
billyvg added a commit to getsentry/sentry-javascript that referenced this pull request Apr 22, 2024
We do not want to allow users to capture super large canvases, enforce a
max size limit

Requires getsentry/rrweb#174
Closes #10498
Backport of #11617
mydea pushed a commit to getsentry/sentry-javascript that referenced this pull request Apr 23, 2024
We do not want to allow users to capture super large canvases, enforce a
max size limit

Requires getsentry/rrweb#174
Closes #10498
Backport of #11617
billyvg added a commit that referenced this pull request Apr 26, 2024
This adds a configuration option to set a max size for canvas snapshots.
This will scale down canvas snapshot images if they are larger than the
configure size limit. The size configuration is width * height.
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