ANR for Firebase Performance

[READ] Step 1: Are you in the right place?

I do. reporting an ANR coming from RemoteConfigComponent (as far as I can say)

[REQUIRED] Step 2: Describe your environment

Firebase BoM 25.6.0 (Firebase Perf 19.0.8 if I’m not mistaken)

[REQUIRED] Step 3: Describe the problem

We are experiencing thousands ANRs at FirebasePerformance creation step. Looking at the source code, I believe the thread blocks trying to get/create an instance from RemoteConfigComponent.get("fireperf"). that method is access from main thread, is synchronized and internally it executes a few disk accesses.

Here is a stacktrace of the main thread and another one, both blocked.

Main thread:

at com.google.firebase.perf.zza.create (zza.java:2)
  at com.google.firebase.components.ComponentRuntime.lambda$new$0 (ComponentRuntime.java:69)
  at com.google.firebase.components.ComponentRuntime$$Lambda$1.get (ComponentRuntime.java)
  at com.google.firebase.components.Lazy.get (Lazy.java:53)
  at com.google.firebase.components.ComponentRuntime.initializeEagerComponents (ComponentRuntime.java:158)
  at com.google.firebase.FirebaseApp.initializeAllApis (FirebaseApp.java:563)
  at com.google.firebase.FirebaseApp.initializeApp (FirebaseApp.java:304)
  at com.google.firebase.FirebaseApp.initializeApp (FirebaseApp.java:268)
  at com.careem.superapp.core.analytics.impl.firebase.FirebaseInitializer.initialize (FirebaseInitializer.java:33)
  at com.careem.superapp.initialization.BaseSuperApp.onCreate (BaseSuperApp.java:58)
  at com.careem.superapp.SuperApp.onCreate (SuperApp.java:44)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1155)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6315)
  at android.app.ActivityThread.access$1300 (ActivityThread.java:220)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1815)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:226)
  at android.app.ActivityThread.main (ActivityThread.java:7224)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:500)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:913)

Other thread:

at com.google.firebase.components.Lazy.get (SourceFile:3)
  at g.k.c.d.a.get (SourceFile:2)
  at com.google.firebase.components.ComponentRuntime.get (SourceFile:1)
  at com.google.firebase.FirebaseApp.get (SourceFile:2)
  at com.google.firebase.perf.FirebasePerformance.getInstance (SourceFile:5)
  at com.google.firebase.perf.internal.zzd.zzbt (SourceFile:2)
  at com.google.firebase.perf.internal.zzd.zzc (SourceFile:2)
  at g.k.c.k.a.b.run (SourceFile:1)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at java.lang.Thread.run (Thread.java:764)

Steps to reproduce:

Sorry, can’t repro locally. but the above stack trace should give an indication.
I don’t think is relevant, but also wanted to add we disabled the FirebaseInitProvider and we init manually

Relevant Code:

1 possible answer(s) on “ANR for Firebase Performance