feat: added AndroidNativeAnrEnabled and related options#2671
Open
bitsandfoxes wants to merge 15 commits into
Open
feat: added AndroidNativeAnrEnabled and related options#2671bitsandfoxes wants to merge 15 commits into
AndroidNativeAnrEnabled and related options#2671bitsandfoxes wants to merge 15 commits into
Conversation
Contributor
|
bitsandfoxes
commented
May 11, 2026
Comment on lines
+143
to
+144
| androidOptions.Call("setAnrEnabled", options.AndroidNativeAnrEnabled); | ||
| androidOptions.Call("setEnableScopePersistence", options.AndroidNativeAnrEnabled); |
Contributor
Author
There was a problem hiding this comment.
The setEnableScopePersistence only affects the ANR v2 and the tombstone integration. And the Unity SDK only surfaces the ANR with this PR. So I'm opting to keep this option merged into the AnrNativeAnrEnabled.
JoshuaMoelans
approved these changes
May 11, 2026
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.
Problem
Unity games can get stuck in multiple places and as of right now the SDK surfaces only the C# watchdog integration to capture ANRs. This comes with several limitations.
sentry-javahas its own ANR integrations that the SDK currently hardcoded opts-out.Context
Unity games have their own main thread. The
sentry-javaSDK has a v1 and a v2 ANR integration that monitors the Android UI thread.There are these native options:
enableAnrenableScopePersistenceisReportHistoricalAnrsisAttachAnrThreadDumpSince the work next to each other we keep the umbrella flags
AnrDetectionEnabledandAndroidNativeAnrEnabledseparated.The way this works is on API >= 30
sentry-javawill useApplicationExitInfoto read OS-reported ANRs to generate events out of those. Since this happens on the next launch,enableScopePersistenceallows the SDK to store the scope to disk to then enrich the event with the scope at the time of the ANR.Proposal
We can surface these options and pass them to
sentry-java. These are especially valuable if users have their own launcher, or plugins running outside of the Unity game loop.sentry-javatakes care of picking the supported ANR integration. On API < 30 this is "just" a watchdog, similar to what we have for C#.Follow Up
There are a couple of follow-ups:
sentry-javamanifest needs to accept the historic anr capture flag, see feat: addedANR_REPORT_HISTORICALto theManifestMetaDataReadersentry-java#5387