Fix broken view hierarchy retrieval for Jetpack Compose 1.8+#4485
Merged
Fix broken view hierarchy retrieval for Jetpack Compose 1.8+#4485
Conversation
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f973d89 | 478.56 ms | 510.76 ms | 32.20 ms |
| e406a73 | 405.00 ms | 420.52 ms | 15.52 ms |
| 72db3dd | 466.26 ms | 550.76 ms | 84.50 ms |
| 6847d1a | 404.77 ms | 414.66 ms | 9.89 ms |
| 3e78fe2 | 410.08 ms | 462.62 ms | 52.54 ms |
| be72013 | 432.08 ms | 494.88 ms | 62.80 ms |
| 6e02352 | 451.73 ms | 477.94 ms | 26.20 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f973d89 | 1.58 MiB | 2.08 MiB | 511.62 KiB |
| e406a73 | 1.58 MiB | 2.08 MiB | 511.61 KiB |
| 72db3dd | 1.58 MiB | 2.08 MiB | 511.64 KiB |
| 6847d1a | 1.58 MiB | 2.08 MiB | 511.63 KiB |
| 3e78fe2 | 1.58 MiB | 2.08 MiB | 511.73 KiB |
| be72013 | 1.58 MiB | 2.08 MiB | 511.73 KiB |
| 6e02352 | 1.58 MiB | 2.12 MiB | 549.10 KiB |
...roid-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ComposeViewHierarchyNode.kt
Show resolved
Hide resolved
...roid-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ComposeViewHierarchyNode.kt
Outdated
Show resolved
Hide resolved
stefanosiano
approved these changes
Jun 13, 2025
Contributor
stefanosiano
left a comment
There was a problem hiding this comment.
just a little doubt, but looks good!
romtsn
reviewed
Jun 16, 2025
| ) | ||
| } | ||
|
|
||
| // If we're unable to retrieve the semantics configuration |
Member
There was a problem hiding this comment.
I'm thinking if we should check if any masking is actually enabled? Thinking of a case where nothing should be masked, but we still would weirdly mask something when failed to retrieve the semantics.
Member
There was a problem hiding this comment.
(maskAllText and maskAllImages, that is)
Member
Author
There was a problem hiding this comment.
I'm wondering if we should even process the view hierarchy if no masking is active? I'll get this merged now, as by default masking is active anyway. We can always improve on top.
romtsn
approved these changes
Jun 16, 2025
Member
romtsn
left a comment
There was a problem hiding this comment.
one comment, but otherwise LGTM, great workaround and tests!
romtsn
pushed a commit
that referenced
this pull request
Jul 9, 2025
* Fix broken view hierarchy retrieval for Jetpack Compose 1.8+ * Update Changelog * Fix tests * Update Changelog * Add more tests * Allow null semantics, but mask in case an exception gets thrown * Address PR feedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Fixes missing masking for Jetpack Compose 1.8+ as
LayoutNode.collapsedSemanticswas removed in favor ofLayoutNode.getSemanticsConfiguration()We used to swallow errors when retrieving the Compose ViewHierarchy, leading to un-masked replays. After some discussion we're changing this to a more defensive approach: If parts of the View Hierarchy can't be retrieved we simply mask the relevant parts of the UI.
💡 Motivation and Context
Fixes #4467
💚 How did you test it?
Added tests + manual testing.
Before:

After:

📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps