Repository navigation
Conversation
Contributor
|
📲 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
On Android 17 (API 37) and above,
AppLifecycleIntegrationnow subscribes toActivityManager.registerAnrWarningListener. The system calls this listener while an ANR timeout is still running, before it declares the app unresponsive. Each warning becomes anapp.anrbreadcrumb (type: system,level: warning,message: ANR warning) with this data:anr_type: theAnrTypesconstant as a readable name (for exampleinput_dispatch,broadcast_of_intent,start_foreground_service). An unknown value is kept asunknown (<n>).anr_id,timeout_ms,consumed_msdescription: the description from the system. It is not set if the system gives an empty value.Details:
enableAppLifecycleBreadcrumbsis enabled.Sentry.init.close()unregisters the listener. If the executor drops or rejects the unregister task, it runs inline. A register task that is still in the queue afterclose()does not register the listener.AppLifecycleIntegrationnow takes(Context, BuildInfoProvider)in its constructor. The public no-arg constructor is kept as@Deprecated. With it, the ANR warning listener is not installed.Depends on #6242 (JDK 21 build), which is the base branch of this PR.
💡 Motivation and Context
The ANR warning arrives before the ANR. If the app then crashes, records an error, or is killed for the ANR, the event breadcrumbs show that the main thread was already slow, and they show which ANR type and how much of the timeout was used.
💚 How did you test it?
AppLifecycleIntegrationTest(Robolectric,sdk = 37): breadcrumb mapping, unknown ANR types, listener not registered when lifecycle breadcrumbs are disabled or below API 37, registration failure, double close, close while the register task is still in the queue, and a dropped or rejected executor task.AnrWarningBreadcrumbTest(API 37 only), verified on an API 37 device: makesservice_start_foreground_timeout_msshorter withdevice_configand startsSlowStartService, which never callsstartForeground(). Then it checks theapp.anrbreadcrumb inbeforeBreadcrumb. The main thread does not block.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
app.anrbreadcrumb to the Android breadcrumbs page.🤖 Generated with Claude Code