Skip to content

fix(replay): [Throwable Boundaries 3] Rethrow fatal errors at replay, NDK and SQLite boundaries - #6659

Draft
runningcode wants to merge 2 commits into
no/java-552-boundaries-android-corefrom
no/java-552-boundaries-replay-ndk
Draft

runningcode wants to merge 2 commits into
no/java-552-boundaries-android-corefrom
no/java-552-boundaries-replay-ndk

Conversation

@runningcode

@runningcode runningcode commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (Throwable Boundaries)


📜 Description

This PR handles the 16 remaining swallowing catch (Throwable) sites in sentry-android-replay, sentry-android-ndk and sentry-android-sqlite, and fixes a lost interrupt in SentryNdk:

  • 14 boundaries now call ExceptionUtils.rethrowIfFatal first, with a comment saying why the catch is broad and what is lost when it fails. They guard the device's graphics and media stacks (PixelCopy, canvas drawing, MediaCodec), the app's own views and touch dispatch, ReplayFrameObserver, the replay executors' task wrappers, and the reflective serialization of breadcrumb data for the NDK.
  • LinkageError arm (1): SentrySQLiteDriver.open. androidx.sqlite is compileOnly, so a mismatched version returns the connection uninstrumented, as before.
  • Narrowed (2):
    • BaseCaptureStrategy's inline segment persistence: IOException, and IndexOutOfBoundsException for a corrupt segment file line.
    • CanvasStrategy.postSafely: Handler.post doesn't throw. It returns false when the looper is quitting, so it now logs on false instead.
  • Javadoc: SentryReplayOptions.ReplayFrameObserver.onMaskedFrameCaptured says what happens when the observer throws.
  • SentryNdk.init and close now restore the thread's interrupt flag before wrapping an InterruptedException in an IllegalStateException.

💡 Motivation and Context

This is the replay, NDK and SQLite part of the rethrowIfFatal boundary pass. Note that an OutOfMemoryError while capturing a frame, for example from Bitmap.createBitmap, now propagates instead of only skipping the frame. In the replay executors, a fatal error ends the task rather than being logged.

💚 How did you test it?

  • The full unit test suites of sentry-android-replay, sentry-android-ndk and sentry-android-sqlite, plus detekt for the Kotlin modules.
  • New tests: session capture starts even when the segment write throws an IOException; the SQLite driver returns the uninstrumented connection on a LinkageError and rethrows an OutOfMemoryError; SentryNdk.init and close keep the interrupt.

📝 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.

🔮 Next steps

⚠️ Merge this PR using a merge commit (not squash). Only the bottom of the stack, #6562, is squash-merged into 9.x.x.

#skip-changelog

🤖 Generated with Claude Code

runningcode and others added 2 commits November 18, 2026 12:12
The remaining catch (Throwable) sites in sentry-android-replay,
sentry-android-ndk and sentry-android-sqlite guard the device's graphics
and media stacks, the app's own views and ReplayFrameObserver, or
reflective serialization of breadcrumb data. Keep them broad, but call
ExceptionUtils.rethrowIfFatal first and say at each catch why it's broad
and what is lost on failure.

- SentrySQLiteDriver.open catches LinkageError first, since androidx.sqlite
  is compileOnly and a mismatched version is an expected failure.
- BaseCaptureStrategy's inline persistence only writes the segment file,
  so it now catches IOException and IndexOutOfBoundsException.
- CanvasStrategy.postSafely checks the result of Handler.post, which
  returns false instead of throwing.
- ReplayFrameObserver documents what happens when it throws.

Refs JAVA-552

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SentryNdk.init and close wrap an InterruptedException from waiting on the
native library load in an IllegalStateException, and the interrupt was
lost. Restore the flag before wrapping, since the SDK doesn't own the
calling thread.

Refs JAVA-552

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 18, 2026

Copy link
Copy Markdown

JAVA-552

@sentry

sentry Bot commented Nov 18, 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

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