From 9ad23ce1ffe356eaa67daf7d3f39781c0d1bd99c Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Thu, 19 Nov 2026 09:52:55 +0100 Subject: [PATCH] fix(replay): Mask the whole Compose view when traversing it fails When the Compose tree can't be traversed, for example with an unsupported Compose version, fromView returned false. The view was then walked as a plain ViewGroup, whose children don't include the composables, so their text and images were recorded unmasked. The whole Compose view is now masked instead. Screenshot masking shares this traversal, so it fails closed too. Refs #5513 Refs JAVA-552 Co-Authored-By: Claude Opus 5.5 --- .../viewhierarchy/ComposeViewHierarchyNode.kt | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ComposeViewHierarchyNode.kt b/sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ComposeViewHierarchyNode.kt index 2e40144e2de..35b38d207d1 100644 --- a/sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ComposeViewHierarchyNode.kt +++ b/sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ComposeViewHierarchyNode.kt @@ -300,11 +300,29 @@ internal object ComposeViewHierarchyNode { .trimIndent(), ) // fail fast in our own sample/UI-test apps (see SentryReplayDebug), so regressions surface - // as crashes instead of silently skipping the whole Compose subtree (i.e. not masking it) + // as crashes instead of silently masking the whole Compose view if (SentryReplayDebug.failFast) { throw e } - return false + // Returning false would treat the view as a plain ViewGroup, whose children don't include + // the composables, so they would be recorded unmasked. Some of them may need masking, so the + // whole view is masked instead. + parent.children = + listOf( + GenericViewHierarchyNode( + x = parent.x, + y = parent.y, + width = parent.width, + height = parent.height, + elevation = parent.elevation, + distance = 0, + parent = parent, + shouldMask = true, + isVisible = parent.isVisible, + visibleRect = parent.visibleRect, + ), + ) + return true } return true