Skip to content

Conversation

@romtsn
Copy link
Member

@romtsn romtsn commented Oct 23, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds new screenshotStrategy option which only applies to Android targets. Here's a docs PR for Android which explains both strategies better.

An example replay from the sample app: https://sentry-sdks.sentry.io/explore/replays/33ea588853ad4d0fa070424728b3f701/

💡 Motivation and Context

Better masking

Closes #5300

💚 How did you test it?

Sample app + we extensively tested it with BlueSky

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

Add docs

@github-actions
Copy link
Contributor

github-actions bot commented Oct 23, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against a648626

@github-actions
Copy link
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 383.54 ms 442.32 ms 58.78 ms
Size 17.75 MiB 19.74 MiB 1.99 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
3bd3f0d+dirty 447.21 ms 472.31 ms 25.10 ms
46da307 455.92 ms 443.79 ms -12.13 ms
083f560+dirty 358.21 ms 382.00 ms 23.79 ms
59f3a84+dirty 382.16 ms 376.45 ms -5.71 ms
69602ce 417.47 ms 443.52 ms 26.05 ms
5526494 440.84 ms 448.36 ms 7.52 ms
6a70a7e+dirty 381.72 ms 413.94 ms 32.22 ms
77061ed+dirty 369.55 ms 408.35 ms 38.80 ms
07808fb+dirty 419.10 ms 419.08 ms -0.02 ms
000da7a 454.46 ms 445.00 ms -9.46 ms

App size

Revision Plain With Sentry Diff
3bd3f0d+dirty 17.75 MiB 19.70 MiB 1.95 MiB
46da307 17.75 MiB 19.68 MiB 1.93 MiB
083f560+dirty 17.75 MiB 19.70 MiB 1.96 MiB
59f3a84+dirty 17.75 MiB 19.70 MiB 1.95 MiB
69602ce 17.75 MiB 19.68 MiB 1.94 MiB
5526494 17.75 MiB 19.68 MiB 1.93 MiB
6a70a7e+dirty 17.75 MiB 19.69 MiB 1.94 MiB
77061ed+dirty 17.75 MiB 19.68 MiB 1.94 MiB
07808fb+dirty 17.75 MiB 19.70 MiB 1.95 MiB
000da7a 17.75 MiB 19.68 MiB 1.94 MiB

@github-actions
Copy link
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 318.25 ms 354.94 ms 36.69 ms
Size 7.15 MiB 8.46 MiB 1.30 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
3bd3f0d+dirty 334.38 ms 402.19 ms 67.81 ms
083f560+dirty 383.96 ms 417.76 ms 33.80 ms
59f3a84+dirty 359.69 ms 407.54 ms 47.86 ms
6a70a7e+dirty 382.45 ms 424.54 ms 42.09 ms
77061ed+dirty 359.40 ms 424.10 ms 64.70 ms
07808fb+dirty 392.47 ms 451.94 ms 59.47 ms
000da7a+dirty 347.89 ms 381.98 ms 34.09 ms
785ffb1+dirty 380.65 ms 451.83 ms 71.18 ms
90afdd3+dirty 367.79 ms 404.84 ms 37.05 ms
c1573b3+dirty 355.65 ms 448.82 ms 93.17 ms

App size

Revision Plain With Sentry Diff
3bd3f0d+dirty 7.15 MiB 8.43 MiB 1.28 MiB
083f560+dirty 7.15 MiB 8.43 MiB 1.28 MiB
59f3a84+dirty 7.15 MiB 8.43 MiB 1.28 MiB
6a70a7e+dirty 7.15 MiB 8.42 MiB 1.26 MiB
77061ed+dirty 7.15 MiB 8.41 MiB 1.26 MiB
07808fb+dirty 7.15 MiB 8.43 MiB 1.28 MiB
000da7a+dirty 7.15 MiB 8.41 MiB 1.26 MiB
785ffb1+dirty 7.15 MiB 8.42 MiB 1.27 MiB
90afdd3+dirty 7.15 MiB 8.43 MiB 1.28 MiB
c1573b3+dirty 7.15 MiB 8.42 MiB 1.27 MiB

@github-actions
Copy link
Contributor

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1235.52 ms 1241.49 ms 5.97 ms
Size 2.63 MiB 4.00 MiB 1.37 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
90edad7+dirty 1222.08 ms 1228.40 ms 6.32 ms
20d5eaa+dirty 1231.12 ms 1226.00 ms -5.12 ms
8490686+dirty 1227.84 ms 1228.91 ms 1.08 ms
f70acbf+dirty 1235.71 ms 1243.14 ms 7.43 ms
5ee3314+dirty 1215.18 ms 1207.64 ms -7.54 ms
98f632c+dirty 1236.40 ms 1241.62 ms 5.22 ms
bc9680d+dirty 1221.41 ms 1241.47 ms 20.06 ms
3099014+dirty 1226.75 ms 1236.56 ms 9.81 ms
a31630c+dirty 1229.09 ms 1230.94 ms 1.85 ms
8db9631+dirty 1223.60 ms 1224.56 ms 0.96 ms

App size

Revision Plain With Sentry Diff
90edad7+dirty 2.63 MiB 4.00 MiB 1.36 MiB
20d5eaa+dirty 2.63 MiB 3.81 MiB 1.18 MiB
8490686+dirty 2.63 MiB 4.00 MiB 1.36 MiB
f70acbf+dirty 2.63 MiB 3.98 MiB 1.34 MiB
5ee3314+dirty 2.63 MiB 3.99 MiB 1.35 MiB
98f632c+dirty 2.63 MiB 3.81 MiB 1.18 MiB
bc9680d+dirty 2.63 MiB 3.81 MiB 1.18 MiB
3099014+dirty 2.63 MiB 3.98 MiB 1.35 MiB
a31630c+dirty 2.63 MiB 3.98 MiB 1.34 MiB
8db9631+dirty 2.63 MiB 4.00 MiB 1.36 MiB

@github-actions
Copy link
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1219.49 ms 1241.56 ms 22.07 ms
Size 3.19 MiB 4.57 MiB 1.38 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
90edad7+dirty 1235.21 ms 1241.45 ms 6.24 ms
20d5eaa+dirty 1224.67 ms 1223.16 ms -1.51 ms
8490686+dirty 1227.32 ms 1240.82 ms 13.50 ms
f70acbf+dirty 1239.00 ms 1242.53 ms 3.53 ms
5ee3314+dirty 1234.25 ms 1235.44 ms 1.19 ms
98f632c+dirty 1221.38 ms 1229.26 ms 7.88 ms
bc9680d+dirty 1228.57 ms 1233.64 ms 5.07 ms
3099014+dirty 1234.04 ms 1243.22 ms 9.18 ms
a31630c+dirty 1241.32 ms 1226.98 ms -14.34 ms
8db9631+dirty 1226.92 ms 1226.06 ms -0.85 ms

App size

Revision Plain With Sentry Diff
90edad7+dirty 3.19 MiB 4.56 MiB 1.38 MiB
20d5eaa+dirty 3.19 MiB 4.38 MiB 1.19 MiB
8490686+dirty 3.19 MiB 4.56 MiB 1.38 MiB
f70acbf+dirty 3.19 MiB 4.54 MiB 1.36 MiB
5ee3314+dirty 3.19 MiB 4.55 MiB 1.37 MiB
98f632c+dirty 3.19 MiB 4.38 MiB 1.19 MiB
bc9680d+dirty 3.19 MiB 4.38 MiB 1.19 MiB
3099014+dirty 3.19 MiB 4.55 MiB 1.36 MiB
a31630c+dirty 3.19 MiB 4.54 MiB 1.36 MiB
8db9631+dirty 3.19 MiB 4.56 MiB 1.38 MiB

* - Experiment: In case you are noticing issues with the canvas screenshot strategy, please report the issue on [GitHub](https://github.com/getsentry/sentry-java).
*
* @default 'pixelCopy'
* @platform android
Copy link
Collaborator

Choose a reason for hiding this comment

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

@alwx @antonis What do you think of updating other platform specific options with @platform?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's a good idea 👍

enableExperimentalViewRenderer: false,
enableViewRendererV2: true,
enableFastViewRendering: false,
screenshotStrategy: 'pixelCopy',
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be worth on a major change to default it to canvas if sendDefaultPii is not true.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah we'll monitor the adoption and possibly make it a default in the future

return ScreenshotStrategyType.PIXEL_COPY;
}

try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

q: why the try/catch block here?

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 just followed the pattern for quality, but can remove it

Copy link
Contributor

@antonis antonis Oct 24, 2025

Choose a reason for hiding this comment

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

I don't recall why I added the try/catch block for quality 😓
I probably followed an existing pattern or modified the code from a state that it was needed. I think it is not needed and opened #5305 to fix that.

@lucas-zimerman
Copy link
Collaborator

Thank you for the PR!

Copy link
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

LGTM 🚀
Thank you for adding this Roman 🙇

Comment on lines +437 to +446
try {
switch (strategyString.toLowerCase(Locale.ROOT)) {
case "canvas":
return ScreenshotStrategyType.CANVAS;
default:
return ScreenshotStrategyType.PIXEL_COPY;
}
} catch (Exception e) {
return ScreenshotStrategyType.PIXEL_COPY;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Following up on https://github.com/getsentry/sentry-react-native/pull/5301/files#r2461084612

Suggested change
try {
switch (strategyString.toLowerCase(Locale.ROOT)) {
case "canvas":
return ScreenshotStrategyType.CANVAS;
default:
return ScreenshotStrategyType.PIXEL_COPY;
}
} catch (Exception e) {
return ScreenshotStrategyType.PIXEL_COPY;
}
switch (strategyString.toLowerCase(Locale.ROOT)) {
case "canvas":
return ScreenshotStrategyType.CANVAS;
default:
return ScreenshotStrategyType.PIXEL_COPY;
}

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.

Expose new experimental Canvas Capture Strategy on Android

3 participants