[SR] Ensure bitmaps are recycled properly#4820
Merged
Conversation
Requires to use synchronized blocks over AutoClosableReentrantLock, as only the bitmap object is shared across Strategy <-> ReplayCache. This ensure bitmap.compress is not called in parallel to bitmap.recycle
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d364ace | 411.72 ms | 430.81 ms | 19.10 ms |
| ee747ae | 396.82 ms | 441.67 ms | 44.86 ms |
| ee747ae | 415.92 ms | 470.15 ms | 54.23 ms |
| 889ecea | 367.58 ms | 437.52 ms | 69.94 ms |
| b77456b | 393.26 ms | 441.10 ms | 47.84 ms |
| f634d01 | 375.06 ms | 420.04 ms | 44.98 ms |
| b750b96 | 408.98 ms | 480.32 ms | 71.34 ms |
| b3d8889 | 371.69 ms | 432.96 ms | 61.26 ms |
| 9fbb112 | 401.87 ms | 515.87 ms | 114.00 ms |
| ee747ae | 358.21 ms | 389.41 ms | 31.20 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d364ace | 1.58 MiB | 2.11 MiB | 539.75 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| 889ecea | 1.58 MiB | 2.11 MiB | 539.75 KiB |
| b77456b | 1.58 MiB | 2.12 MiB | 548.11 KiB |
| f634d01 | 1.58 MiB | 2.10 MiB | 533.40 KiB |
| b750b96 | 1.58 MiB | 2.10 MiB | 533.19 KiB |
| b3d8889 | 1.58 MiB | 2.10 MiB | 535.06 KiB |
| 9fbb112 | 1.58 MiB | 2.11 MiB | 539.18 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
Previous results on branch: markushi/fix/sr-bitmap-synchronization
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 22d6c54 | 328.67 ms | 392.40 ms | 63.73 ms |
| 735b63e | 303.80 ms | 366.12 ms | 62.32 ms |
| 92f4581 | 300.64 ms | 362.88 ms | 62.24 ms |
| 2cdc160 | 313.60 ms | 367.83 ms | 54.23 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 22d6c54 | 1.58 MiB | 2.12 MiB | 548.19 KiB |
| 735b63e | 1.58 MiB | 2.12 MiB | 549.49 KiB |
| 92f4581 | 1.58 MiB | 2.12 MiB | 549.49 KiB |
| 2cdc160 | 1.58 MiB | 2.12 MiB | 549.42 KiB |
romtsn
reviewed
Oct 21, 2025
sentry-android-replay/src/main/java/io/sentry/android/replay/screenshot/CanvasStrategy.kt
Outdated
Show resolved
Hide resolved
romtsn
approved these changes
Oct 22, 2025
Member
romtsn
left a comment
There was a problem hiding this comment.
one bugbot thing, but lgtm otherwise
…etsentry/sentry-java into markushi/fix/sr-bitmap-synchronization
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.
Requires to use synchronized blocks over AutoClosableReentrantLock, as only the bitmap object is shared across Strategy <-> ReplayCache. This ensure bitmap.compress is not called in parallel to bitmap.recycle
📜 Description
💡 Motivation and Context
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps