Repository navigation
Conversation
|
📲 Install BuildsAndroid
|
Keep both current Unreleased changelog entries after #6301 merged.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6c235cd. Configure here.
| return; | ||
| } | ||
| anrWarningConsumer = consumer; | ||
| } |
There was a problem hiding this comment.
Lock held across binder registration
Medium Severity
activityManager.registerAnrWarningListener is a binder IPC call, but it runs while lock is held, and the failure path also logs under that lock. close() acquires the same lock and often runs on the main thread, so a slow or stuck ActivityManager call can block Sentry.close() and show up as an ANR. Unregister already performs its binder call after releasing the lock.
Triggered by project rule: PR Review Guidelines for Cursor Bugbot
Reviewed by Cursor Bugbot for commit 6c235cd. Configure here.
| options | ||
| .getLogger() | ||
| .log(SentryLevel.WARNING, "Failed to register the ANR warning listener.", e); | ||
| return; |
There was a problem hiding this comment.
Broad catch missing required handling
Medium Severity
The new RuntimeException catches around the ActivityManager binder calls sit at a system-service boundary but do not call ExceptionUtils.rethrowIfFatal first and have no comment explaining why the catch is broad or what happens on failure (listener not installed, or leftover registration). Nearby API 37 code such as MemoryLimiterIntegration follows that pattern.
Additional Locations (1)
Triggered by project rule: PR Review Guidelines for Cursor Bugbot
Reviewed by Cursor Bugbot for commit 6c235cd. Configure here.
| final @NotNull Context context, final @NotNull BuildInfoProvider buildInfoProvider) { | ||
| this.context = context.getApplicationContext(); | ||
| this.buildInfoProvider = buildInfoProvider; | ||
| } |
There was a problem hiding this comment.
Null application context skips ANR listener
Low Severity
The new constructor stores context.getApplicationContext() directly. That method can return null for some Context implementations (ContextImpl is called out in ContextUtils). scheduleRegisterAnrWarningListener then treats a null context as “no Context” and never installs the ANR warning listener. Other integrations, including MemoryLimiterIntegration and AnrV2Integration, use ContextUtils.getApplicationContext, which falls back to the original context.
Reviewed by Cursor Bugbot for commit 6c235cd. Configure here.


📜 Description
On Android 17 (API 37) and above,
AppLifecycleIntegrationnow subscribes toActivityManager.registerAnrWarningListener. These usually fire halfway (e.g. input dispatch at 2.5s of the 5s limit, forground service starts at 5s of the 10s limit)Each warning becomes an
app.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.💡 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?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
app.anrbreadcrumb to the Android breadcrumbs page.🤖 Generated with Claude Code