Skip to content

fix(replay): Fix Compose masking on obfuscated/minified builds#5503

Merged
romtsn merged 3 commits into
mainfrom
rz/fix/compose-masking-obfuscated-builds
Jun 8, 2026
Merged

fix(replay): Fix Compose masking on obfuscated/minified builds#5503
romtsn merged 3 commits into
mainfrom
rz/fix/compose-masking-obfuscated-builds

Conversation

@romtsn
Copy link
Copy Markdown
Member

@romtsn romtsn commented Jun 5, 2026

📜 Description

Fixes Compose view masking on obfuscated/minified (R8) builds, plus adds a CI mechanism to catch such regressions early.

  • Masking fix: the SDK accesses internal Compose LayoutNode members to walk the node tree. On Compose < 1.10 these are looked up via reflection by their mangled names (getChildren$ui_release, getOuterCoordinator$ui_release, getCollapsedSemantics$ui_release). Since they aren't referenced directly, R8 could strip or rename them, silently breaking masking on minified builds. Added consumer proguard keep rules for them.
  • Fail-fast in CI: added an internal SentryReplayDebug.failFast switch (gated on the io.sentry.replay.compose.fail-fast system property) that re-throws the exceptions ComposeViewHierarchyNode normally swallows. It's enabled in the sample app and the on-device ReplayTest/ReplaySnapshotTest, so our release/obfuscated builds running on real devices in Sauce Labs crash instead of silently under-masking. Defaults off, so customers are unaffected.
  • Guard the on-device replay tests against GitHub-hosted emulators, which can't capture screenshots reliably.

💡 Motivation and Context

On obfuscated/minified builds, R8 could rename/strip the reflected Compose internals, which silently degraded or disabled Compose masking. Because the SDK swallows these errors to avoid crashing customer apps, the regression was invisible in our CI until now.

💚 How did you test it?

Unit tests + on-device ReplayTest/ReplaySnapshotTest running on release/obfuscated builds on real devices (Sauce Labs), which now fail fast if masking breaks.

Example replay: https://sentry-sdks.sentry.io/explore/replays/6783b073aef442a8b4ad8731bf6901fa

📝 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.

@sentry
Copy link
Copy Markdown

sentry Bot commented Jun 5, 2026

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@romtsn romtsn closed this Jun 5, 2026
@romtsn romtsn reopened this Jun 5, 2026
@romtsn romtsn force-pushed the rz/fix/compose-masking-obfuscated-builds branch 2 times, most recently from f48172d to b8d52cb Compare June 5, 2026 14:24
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 320.94 ms 371.50 ms 50.56 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
2387c2c 317.04 ms 354.60 ms 37.56 ms
91bb874 310.68 ms 359.24 ms 48.56 ms
cf708bd 408.35 ms 458.98 ms 50.63 ms
2195398 321.31 ms 391.66 ms 70.35 ms
e2dce0b 315.85 ms 369.20 ms 53.35 ms
991b33b 326.08 ms 397.82 ms 71.73 ms
4c04bb8 350.71 ms 413.63 ms 62.92 ms
3699cd5 423.60 ms 495.52 ms 71.92 ms
70118e9 380.00 ms 475.72 ms 95.72 ms
694d587 312.37 ms 402.77 ms 90.41 ms

App size

Revision Plain With Sentry Diff
2387c2c 1.58 MiB 2.13 MiB 559.54 KiB
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
cf708bd 1.58 MiB 2.11 MiB 539.71 KiB
2195398 0 B 0 B 0 B
e2dce0b 0 B 0 B 0 B
991b33b 0 B 0 B 0 B
4c04bb8 0 B 0 B 0 B
3699cd5 1.58 MiB 2.10 MiB 533.45 KiB
70118e9 1.58 MiB 2.29 MiB 719.84 KiB
694d587 1.58 MiB 2.19 MiB 620.06 KiB

Previous results on branch: rz/fix/compose-masking-obfuscated-builds

Startup times

Revision Plain With Sentry Diff
ea7fe98 313.04 ms 363.51 ms 50.47 ms
bd23040 313.90 ms 331.71 ms 17.81 ms

App size

Revision Plain With Sentry Diff
ea7fe98 0 B 0 B 0 B
bd23040 0 B 0 B 0 B

@romtsn romtsn force-pushed the rz/fix/compose-masking-obfuscated-builds branch 2 times, most recently from fffae5c to 9eb8255 Compare June 5, 2026 21:01
Add an internal SentryReplayDebug.failFast switch (gated on the
io.sentry.replay.compose.fail-fast system property) that re-throws the
exceptions ComposeViewHierarchyNode normally swallows in fromComposeNode
and fromView. Enabled in the sentry-samples-android app and the on-device
ReplayTest/ReplaySnapshotTest so our release/obfuscated builds running on
real devices in CI crash instead of silently degrading masking. Defaults
off, so customers are unaffected.

Also add consumer proguard keep rules for the LayoutNode internals
(getChildren/getOuterCoordinator/getCollapsedSemantics) that are looked up
via reflection on Compose < 1.10, so R8 doesn't strip or rename them.

Also guard the on-device tests against GitHub-hosted emulators, which
can't capture screenshots reliably.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@romtsn romtsn force-pushed the rz/fix/compose-masking-obfuscated-builds branch from 9eb8255 to bfc18bd Compare June 8, 2026 07:14
@romtsn romtsn changed the title try to run replay tests on gh emulators fix(replay): fix Compose masking on obfuscated/minified builds Jun 8, 2026
@romtsn romtsn changed the title fix(replay): fix Compose masking on obfuscated/minified builds fix(replay): Fix Compose masking on obfuscated/minified builds Jun 8, 2026
@romtsn romtsn marked this pull request as ready for review June 8, 2026 07:15
Copy link
Copy Markdown
Contributor

@runningcode runningcode left a comment

Choose a reason for hiding this comment

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

That's a good way to enhance our tests for this!

@romtsn romtsn merged commit abcd889 into main Jun 8, 2026
70 of 72 checks passed
@romtsn romtsn deleted the rz/fix/compose-masking-obfuscated-builds branch June 8, 2026 15:38
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