Repository navigation
fix(replay): Skip the screenshot or frame when its bitmap can't be allocated (JAVA-552) - #6678
Draft
runningcode wants to merge 1 commit into
Draft
runningcode wants to merge 1 commit into
runningcode wants to merge 1 commit into
Conversation
…located A bitmap of the whole window, recording or SurfaceView is one large allocation, which can fail with an OutOfMemoryError while the rest of the heap is healthy. The SDK now catches it only around its own Bitmap allocations and skips that screenshot or frame, instead of crashing the app. This matters for hybrid SDKs, which call ScreenshotUtils on the UI thread without a catch of their own. The screenshot and replay capture catches around these allocations also call ExceptionUtils.rethrowIfFatal now, with a comment saying why they are broad. Refs #5513 Refs JAVA-552 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 19, 2026
📲 Install BuildsAndroid
|
This branch has not been deployed
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
A bitmap of the whole window, recording or SurfaceView is one large allocation. It can fail with an
OutOfMemoryErrorwhile the rest of the heap is healthy. The SDK now catches theOutOfMemoryErroronly around its ownBitmapallocations, and skips that screenshot or frame instead of crashing the app:ScreenshotUtils.captureScreenshot: the screenshot is skipped. Hybrid SDKs call this throughtakeMaskedScreenshoton the UI thread without a catch of their own.CanvasStrategy: the replay frame is skipped, and the next frame tries the allocation again.PixelCopyStrategy: a SurfaceView whose bitmap can't be allocated is left out of the frame. The strategy's own frame bitmap is allocated when the recorder is created, so:WindowRecorder: if creating the recorder runs out of memory, no frames are captured until the next configuration change.The catches around these allocations are boundaries, so they also get
ExceptionUtils.rethrowIfFatalhere, with a comment saying why they are broad. That's 8 sites:ScreenshotUtils.captureScreenshot: the PixelCopy request, thedraw()posted to the UI thread, and the catch around the whole captureScreenshotRecorder.captureandWindowRecorder's capture loopPixelCopyStrategy: the PixelCopy request and the SurfaceView captureCanvasStrategy's picture render taskThread creation isn't covered: an
OutOfMemoryErrorfromHandlerThread.startor a timer still crashes, as accepted.Mixed sites
All 8 sites are mixed: the boundary treatment plus the inner
OutOfMemoryErrorcatch around the allocation. They move here from #6665.💡 Motivation and Context
This is part of the
catch (Throwable)audit. A review of #6665 found that addingrethrowIfFatalat these sites turns one failed bitmap allocation into an app crash.This PR is independent of its siblings and they can merge in any order:
rethrowIfFatalat boundary sitesLinkageErrorisn't fatalUserInteractionTeststhread-safe list💚 How did you test it?
sentry-android-coreandsentry-android-replay, plus detekt.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
The changelog entry for the whole set is in #6665.
#skip-changelog
🤖 Generated with Claude Code