Skip to content

feat(android): Mask screenshots by default - #6437

Merged
runningcode merged 4 commits into
9.x.xfrom
no/screenshot-masking-default
Nov 9, 2026
Merged

runningcode merged 4 commits into
9.x.xfrom
no/screenshot-masking-default

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

Error screenshots and user feedback screenshots now mask all text and images by default, matching Session Replay.

  • SentryScreenshotOptions turns on maskAllText and maskAllImages in its constructor. maskAllImages also masks WebView, VideoView and the media player views.
  • ManifestMetadataReader used to set both options to false when io.sentry.screenshot.mask-all-text and io.sentry.screenshot.mask-all-images were missing, which would have undone the new default. It now defaults them to true, like the session replay keys.

Opt out with options.screenshot.setMaskAllText(false) / setMaskAllImages(false), or the manifest keys above set to false.

Note: masking needs sentry-android-replay at runtime. If masking is configured and the replay module is missing, ScreenshotEventProcessor skips the screenshot instead of attaching an unmasked one. sentry-android includes replay, so this only affects apps that depend on sentry-android-core directly and use attachScreenshot. Those apps now get no screenshot until they add sentry-android-replay or turn masking off.

💡 Motivation and Context

Screenshots can contain PII. Masking by default makes the safe choice the default, as on iOS.

💚 How did you test it?

  • Updated unit tests for SentryScreenshotOptions and ManifestMetadataReader
  • sentry-android-core screenshot, feedback and manifest unit tests

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the 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.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

  • Update the screenshot docs to describe masking, similar to iOS

@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

JAVA-502

@github-actions

github-actions Bot commented Oct 30, 2026 •

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

Generated by 🚫 dangerJS against 4becdf2

@sentry

sentry Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.63.0 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode
runningcode marked this pull request as ready for review October 30, 2026 12:18
@runningcode runningcode added the next-major This should only be merged in the next major version. label Oct 30, 2026
* #setMaskAllText(boolean)} and/or {@link #setMaskAllImages(boolean)} with {@code false}.
*
* <p>Note: Screenshot masking requires the {@code sentry-android-replay} module to be present at
* runtime. If masking is enabled but the replay module is not available, no screenshot is captured

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh, wait this is a deal-breaker, right? Basically whoever is not using replay now, will stop getting screenshots once they bump to v9 🙈

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah I see we mention in the changelog... On a second thought it's probably fine, that's why it goes into a new major. So customers would have to explicitly "opt-in" for screenshots without masking.

Junior estimated around 30-40 orgs that would stop receiving screenshots in v9 because of this, which is fine given we'll have the migration guide I think.

What do you think of maybe logging the warning with a options.getFatalLogger() to bypass the options.debug flag in ScreenshotUtils:89 when we found such misconfiguration (masking on, but no replay module)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will do!

@romtsn romtsn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving, but left one suggestion which I think is worth doing (changing the logger in ScreenshotUtils)

@runningcode
runningcode requested a review from a team as a code owner November 6, 2026 15:02
runningcode and others added 3 commits November 6, 2026 16:04
Error and user feedback screenshots now mask all text and images by
default, matching Session Replay. The manifest reader defaulted the
screenshot masking keys to false, which would have undone the new
default, so it now defaults them to true like the replay keys.

Masking needs sentry-android-replay at runtime. Apps that depend on
sentry-android-core alone and attach screenshots now get no screenshot
until they add the replay module or turn masking off.

Refs JAVA-502
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/screenshot-masking-default branch from c72358a to 8ba018e Compare November 6, 2026 15:05

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8ba018e. Configure here.

ScreenshotEventProcessor checks for the missing replay module itself and
returns before captureMaskedScreenshot, so the warning was still gated on
options.debug for native errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode merged commit 722bd53 into 9.x.x Nov 9, 2026
38 of 39 checks passed
@runningcode
runningcode deleted the no/screenshot-masking-default branch November 9, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next-major This should only be merged in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants