Skip to content

Fix broken view hierarchy retrieval for Jetpack Compose 1.8+ #4485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 17, 2025

Conversation

markushi
Copy link
Member

@markushi markushi commented Jun 11, 2025

📜 Description

Fixes missing masking for Jetpack Compose 1.8+ as LayoutNode.collapsedSemantics was removed in favor of LayoutNode.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

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

🔮 Next steps

Copy link
Contributor

github-actions bot commented Jun 11, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 379.27 ms 416.89 ms 37.62 ms
Size 1.58 MiB 2.12 MiB 549.12 KiB

Previous results on branch: markushi/fix/session-replay-jetpack-composes-masking

Startup times

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

Copy link
Member

@stefanosiano stefanosiano left a comment

Choose a reason for hiding this comment

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

just a little doubt, but looks good!

)
}

// If we're unable to retrieve the semantics configuration
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

(maskAllText and maskAllImages, that is)

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

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

one comment, but otherwise LGTM, great workaround and tests!

@markushi markushi merged commit 8bfa9cc into main Jun 17, 2025
34 checks passed
@markushi markushi deleted the markushi/fix/session-replay-jetpack-composes-masking branch June 17, 2025 06:05
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.

Text composables not masked in session replay
3 participants