Skip to content

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
9.x.xfrom
no/java-552-bitmap-oom
Draft

runningcode wants to merge 1 commit into
9.x.xfrom
no/java-552-bitmap-oom

Conversation

@runningcode

@runningcode runningcode commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

A bitmap of a whole window, frame or SurfaceView is one large allocation, which can fail with an OutOfMemoryError while the rest of the heap is healthy. The SDK now catches OutOfMemoryError only around its own single large bitmap allocations, and skips that screenshot or frame instead of crashing the app.

Exceptions:

  • The broad catches around these allocations get rethrowIfFatal here instead of in fix: Rethrow fatal errors at the SDK's boundary catches (JAVA-552) #6665, because without the inner OutOfMemoryError catch, rethrowIfFatal would turn one failed allocation into a crash.
  • If creating the replay recorder runs out of memory, no frames are captured until the next configuration change, because the PixelCopy strategy allocates its frame bitmap up front.
  • An OutOfMemoryError from starting a thread, such as a HandlerThread or a timer, is deliberately left uncaught.

💡 Motivation and Context

This is part of the catch (Throwable) audit. It's independent of the other JAVA-552 PRs, so it can merge in any order.

💚 How did you test it?

No new tests, only the existing ones.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

#skip-changelog

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Nov 19, 2026

Copy link
Copy Markdown

JAVA-552

@sentry

sentry Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.64.0 (1) release

⚙️ sentry-android Build Distribution Settings

…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 frame observer's copy of a replay frame, made with Bitmap.copy or BitmapFactory.decodeFile, is skipped the same way. The frame is still recorded.

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 <[email protected]>
@runningcode
runningcode force-pushed the no/java-552-bitmap-oom branch from 320ded7 to 730480f Compare November 19, 2026 09:37
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant