Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FirebaseCrashlytics] ANR in FirebaseSessionsRegistrar #6523

Open
pritesh-swiggy opened this issue Nov 18, 2024 · 11 comments
Open

[FirebaseCrashlytics] ANR in FirebaseSessionsRegistrar #6523

pritesh-swiggy opened this issue Nov 18, 2024 · 11 comments

Comments

@pritesh-swiggy
Copy link

Step 2: Describe your environment

  • Android Studio version: Android Studio Koala | 2024.1.1
  • Firebase Component: Crashlytics
  • Component version: 19.2.0

Step 3: Describe the problem

  • An ANR occurs when initializing Firebase Sessions settings during app startup. This seems related to the FirebaseSessionsRegistrar and SessionsSettings classes.
main (runnable): tid=1 systid=16923
at com.google.firebase.sessions.settings.SessionsSettings.<clinit>(SessionsSettings.kt:152)
at com.google.firebase.sessions.FirebaseSessionsRegistrar.getComponents$lambda$3(FirebaseSessionsRegistrar.kt:87)
at com.google.firebase.tracing.ComponentMonitor.lambda$processRegistrar$0(ComponentMonitor.java:38)
at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0(ComponentRuntime.java:160)
at com.google.firebase.components.Lazy.get(Lazy.java:53)
at com.google.firebase.components.ComponentContainer.get(ComponentContainer.java:48)
at com.google.firebase.components.RestrictedComponentContainer.get(RestrictedComponentContainer.java:105)
at com.google.firebase.sessions.FirebaseSessionsRegistrar.getComponents$lambda$0(FirebaseSessionsRegistrar.kt:52)
at com.google.firebase.tracing.ComponentMonitor.lambda$processRegistrar$0(ComponentMonitor.java:38)
at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0(ComponentRuntime.java:160)
at com.google.firebase.components.Lazy.get(Lazy.java:53)
at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents(ComponentRuntime.java:322)
at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(ComponentRuntime.java:312)
at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:607)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:300)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:264)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:249)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:69)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2697)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2667)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:61)
at android.app.ActivityThread.installProvider(ActivityThread.java:8783)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:8267)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7909)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2647)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:328)
at android.app.ActivityThread.main(ActivityThread.java:9237)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:594)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)

Steps to reproduce:

  1. Integrate Firebase Crashlytics SDK into the project.
  2. Launch the application.
  3. Observe the ANR during app initialization.

Relevant Code:

 FirebaseCrashlytics.getInstance().setUserId(userId)
@lehcar09
Copy link
Contributor

Hi @pritesh-swiggy, thanks you for reaching out. I tried reproducing the issue, however, I did not encounter any ANR issue. By any chance, are manually initializing the Firebase SDK? Can you share an MCVE? That'll help us to investigate the issue.

Aside from that, are you constantly experiencing this error? Does the issue occur on certain devices and/or android versions? Thanks!

@pritesh-swiggy
Copy link
Author

Hi @lehcar09, We're not initialising SDK manually, we're using getInstance method for accessing it.

This issue is happening for 100% Android 14 users in 100% background state. Also we have started seeing this issue after the recent bump of crashlytics SDK from 18.2.8 to 19.2.0.

Our targetSDK is also 34 (Android 14).

We're also seeing some other ANRs along with this SDK bump

ANR 1. com.google.firebase.tracing.ComponentMonitor.lambda$processRegistrar$0

Happening for Android 10, 11, 12 users in 100% background state

main (timed waiting):tid=1 systid=24173 
at sun.misc.Unsafe.park(Native method)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:447)
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at com.google.firebase.crashlytics.internal.common.CrashlyticsCore.checkForPreviousCrash(CrashlyticsCore.java:490)
at com.google.firebase.crashlytics.internal.common.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:198)
at com.google.firebase.crashlytics.FirebaseCrashlytics.init(FirebaseCrashlytics.java:165)
at com.google.firebase.crashlytics.CrashlyticsRegistrar.buildCrashlytics(CrashlyticsRegistrar.java:75)
at com.google.firebase.tracing.ComponentMonitor.lambda$processRegistrar$0(ComponentMonitor.java:38)
at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0(ComponentRuntime.java:160)
at com.google.firebase.components.Lazy.get(Lazy.java:53)
at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents(ComponentRuntime.java:322)
at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(ComponentRuntime.java:312)
at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:607)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:300)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:264)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:249)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:69)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:61)
at android.app.ActivityThread.installProvider(ActivityThread.java:7841)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7371)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7279)
at android.app.ActivityThread.access$1700(ActivityThread.java:299)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2184)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:264)
at android.app.ActivityThread.main(ActivityThread.java:8312)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)

ANR 2. com.google.android.datatransport.runtime.DaggerTransportRuntimeComponent$TransportRuntimeComponentImpl.initialize

Happening for Android 11, 12, 13 users in 100% background state

main (runnable):tid=1 systid=15126 
at com.google.android.datatransport.runtime.DaggerTransportRuntimeComponent$TransportRuntimeComponentImpl.initialize(DaggerTransportRuntimeComponent.java:103)
at com.google.android.datatransport.runtime.DaggerTransportRuntimeComponent$TransportRuntimeComponentImpl.<init>(DaggerTransportRuntimeComponent.java:97)
at com.google.android.datatransport.runtime.DaggerTransportRuntimeComponent$TransportRuntimeComponentImpl.<init>(DaggerTransportRuntimeComponent.java:63)
at com.google.android.datatransport.runtime.DaggerTransportRuntimeComponent$Builder.build(DaggerTransportRuntimeComponent.java:59)
at com.google.android.datatransport.runtime.TransportRuntime.initialize(TransportRuntime.java:79)
at com.google.firebase.crashlytics.internal.send.DataTransportCrashlyticsReportSender.create(DataTransportCrashlyticsReportSender.java:53)
at com.google.firebase.crashlytics.internal.common.SessionReportingCoordinator.create(SessionReportingCoordinator.java:80)
at com.google.firebase.crashlytics.internal.common.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:163)
at com.google.firebase.crashlytics.FirebaseCrashlytics.init(FirebaseCrashlytics.java:165)
at com.google.firebase.crashlytics.CrashlyticsRegistrar.buildCrashlytics(CrashlyticsRegistrar.java:75)
at com.google.firebase.tracing.ComponentMonitor.lambda$processRegistrar$0(ComponentMonitor.java:38)
at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0(ComponentRuntime.java:160)
at com.google.firebase.components.Lazy.get(Lazy.java:53)
at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents(ComponentRuntime.java:322)
at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(ComponentRuntime.java:312)
at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:607)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:300)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:264)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:249)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:69)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2443)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2413)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:61)
at android.app.ActivityThread.installProvider(ActivityThread.java:7721)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7233)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6990)
at android.app.ActivityThread.access$1600(ActivityThread.java:273)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2173)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:241)
at android.os.Looper.loop(Looper.java:342)
at android.app.ActivityThread.main(ActivityThread.java:8143)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:583)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

Do let me know if more info required

@lehcar09
Copy link
Contributor

