fix(replay): Prevent concurrent PixelCopy frame access#5808
Draft
romtsn wants to merge 1 commit into
Draft
Conversation
Keep PixelCopy, masking, compositing, and cleanup from accessing the shared bitmap concurrently. Fixes GH-5340 Co-Authored-By: Codex <noreply@openai.com>
Contributor
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Fixes
- Prevent concurrent PixelCopy frame access ([#5808](https://github.com/getsentry/sentry-java/pull/5808))If none of the above apply, you can opt out of this check by adding |
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5b1a06b | 352.27 ms | 413.70 ms | 61.43 ms |
| 2124a46 | 319.19 ms | 415.04 ms | 95.85 ms |
| ad8da22 | 314.52 ms | 352.47 ms | 37.95 ms |
| d15471f | 304.55 ms | 408.43 ms | 103.87 ms |
| 0ee65e9 | 317.37 ms | 366.50 ms | 49.13 ms |
| 2195398 | 351.77 ms | 433.22 ms | 81.45 ms |
| ee747ae | 358.21 ms | 389.41 ms | 31.20 ms |
| abfcc92 | 309.54 ms | 380.32 ms | 70.78 ms |
| 8558cac | 306.16 ms | 355.24 ms | 49.09 ms |
| d15471f | 310.26 ms | 377.04 ms | 66.78 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5b1a06b | 0 B | 0 B | 0 B |
| 2124a46 | 1.58 MiB | 2.12 MiB | 551.51 KiB |
| ad8da22 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 0ee65e9 | 0 B | 0 B | 0 B |
| 2195398 | 0 B | 0 B | 0 B |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| abfcc92 | 1.58 MiB | 2.13 MiB | 557.31 KiB |
| 8558cac | 0 B | 0 B | 0 B |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
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
Prevent concurrent access to the bitmap shared by PixelCopy and replay processing.
The strategy now drops a capture while another frame is in flight, keeps the gate held through
masking and SurfaceView compositing, suppresses last-frame emission during that work, and defers
bitmap cleanup until the outstanding PixelCopy callback completes.
💡 Motivation and Context
PixelCopy.request()returns before RenderThread finishes writing its destination. The replayexecutor could therefore draw masks or SurfaceView content into the same bitmap, while
close()could recycle it before the asynchronous request completed. This could produce torn or improperly
masked frames and may contribute to native
libhwuicrashes.Dropping an overlapping frame avoids blocking the main thread or allocating a second recording
bitmap.
Fixes #5340
Refs JAVA-490
💚 How did you test it?
./gradlew ':sentry-android-replay:testDebugUnitTest' --tests='*PixelCopyStrategyTest*' --info./gradlew spotlessApply apiDumpAdded regression coverage for requests overlapping PixelCopy, queued masking, last-frame emission,
and cleanup during an outstanding request.
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
RGB_565when SurfaceView capture is disabled in a separate change.