fix(replay): Fix VerifyError in Compose masking under DexGuard/R8 obfuscation#5507
Merged
Merged
Conversation
…uscation ComposeViewHierarchyNode.boundsInWindow returned an android.graphics.Rect while the surrounding code carried it as androidx.compose.ui.geometry.Rect, mixing the two Rect types in the same method. Under aggressive obfuscation (DexGuard 9.13.2 / R8 full mode) this could be rejected at class load with a VerifyError, crashing Replay when traversing the Compose tree. Make boundsInWindow return androidx.compose.ui.geometry.Rect throughout and add a Rect.toRect() extension to convert to android.graphics.Rect only at the boundary where the view-hierarchy node needs it. Fixes #5497 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
| 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 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e56c863. Configure here.
isVisible/shouldMask are derived from the sub-pixel float bounds, but the android.graphics.Rect stored on the node (and drawn by MaskRenderer) used truncating toInt(). A sub-pixel node could be marked visible+maskable yet store a zero-width/height rect, so the mask wasn't drawn and sensitive content leaked. Round outward (floor min, ceil max) so a non-empty float rect always yields a non-empty integer rect, biasing toward over-masking. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
8 tasks
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
ComposeViewHierarchyNodetraversal computed node bounds viaLayoutCoordinates.boundsInWindow(...), which returned anandroid.graphics.Rectwhile the surrounding code treated the value asandroidx.compose.ui.geometry.Rect— mixing the twoRecttypes withinfromComposeNode(...).Under aggressive obfuscation/optimization (DexGuard 9.13.2 / R8 full mode) this could be rejected at class verification time with a
VerifyError('Unresolved Reference: androidx.compose.ui.geometry.Rect' not instance of ...), crashing Session Replay the moment it traversed the first Compose screen.Fix:
boundsInWindow(...)now consistently returnsandroidx.compose.ui.geometry.Rect(float-based), so a singleRecttype flows through the method.internal fun Rect.toRect(): android.graphics.Rectextension to convert only at the boundary where the view-hierarchy node actually needsandroid.graphics.Rect.💡 Motivation and Context
Fixes #5497 — Session Replay
VerifyErrorinComposeViewHierarchyNodeunder DexGuard/R8 obfuscation.💚 How did you test it?
Existing Session Replay Compose unit tests; built the replay module in release. The crash itself only reproduces under aggressive obfuscation (DexGuard / R8 full mode), where the mixed
Recttypes tripped the verifier; collapsing to a singleRecttype removes the ambiguity.Example replay: https://sentry-sdks.sentry.io/explore/replays/6783b073aef442a8b4ad8731bf6901fa
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps