Multiple ANRs on Init after upgrading from 8.18.0 to 8.25.0
Integration
sentry-android
Build System
Gradle
AGP Version
8.11.0
Proguard
Enabled
Version
8.25.0
Steps to Reproduce
Background ANR on Sentry initialization after upgrading SDK
We are experiencing Background Application Not Responding (ANR) issues after upgrading the Sentry Android SDK from version 8.18.0 to 8.25.0.
These ANRs occur during the application's startup phase, specifically within the Sentry initialization process (SentryAndroid.init or related internal setup). Since the update, we have observed an increase in io.sentry.android.core.ApplicationNotResponding: Background ANR events.
We have gathered multiple stack traces pointing to different parts of the Sentry SDK's initialization, which suggests a potential bottleneck or blocking operation introduced in the newer versions.
io.sentry.android.core.ApplicationNotResponding: Background ANR
at io.sentry.android.core.ManifestMetadataReader.readDouble(ManifestMetadataReader.java:1)
at io.sentry.android.core.ManifestMetadataReader.applyMetadata(ManifestMetadataReader.java:193)
at io.sentry.android.core.AndroidOptionsInitializer.loadDefaultAndMetadataOptions(AndroidOptionsInitializer.java:132)
at io.sentry.android.core.SentryAndroid.lambda$init$1(SentryAndroid.java:125)
at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:254)
at io.sentry.Sentry.init(Sentry.java:224)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:100)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:84)
at com.pedidosya.logger.businesslogic.report.handlers.SentryHandler.init(SentryHandler.kt:75)
at com.pedidosya.main.activities.PedidosYa.onCreate(PedidosYa.kt:42)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7711)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(unavailable:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2478)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8919)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
io.sentry.android.core.ApplicationNotResponding: Background ANR
at io.sentry.NoOpSentryExecutorService.<clinit>(NoOpSentryExecutorService.java:9)
at io.sentry.SentryOptions.<init>(SentryOptions.java:305)
at io.sentry.SentryOptions.empty(SentryOptions.java:3181)
at io.sentry.Sentry.<clinit>(Sentry.java:68)
at com.pedidosya.logger.businesslogic.report.handlers.SentryHandler.checkInitialized(SentryHandler.kt:543)
at com.pedidosya.logger.businesslogic.report.handlers.SentryHandler.init(SentryHandler.kt:73)
at com.pedidosya.main.activities.PedidosYa.onCreate(PedidosYa.kt:42)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1325)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7534)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(unavailable:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2421)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:222)
at android.os.Looper.loop(Looper.java:314)
at android.app.ActivityThread.main(ActivityThread.java:8779)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:569)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1090)
at io.sentry.android.core.ContextUtils.<clinit> (ContextUtils.java:126)
at io.sentry.android.core.AndroidOptionsInitializer.loadDefaultAndMetadataOptions (AndroidOptionsInitializer.java:107)
at io.sentry.android.core.SentryAndroid.lambda$init$1 (SentryAndroid.java:120)
at io.sentry.Sentry.applyOptionsConfiguration (Sentry.java:253)
at io.sentry.Sentry.init (Sentry.java:223)
at io.sentry.android.core.SentryAndroid.init (SentryAndroid.java:97)
at io.sentry.android.core.SentryAndroid.init (SentryAndroid.java:81)
at com.pedidosya.logger.businesslogic.report.handlers.SentryHandler.init (SentryHandler.kt:75)
at com.pedidosya.main.activities.PedidosYa.onCreate$lambda$0 (PedidosYa.kt:43)
at com.pedidosya.performance.UtilsKt.traceBlock (Utils.kt:18)
at com.pedidosya.main.activities.PedidosYa.onCreate (PedidosYa.kt:42)
at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1329)
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:8334)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication (unavailable)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2869)
at android.os.Handler.dispatchMessage (Handler.java:117)
at android.os.Looper.loopOnce (Looper.java:210)
at android.os.Looper.loop (Looper.java:302)
at android.app.ActivityThread.main (ActivityThread.java:9675)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:601)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1062)
Steps to Reproduce:
- Use Manual Initialization (
SentryAndroid.init(context, options)) in the Application class - Upgrade Sentry Android SDK dependency from
8.18.0to8.25.0. - Run the application.
- Observe increased frequency of Background ANRs during Sentry's initialization sequence.
Expected Result
Sentry initializes quickly without causing ANRs, as it did in version 8.18.0.
Actual Result
Frequent Background ANRs are reported during the manual initialization of Sentry in version 8.25.0
@juanfelippopeya thanks for reporting, we'll investigate and report back! Are these ANRs new or you just have seen an increase in numbers of the existing ones?
Hi @romtsn! sorry my bad, i double checked and the ANR is not new; it was already present in previous versions.
What changed is that in the latest migration, we switched the library's initialization method from automatic to manual. This change led to a different grouping and reporting structure, which is why it looks like there's an increase in the numbers, or why they seem new.
Regardless of the grouping change, their current occurrence is still very high, ranking as our top ANR.
Let me know if you prefer that I update this issue with further details, or if I should open a new one instead