Skip to content

fix(android): support out-of-process crash handling on API 21+ - #6614

Open
jpnurmi wants to merge 5 commits into
mainfrom
jpnurmi/fix/native-android-21
Open

jpnurmi wants to merge 5 commits into
mainfrom
jpnurmi/fix/native-android-21

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

⚠️ DO NOT MERGE YET (revert 1eca506 after releasing getsentry/sentry-native#2301)

📜 Description

A follow-up to #6347:

  • Drop the API 30 requirement from sentry-android-ndk-outproc.
  • Pass the database directory to SentryNdk.createCrashShm(String), which falls back to a file without memfd_create (Linux < 3.17).
  • Read the process name from /proc/self/cmdline below API 28 to skip SDK init in the crash service process.
  • Start the crash service without blocking SentryAndroid.init() for up to 10 s.

💡 Motivation and Context

Before, outproc required API 30+ while inproc supports API 21+. Now, both support API 21+.

💚 How did you test it?

The Android E2E tests in getsentry/sentry-native#2301 build this branch and run on API 21, 26, 31, 35 and 36.

📝 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

Requires:

Docs:

`SentryNdkCrashService.start` waited up to 10 s for the service to
connect and configure, on the thread that calls `SentryAndroid.init`,
usually the main thread. It now hands the app's ends to native right
away, and the service takes its ends when it connects. If it doesn't
connect within 10 s, its ends are closed so that native sends and the
crash handler fail at once, and a later connection reattaches.

Native init in sentry-native 1.0.0-beta.1 still waits for the daemon.
Nothing in the crash service needs API 30. Drop the check in
`SentryNdkOutproc.init()`, and pass the database directory to
`SentryNdk.createCrashShm()` so that the crash IPC falls back to a file
on kernels without memfd.

`Application.getProcessName()` needs API 28, so read the process name
from `/proc/self/cmdline` on older versions to skip SDK init in the
crash service process.
DO NOT MERGE (revert after releasing getsentry/sentry-native#2301)

`SentryNdk.createCrashShm(String)` is not in a sentry-native release
yet. Build `sentry-native-ndk-outproc` from the sentry-native branch
and publish it to Maven Local under a version that Maven Central does
not have, so that Gradle resolves the local build.
@jpnurmi
jpnurmi requested review from a team and adinauer as code owners November 16, 2026 08:58
@jpnurmi
jpnurmi requested review from romtsn and runningcode and removed request for a team November 16, 2026 08:58
@sentry

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1eca506. Configure here.

A service that connected after the 10 s timeout reattached, but its
connection never counted as configured, so `onBindingDied` didn't bind
it again and out-of-process crash handling stayed down for the rest of
the session.

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