File tree Expand file tree Collapse file tree
sentry-android-integration-tests/sentry-uitest-android/src
androidTestReplay/java/io/sentry/uitest/android
androidTest/java/io/sentry/uitest/android
sentry-android-replay/src/main/java/io/sentry/android/replay
sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ class ReplayTest : BaseUiTest() {
2121 // we can't run on GH actions emulator, because they don't allow capturing screenshots properly
2222 @Suppress(" KotlinConstantConditions" )
2323 assumeThat(BuildConfig .ENVIRONMENT != " github" , `is `(true ))
24+ // crash on swallowed Compose masking errors (e.g. broken obfuscated internals) so regressions
25+ // fail this on-device test instead of silently under-masking (see SentryReplayDebug)
26+ System .setProperty(" io.sentry.replay.compose.fail-fast" , " true" )
2427 }
2528
2629 @Test
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ class ReplaySnapshotTest : BaseUiTest() {
2323 // GH Actions emulators don't support capturing screenshots for replay
2424 @Suppress(" KotlinConstantConditions" )
2525 assumeThat(BuildConfig .ENVIRONMENT != " github" , `is `(true ))
26+ // crash on swallowed Compose masking errors (e.g. broken obfuscated internals) so regressions
27+ // fail this on-device test instead of silently under-masking (see SentryReplayDebug)
28+ System .setProperty(" io.sentry.replay.compose.fail-fast" , " true" )
2629 }
2730
2831 @Test
Original file line number Diff line number Diff line change 1+ package io.sentry.android.replay.util
2+
3+ /* *
4+ * Internal, undocumented escape hatch used to make Session Replay fail fast instead of silently
5+ * degrading masking when an exception is swallowed (e.g. unsupported/obfuscated Compose internals).
6+ *
7+ * It is intended to be enabled only in our own sample/UI-test apps that run on real devices in CI
8+ * (which are release/obfuscated builds, so [io.sentry.android.replay.BuildConfig.DEBUG] can't be
9+ * used), so that regressions surface as crashes rather than under-masked replays. Customers should
10+ * never set this.
11+ *
12+ * Enable via:
13+ * ```
14+ * System.setProperty("io.sentry.replay.compose.fail-fast", "true")
15+ * ```
16+ */
17+ internal object SentryReplayDebug {
18+ private const val FAIL_FAST_PROPERTY = " io.sentry.replay.compose.fail-fast"
19+
20+ /* *
21+ * Read live (not cached) so it's only evaluated on the error path and unit tests can toggle it
22+ * between cases.
23+ */
24+ val failFast: Boolean
25+ get() = " true" .equals(System .getProperty(FAIL_FAST_PROPERTY ), ignoreCase = true )
26+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import io.sentry.SentryLevel
2222import io.sentry.SentryMaskingOptions
2323import io.sentry.android.replay.SentryReplayModifiers
2424import io.sentry.android.replay.util.ComposeTextLayout
25+ import io.sentry.android.replay.util.SentryReplayDebug
2526import io.sentry.android.replay.util.boundsInWindow
2627import io.sentry.android.replay.util.findPainter
2728import io.sentry.android.replay.util.findTextColor
@@ -147,6 +148,12 @@ internal object ComposeViewHierarchyNode {
147148 )
148149 }
149150
151+ // fail fast in our own sample/UI-test apps (see SentryReplayDebug), so regressions surface
152+ // as crashes instead of silently degrading masking
153+ if (SentryReplayDebug .failFast) {
154+ throw t
155+ }
156+
150157 // If we're unable to retrieve the semantics configuration
151158 // we should play safe and mask the whole node.
152159 return GenericViewHierarchyNode (
@@ -291,6 +298,11 @@ internal object ComposeViewHierarchyNode {
291298 """
292299 .trimIndent(),
293300 )
301+ // fail fast in our own sample/UI-test apps (see SentryReplayDebug), so regressions surface
302+ // as crashes instead of silently skipping the whole Compose subtree (i.e. not masking it)
303+ if (SentryReplayDebug .failFast) {
304+ throw e
305+ }
294306 return false
295307 }
296308
Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ public class MyApplication extends Application {
99
1010 @ Override
1111 public void onCreate () {
12+ // Make Session Replay fail fast instead of silently degrading masking when an exception is
13+ // swallowed (e.g. unsupported/obfuscated Compose internals). This way regressions surface as
14+ // crashes in our release/obfuscated builds that run on real devices in CI. Only meant for our
15+ // own sample/UI-test apps, customers should never set this.
16+ System .setProperty ("io.sentry.replay.compose.fail-fast" , "true" );
1217 Sentry .startProfiler ();
1318 strictMode ();
1419 super .onCreate ();
You can’t perform that action at this time.
0 commit comments