Thank you for additional details @pritesh-swiggy. Looking into the other ANR you’re encountering, It looks to me that this is related to the ANR issue that we investigated. According to our engineers (#6147#issuecomment-2417385067),

After some investigation here are the results:

  • Previous to Android 14, these app closures still occurred, but where not reported as ANRs, so while it may be worrying to see this ANR spike in Android 14, your user's behavior is not degraded.
  • This ANR is also not caused by hitting the timeout behavior change in Android 14, Firelog's use of JobScheduler does very little on the main thread, and in a test we ran swapping to WorkManager didn't improve the situation as WorkManager is implemented on top of JobScheduler, however performance was heavier weight, so we decided to not ship that change.
  • The vast majority (>99%) of these ANRs are background ANRs. It is important to note that background ANRs are not user visible. The user experience of a background ANR is that the app takes slightly longer to turn on the next time they launch it. >* Also, background ANRs are relatively common, because a backgrounded app will be running with very limited access to memory and CPU time.

As for the ANR issue from FirebaseSessionRegistrar, were you able to reproduce the issue? Is there any chance you can share an MCVE?

@pritesh-swiggy
Copy link
Author

Hi @lehcar09, We're not able to reproduce the same issue. We're receiving the ANR stack traces from the Firebase and Play Console. Are we tracking this issue internally somewhere? probably happening to other clients also.

@lehcar09
Copy link
Contributor

Thank you for your clarification. I've checked our records and haven't found any similar reports of ANR issues related to FirebaseSessionsRegistrar.

To help our engineers investigate further, could you please confirm the version of FirebaseSession you're currently using?

I've notified our engineering team about this issue and will keep you updated.

@pritesh-swiggy
Copy link
Author

Hi @lehcar09,

Thanks for an update, Firebase Crashlytics version 19.2.0 uses firebase-sessions version 2.0.5 transitively.

@pritesh-swiggy
Copy link
Author

Hi @lehcar09,

did you get a chance to check this? can you share an update?

@pritesh-swiggy
Copy link
Author

Hi @lehcar09,

can you help with an update on this issue?

@lehcar09
Copy link
Contributor

lehcar09 commented Dec 2, 2024

Hi @pritesh-swiggy, I have raised this issue to our engineers and we're already looking into it. I'll get back to you as soon as we have updates.

@MinhNguyen-nvm
Copy link

MinhNguyen-nvm commented Dec 23, 2024

We face the same issue with a more apparent stack trace. I hope this helps solve the problem.
We started to see the issue report in Google Play Console after updating Firebase in our project from an ancient version (2021 version) to Firebase Bom file 33.3.0

"main" tid=1 Runnable
  at androidx.datastore.core.DataStoreFactory.create (DataStoreFactory.kt:64)
  at androidx.datastore.preferences.core.PreferenceDataStoreFactory.create (PreferenceDataStoreFactory.kt:63)
  at androidx.datastore.preferences.PreferenceDataStoreSingletonDelegate.getValue (PreferenceDataStoreDelegate.kt:102)
  at androidx.datastore.preferences.PreferenceDataStoreSingletonDelegate.getValue (PreferenceDataStoreDelegate.kt:78)
  at com.google.firebase.sessions.settings.SessionsSettings$Companion.getDataStore (SessionsSettings.kt:149)
  at com.google.firebase.sessions.settings.SessionsSettings$Companion.access$getDataStore (SessionsSettings.kt:142)
  at com.google.firebase.sessions.settings.SessionsSettings.<init> (SessionsSettings.kt:61)
  at com.google.firebase.sessions.settings.SessionsSettings.<init> (SessionsSettings.kt:70)
  at com.google.firebase.sessions.FirebaseSessionsRegistrar.getComponents$lambda$3 (FirebaseSessionsRegistrar.kt:87)
  at com.google.firebase.tracing.ComponentMonitor.lambda$processRegistrar$0 (ComponentMonitor.java:38)
  at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0 (ComponentRuntime.java:160)
  at com.google.firebase.components.Lazy.get (Lazy.java:53)
  at com.google.firebase.components.ComponentContainer.get (ComponentContainer.java:48)
  at com.google.firebase.components.RestrictedComponentContainer.get (RestrictedComponentContainer.java:105)
  at com.google.firebase.sessions.FirebaseSessionsRegistrar.getComponents$lambda$0 (FirebaseSessionsRegistrar.kt:52)
  at com.google.firebase.tracing.ComponentMonitor.lambda$processRegistrar$0 (ComponentMonitor.java:38)
  at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0 (ComponentRuntime.java:160)
  at com.google.firebase.components.Lazy.get (Lazy.java:53)
  at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents (ComponentRuntime.java:322)
  at com.google.firebase.components.ComponentRuntime.initializeEagerComponents (ComponentRuntime.java:312)
  at com.google.firebase.FirebaseApp.initializeAllApis (FirebaseApp.java:607)
  at com.google.firebase.FirebaseApp.initializeApp (FirebaseApp.java:300)
  at com.google.firebase.FirebaseApp.initializeApp (FirebaseApp.java:264)
  at com.google.firebase.FirebaseApp.initializeApp (FirebaseApp.java:249)
  at com.google.firebase.provider.FirebaseInitProvider.onCreate (FirebaseInitProvider.java:69)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2388)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2358)
  at com.google.firebase.provider.FirebaseInitProvider.attachInfo (FirebaseInitProvider.java:61)
  at android.app.ActivityThread.installProvider (ActivityThread.java:7857)
  at android.app.ActivityThread.installContentProviders (ActivityThread.java:7387)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7295)
  at android.app.ActivityThread.access$1700 (ActivityThread.java:309)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2194)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:264)
  at android.app.ActivityThread.main (ActivityThread.java:8315)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:632)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1049)

@pritesh-swiggy
Copy link
Author

Hi, @lehcar09, can you share an latest update on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants