firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.27k stars 574 forks source link

Crash (FirebaseApp is not initialized in this process) or ANR(executing service ***/com.onfido.android.sdk.capture.ui.OnfidoStarterService) with firebase-perf and Onfido start activity for result #5936

Closed ChavanSuyash closed 5 months ago

ChavanSuyash commented 5 months ago

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

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

  1. Build onfido config and startActivityForResult.
  2. Onfido launches the activity in the new process ***:onfido_process.
  3. Don't Init firebase FirebaseApp.initializeApp(this) inside function onCreate() of app for ***:onfido_process. Observe Crash (FirebaseApp is not initialized in this process).
  4. Init firebase FirebaseApp.initializeApp(this) inside function onCreate() of app for ***:onfido_process. Observe ANR.

What happened? - Crash - java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process :onfido_process. Make sure to call FirebaseApp.initializeApp(Context). So firebase perf tracks network requests and can happen if FirebaseApp is not initialized :onfido_process.

ANR - Onfido third-party SDKs also trigger network requests automatically at startup that can block FirebaseApp.

Relevant Code:

Crash FATAL EXCEPTION: dtxEventSenderThread Process: ****:onfido_process, PID: 32030 java.lang.ExceptionInInitializerError at com.google.firebase.perf.config.ConfigResolver.<init>(ConfigResolver.java:78) at com.google.firebase.perf.config.ConfigResolver.getInstance(ConfigResolver.java:86) at com.google.firebase.perf.application.AppStateMonitor.<init>(AppStateMonitor.java:98) at com.google.firebase.perf.application.AppStateMonitor.getInstance(AppStateMonitor.java:87) at com.google.firebase.perf.metrics.NetworkRequestMetricBuilder.<init>(NetworkRequestMetricBuilder.java:92) at com.google.firebase.perf.metrics.NetworkRequestMetricBuilder.builder(NetworkRequestMetricBuilder.java:84) at com.google.firebase.perf.network.FirebasePerfUrlConnection.instrument(FirebasePerfUrlConnection.java:186) at com.dynatrace.android.agent.comm.CommHandler.openConnection(CommHandler.java:147) at com.dynatrace.android.agent.comm.CommHandler.executeRequest(CommHandler.java:48) at com.dynatrace.android.agent.comm.RequestExecutor.handleBeaconRequest(RequestExecutor.java:97) at com.dynatrace.android.agent.comm.RequestExecutor.sendBeacon(RequestExecutor.java:85) at com.dynatrace.android.agent.CommunicationManager.forceUemStateUpdate(CommunicationManager.java:242) at com.dynatrace.android.agent.CommunicationManager.doSenderTask(CommunicationManager.java:514) at com.dynatrace.android.agent.CommunicationManager.access$500(CommunicationManager.java:35) at com.dynatrace.android.agent.CommunicationManager$EventSenderThread.run(CommunicationManager.java:628) Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.bnt.currencydirect.uat:onfido_process. Make sure to call FirebaseApp.initializeApp(Context) first. at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:179) at com.google.firebase.perf.config.RemoteConfigManager.getInitialStartupMillis(RemoteConfigManager.java:91) at com.google.firebase.perf.config.RemoteConfigManager.<init>(RemoteConfigManager.java:85) at com.google.firebase.perf.config.RemoteConfigManager.<clinit>(RemoteConfigManager.java:52) at com.google.firebase.perf.config.ConfigResolver.<init>(ConfigResolver.java:78)  at com.google.firebase.perf.config.ConfigResolver.getInstance(ConfigResolver.java:86)  at com.google.firebase.perf.application.AppStateMonitor.<init>(AppStateMonitor.java:98)  at com.google.firebase.perf.application.AppStateMonitor.getInstance(AppStateMonitor.java:87)  at com.google.firebase.perf.metrics.NetworkRequestMetricBuilder.<init>(NetworkRequestMetricBuilder.java:92)  at com.google.firebase.perf.metrics.NetworkRequestMetricBuilder.builder(NetworkRequestMetricBuilder.java:84)  at com.google.firebase.perf.network.FirebasePerfUrlConnection.instrument(FirebasePerfUrlConnection.java:186)  at com.dynatrace.android.agent.comm.CommHandler.openConnection(CommHandler.java:147)  at com.dynatrace.android.agent.comm.CommHandler.executeRequest(CommHandler.java:48)  at com.dynatrace.android.agent.comm.RequestExecutor.handleBeaconRequest(RequestExecutor.java:97)  at com.dynatrace.android.agent.comm.RequestExecutor.sendBeacon(RequestExecutor.java:85)  at com.dynatrace.android.agent.CommunicationManager.forceUemStateUpdate(CommunicationManager.java:242)  at com.dynatrace.android.agent.CommunicationManager.doSenderTask(CommunicationManager.java:514)  at com.dynatrace.android.agent.CommunicationManager.access$500(CommunicationManager.java:35)  at com.dynatrace.android.agent.CommunicationManager$EventSenderThread.run(CommunicationManager.java:628) 

ANR PID: 29915 Reason: executing service ****/com.onfido.android.sdk.capture.ui.OnfidoStarterService ErrorId: 1bb76e13-2eb6-4e45-87d7-1fdf093853a2 Frozen: false Load: 1.03 / 1.35 / 1.27 ----- Output from /proc/pressure/memory ----- some avg10=0.00 avg60=0.00 avg300=0.00 total=86251029 full avg10=0.00 avg60=0.00 avg300=0.00 total=21456118 ----- End output from /proc/pressure/memory ----- ----- Output from /proc/pressure/cpu ----- some avg10=1.01 avg60=0.66 avg300=0.75 total=1898038473 ----- End output from /proc/pressure/cpu ----- ----- Output from /proc/pressure/io ----- some avg10=0.00 avg60=0.00 avg300=0.00 total=266478494 full avg10=0.00 avg60=0.00 avg300=0.00 total=208767418 ----- End output from /proc/pressure/io ----- CPU usage from 52455ms to -2ms ago (2024-05-07 21:23:36.364 to 2024-05-07 21:24:28.821) with 99% awake: 23% 28704/com.bnt.currencydirect.uat: 21% user + 2.5% kernel / faults: 11961 minor 4.8% 655/surfaceflinger: 3.4% user + 1.3% kernel / faults: 83 minor 2 major 3.8% 1609/system_server: 2% user + 1.7% kernel / faults: 3248 minor 3.1% 657/vendor.qti.hardware.display.composer-service: 1.3% user + 0.8% kernel / faults: 92 minor 1.4% 16729/process-tracker: 0.2% user + 1.2% kernel 1.4% 16733/process-tracker: 0.2% user + 1.2% kernel 1.3% 1099/rlsservice: 0% user + 1.2% kernel 1% 15409/kworker/u16:7+LPASS_DATA: 0% user + 1% kernel / faults: 23 minor 0.9% 29136/kworker/u16:8-DIAG_DCI_DATA: 0% user + 0.9% kernel / faults: 1 minor 0.8% 17950/kworker/u16:17+WCNSS_DCI: 0% user + 0.8% kernel 7.6% TOTAL: 4.4% user + 2.4% kernel + 0% iowait + 0.5% irq + 0.1% softirq CPU usage from 57ms to 737ms later (2024-05-07 21:24:28.876 to 2024-05-07 21:24:29.556): 100% 1609/system_server: 58% user + 41% kernel / faults: 8623 minor 1 major 62% 1730/Signal Catcher: 46% user + 15% kernel 30% 30006/AnrAuxiliaryTas: 12% user + 17% kernel 4.1% 30004/AnrConsumer: 1.5% user + 1.5% kernel 1.5% 1609/system_server: 0% user + 1.5% kernel 1.5% 1734/Jit thread pool: 1.5% user + 0% kernel 1.5% 1918/HwBinder:1609_1: 0% user + 1.5% kernel 1.5% 1966/Thread-2: 0% user + 1.5% kernel 1.5% 2446/android.imms: 1.5% user + 0% kernel 1.5% 2461/NetworkStats: 1.5% user + 0% kernel 1.5% 15925/binder:1609_15: 0% user + 1.5% kernel 38% 16758/com.google.android.inputmethod.latin: 32% user + 6.4% kernel / faults: 3391 minor 41% 16763/Signal Catcher: 35% user + 6.4% kernel 3.2% 16764/perfetto_hprof_: 0% user + 3.2% kernel 3.2% 16767/HeapTaskDaemon: 0% user + 3.2% kernel 8.8% 29060/kworker/u16:0-memlat_wq: 0% user + 8.8% kernel 1.4% 11/rcu_preempt: 0% user + 1.4% kernel 1.4% 64/rcuop/6: 0% user + 1.4% kernel 1.6% 1710/adbd: 1.6% user + 0% kernel / faults: 1 minor 1.6% 1710/adbd: 1.6% user + 0% kernel 1.6% 16638/UsbFfs-worker: 0% user + 1.6% kernel 1.7% 15409/kworker/u16:7-events_unbound: 0% user + 1.7% kernel 3.3% 18169/logcat: 0% user + 3.3% kernel 19% TOTAL: 10% user + 8% kernel + 0.1

google-oss-bot commented 5 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

lehcar09 commented 5 months ago

Hi @ChavanSuyash, thank you for reaching out. Could you share an MCVE/ code snippet that can help us investigate the issue?

Aside from that, I notice that you're not using the latest Firebase SDK version. I suggest updating to the latest Firebase SDK version to get the latest features and bug fixes that might be causing the issues.

google-oss-bot commented 5 months ago

Hey @ChavanSuyash. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 5 months ago

Since there haven't been any recent updates here, I am going to close this issue.

@ChavanSuyash if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.