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

ANR #2014

Closed
RodolfoGS opened this issue Sep 29, 2020 · 36 comments
Closed

ANR #2014

RodolfoGS opened this issue Sep 29, 2020 · 36 comments

Comments

@RodolfoGS
Copy link

[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:

  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 4.0
  • Firebase Component: Messaging (Database, Firestore, Storage, Functions, etc)
  • Component version: 20.2.4

[REQUIRED] Step 3: Describe the problem

Appear tons of ANR errors in Play Console related to firebase messaging. And a lot of users have the same problem and are reporting in a closed issue of 2 years ago (2018).

Issue closed that continues active with more than 50 comments and 33 participants firebase/quickstart-android#594

image

Steps to reproduce:

I can't reproduce, I just see the issues in the play console.

Relevant Code:

Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 pkg=xxx cmp=xxx/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) }, InvisibleToUser

com.google.firebase.iid.FirebaseInstanceIdReceiver


"main" prio=5 tid=1 Runnable
  | group="main" sCount=0 dsCount=0 flags=4 obj=0x713d3fc8 self=0x788ebc1c00
  | sysTid=22434 nice=0 cgrp=default sched=0/0 handle=0x7890126ed0
  | state=R schedstat=( 310821836 210351148 893 ) utm=8 stm=22 core=0 HZ=100
  | stack=0x7fe8780000-0x7fe8782000 stackSize=8192KB
  | held mutexes= "mutator lock"(shared held)
  at com.google.firebase.internal.DataCollectionConfigStorage.directBootSafe (DataCollectionConfigStorage.java)
  at com.google.firebase.internal.DataCollectionConfigStorage.isEnabled (DataCollectionConfigStorage.java)
  at com.google.firebase.internal.DataCollectionConfigStorage.setEnabled (DataCollectionConfigStorage.java)
  at com.google.firebase.FirebaseApp.isDataCollectionDefaultEnabled (FirebaseApp.java)
  at java.lang.reflect.Method.invoke (Method.java)
  at io.fabric.sdk.android.services.common.FirebaseAppImpl.getInstance (FirebaseAppImpl.java)
  at io.fabric.sdk.android.services.common.FirebaseAppImpl.isDataCollectionDefaultEnabled (FirebaseAppImpl.java)
  at io.fabric.sdk.android.services.common.DataCollectionArbiter.getInstance (DataCollectionArbiter.java)
  at io.fabric.sdk.android.services.common.DataCollectionArbiter.isDataCollectionEnabled (DataCollectionArbiter.java)
  at com.crashlytics.android.core.CrashlyticsCore.access$100 (CrashlyticsCore.java)
  at com.crashlytics.android.core.CrashlyticsCore.doLog (CrashlyticsCore.java)
  at com.crashlytics.android.core.CrashlyticsCore.isBuildIdValid (CrashlyticsCore.java)
  at com.crashlytics.android.core.CrashlyticsCore.log (CrashlyticsCore.java)
  at com.crashlytics.android.core.CrashlyticsCore.logException (CrashlyticsCore.java)
  at com.crashlytics.android.core.CrashlyticsCore.onPreExecute (CrashlyticsCore.java)
  at com.crashlytics.android.core.CrashlyticsCore.setCrashlyticsNdkDataProvider (CrashlyticsCore.java)
  at com.crashlytics.android.core.CrashlyticsCore.setString (CrashlyticsCore.java)
  at com.crashlytics.android.core.CrashlyticsCore.onPreExecute (CrashlyticsCore.java)
  at io.fabric.sdk.android.InitializationTask.onPreExecute (InitializationTask.java)
  at io.fabric.sdk.android.services.concurrency.AsyncTask.access$200 (AsyncTask.java)
  at io.fabric.sdk.android.services.concurrency.AsyncTask.access$300 (AsyncTask.java)
  at io.fabric.sdk.android.services.concurrency.AsyncTask.doInBackground (AsyncTask.java)
  at io.fabric.sdk.android.services.concurrency.AsyncTask.executeOnExecutor (AsyncTask.java)
  at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.addDependency (PriorityAsyncTask.java)
  at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.addDependency (PriorityAsyncTask.java)
  at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.executeOnExecutor (PriorityAsyncTask.java)
  at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.isFinished (PriorityAsyncTask.java)
  at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.setError (PriorityAsyncTask.java)
  at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.setFinished (PriorityAsyncTask.java)
  at io.fabric.sdk.android.Kit.initialize (Kit.java)
  at io.fabric.sdk.android.Fabric.access$300 (Fabric.java)
  at io.fabric.sdk.android.Fabric.getExecutorService (Fabric.java)
  at io.fabric.sdk.android.Fabric.getKitMap (Fabric.java)
  at io.fabric.sdk.android.Fabric.initializeKits (Fabric.java)
  at io.fabric.sdk.android.Fabric.init (Fabric.java)
  at io.fabric.sdk.android.Fabric.access$100 (Fabric.java)
  at io.fabric.sdk.android.Fabric.getIdentifier (Fabric.java)
  at io.fabric.sdk.android.Fabric.setFabric (Fabric.java)
  at io.fabric.sdk.android.Fabric.extractActivity (Fabric.java)
  at io.fabric.sdk.android.Fabric.getKits (Fabric.java)
  at io.fabric.sdk.android.Fabric.with (Fabric.java)
- locked <0x0b22d8d5> (a java.lang.Class<h.a.a.a.c>)
  at io.invertase.firebase.crashlytics.ReactNativeFirebaseCrashlyticsInitProvider.onCreate (ReactNativeFirebaseCrashlyticsInitProvider.java)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2092)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2066)
  at io.invertase.firebase.common.ReactNativeFirebaseInitProvider.attachInfo (ReactNativeFirebaseInitProvider.java)
  at android.app.ActivityThread.installProvider (ActivityThread.java:7237)
  at android.app.ActivityThread.installContentProviders (ActivityThread.java:6782)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6693)
  at android.app.ActivityThread.access$1400 (ActivityThread.java:232)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2014)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:241)
  at android.app.ActivityThread.main (ActivityThread.java:7617)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:941)
@google-oss-bot
Copy link
Contributor

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

@zwu52
Copy link
Member

zwu52 commented Oct 9, 2020

Previously FIID broadcast handling was done and main thread and caused lots of ANR. It was fixed and rolled out earlier this year (not sure which release was in. Likely >= 20.1.3). IIRC, you updated the app to 20.2.4 but still sees many ANR crashes. Do you have any insights on the demographics of the SDK versions these crashes are on?

@PratyeshSingh
Copy link

PratyeshSingh commented Oct 21, 2020

I was also getting the same ANR. So i'm sharing my finding here with you all guys to reduce this ANR.

Memory Leak can be one reason for emitting this com.google.firebase.iid.firebaseinstanceidreceiver ANR.
So you can verify on Android profiler for memory leak, If memory leak issue is fixed then this ANR automatically come DOWN.

Hope this help to all you guys.

@PratyeshSingh
Copy link

PratyeshSingh commented Nov 24, 2020

Hi @zwu52 @google-oss-bot ,
Here is one use case in which we can reproduce this ANR.

I have many app in my phone which receive daily 200+ push-notification each-app every-day. So i putted my device offline for 2-3days, later then came to online and then started getting notification more than 1000+ PNs (older & pending PN).

Log Details:-
_#00 pc 0000000000071160 /system/lib64/libc.so (__epoll_pwait+8)
#00 pc 0000000000014200 /system/lib64/libutils.so (android::Looper::pollInner(int)+144)
#00 pc 00000000000140cc /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+60)
#00 pc 0000000000127264 /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, jobject*, long, int)+44)
at android.os.MessageQueue.nativePollOnce (MessageQueue.java)
at android.os.MessageQueue.next (MessageQueue.java:326)
at android.os.Looper.loop (Looper.java:190)
at android.app.ActivityThread.main (ActivityThread.java:7212)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:499)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:942)

Device details:-

Screenshot 2020-11-24 at 9 45 01 AM


So in my opinion, if we receive many PN at same time this ANR surely occur.

@google-oss-bot @zwu52 kindly look on this use case. while receiving 500+ push-notifications is their a way to properly schedule these many push notification to prevent this happening?

@Jack29913
Copy link

I am also seeing this issue.
Especially after migrating from 20.1.7 to 20.3.0 and changing targetSDKVersion to 30.
This is critical as my app passed ANR threshold because of this.
And no, it has nothing to do with memory leak.

@zwu52
Copy link
Member

zwu52 commented Jan 19, 2021

@Jack29913
I am sure you have traced through #594 and wasn't able to fixed your issue. Do you mind verifying or pasting (event better) your stack trace here. ANR issues had different causes and does yours also consist these com.crashlytics.android.core.CrashlyticsCore calls?

@rlazo Rodrigo,
This particular ANR looks like to be a triggered in a crashlytics call path? can we route in crashlytics folks to take a look

@Jack29913
Copy link

Jack29913 commented Jan 20, 2021

@zwu52
Broadcast of Intent act=com.google.android.c2dm.intent.RECEIVE flg=0x10000010
com.google.firebase.iid.FirebaseInstanceIdReceive
Android 5.0 - Android 7.1
main" prio=5 tid=1 Waiting

  at java.lang.Object.wait! (Native method)
  at java.lang.Thread.parkFor$ (Thread.java:1220)
  at sun.misc.Unsafe.park (Unsafe.java:299)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:158)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt (AbstractQueuedSynchronizer.java:810)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly (AbstractQueuedSynchronizer.java:970)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly (AbstractQueuedSynchronizer.java:1278)
  at java.util.concurrent.CountDownLatch.await (CountDownLatch.java:203)
  at android.app.SharedPreferencesImpl$EditorImpl$1.run (SharedPreferencesImpl.java:366)
  at android.app.QueuedWork.waitToFinish (QueuedWork.java:88)
  at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4134)
  at android.app.ActivityThread.access$2400 (ActivityThread.java:229)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1924)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:148)
  at android.app.ActivityThread.main (ActivityThread.java:7325)
  at java.lang.reflect.Method.invoke! (Native method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)

com.google.firebase.crashlytics.startup1" prio=5 tid=15 Waiting

  at java.lang.Object.wait! (Native method)
  at java.lang.Thread.parkFor (Thread.java:1220)
  at sun.misc.Unsafe.park (Unsafe.java:299)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:157)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2016)
  at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:410)
  at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1035)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1097)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
  at com.google.firebase.crashlytics.internal.common.ExecutorUtils$1$1.onRun (ExecutorUtils.java:1)
  at com.google.firebase.crashlytics.internal.common.BackgroundPriorityRunnable.run (BackgroundPriorityRunnable.java:2)
  at java.lang.Thread.run (Thread.java:818)

GoogleApiHandler" prio=5 tid=24 Blocked

  at com.android.org.conscrypt.PinFailureLogger.log (PinFailureLogger.java:35)
  at com.android.org.conscrypt.PinListEntry.logPinFailure (PinListEntry.java:154)
  at com.android.org.conscrypt.PinListEntry.isChainValid (PinListEntry.java:106)
  at com.android.org.conscrypt.CertPinManager.isChainValid (CertPinManager.java:79)
  at com.android.org.conscrypt.TrustManagerImpl.checkTrusted (TrustManagerImpl.java:302)
  at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted (TrustManagerImpl.java:219)
  at java.lang.reflect.Method.invoke! (Native method)
  at java.lang.reflect.Method.invoke (Method.java:372)
  at com.google.android.gms.org.conscrypt.Platform.checkTrusted (com.google.android.gms@204516007@20.45.16 (020304-344294571):2)
  at com.google.android.gms.org.conscrypt.Platform.checkServerTrusted (com.google.android.gms@204516007@20.45.16 (020304-344294571):3)
  at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.verifyCertificateChain (com.google.android.gms@204516007@20.45.16 (020304-344294571):5)
  at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake (Native method)
  at com.google.android.gms.org.conscrypt.NativeSsl.doHandshake (com.google.android.gms@204516007@20.45.16 (020304-344294571):6)
  at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake (com.google.android.gms@204516007@20.45.16 (020304-344294571):16)
  at com.google.android.gms.org.conscrypt.KitKatPlatformOpenSSLSocketImplAdapter.startHandshake (com.google.android.gms@204516007@20.45.16 (020304-344294571))
  at com.android.okhttp.Connection.upgradeToTls (Connection.java:1253)
  at com.android.okhttp.Connection.connect (Connection.java:1184)
  at com.android.okhttp.internal.http.HttpEngine.connect (HttpEngine.java:395)
  at com.android.okhttp.internal.http.HttpEngine.sendRequest (HttpEngine.java:298)
  at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute (HttpURLConnectionImpl.java:399)
  at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect (HttpURLConnectionImpl.java:110)
  at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream (HttpURLConnectionImpl.java:221)
  at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getOutputStream (DelegatingHttpsURLConnection.java:218)
  at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream (HttpsURLConnectionImpl.java:25)
  at com.google.android.gms.internal.firebase
  at com.google.android.gms.internal.firebase
  at com.google.android.gms.internal.firebase
  at com.google.android.gms.internal.firebase
  at com.google.android.gms.internal.firebase
  at com.google.android.gms.internal.firebase
  at com.google.android.gms.common.api.internal.zacj.doExecute
  at com.google.android.gms.common.api.internal.zah.zaa
  at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zac
  at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zab
  at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zap
  at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zao
  at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.onConnected
  at com.google.android.gms.common.internal.zag.onConnected
  at com.google.android.gms.common.internal.BaseGmsClient$zzf.zza
  at com.google.android.gms.common.internal.BaseGmsClient$zza.zza
  at com.google.android.gms.common.internal.BaseGmsClient$zzc.zzc
  at com.google.android.gms.common.internal.BaseGmsClient$zzb.handleMessage
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:135)
  at android.os.HandlerThread.run (HandlerThread.java:61)

Broadcast of Intent act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010
com.google.firebase.iid.FirebaseInstanceIdReceive
Android 9 - Android 10
main" prio=5 tid=1 Native

#00  pc 0000000000096394  /apex/com.android.runtime/lib/bionic/libc.so (__epoll_pwait+20)
 #00  pc 0000000000068d45  /apex/com.android.runtime/lib/bionic/libc.so (epoll_wait+16)
 #00  pc 0000000000010643  /system/lib/libutils.so (android::Looper::pollInner(int)+118)
 #00  pc 0000000000010553  /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+30)
 #00  pc 00000000000d285f  /system/lib/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long long, int)+24)
 at android.os.MessageQueue.nativePollOnce (Native method)
 at android.os.MessageQueue.next (MessageQueue.java:336)
 at android.os.Looper.loop (Looper.java:182)
 at android.app.ActivityThread.main (ActivityThread.java:7563)
 at java.lang.reflect.Method.invoke (Native method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:539)
 at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:994)

"Crashlytics Exception Handler1" prio=5 tid=20 Waiting

  at sun.misc.Unsafe.park (Native method)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2067)
  at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:442)
  at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1092)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1152)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at com.google.firebase.crashlytics.internal.common.ExecutorUtils$1$1.onRun (ExecutorUtils.java:1)
  at com.google.firebase.crashlytics.internal.common.BackgroundPriorityRunnable.run (BackgroundPriorityRunnable.java:2)
  at java.lang.Thread.run (Thread.java:919)

"com.google.firebase.crashlytics.startup1" prio=5 tid=21 Waiting

  at sun.misc.Unsafe.park (Native method)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2067)
  at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:442)
  at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1092)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1152)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at com.google.firebase.crashlytics.internal.common.ExecutorUtils$1$1.onRun (ExecutorUtils.java:1)
  at com.google.firebase.crashlytics.internal.common.BackgroundPriorityRunnable.run (BackgroundPriorityRunnable.java:2)
  at java.lang.Thread.run (Thread.java:919)

@zwu52
Copy link
Member

zwu52 commented Jan 20, 2021

Jack,
Processes seem to be waiting on GMS. Can you confirm if your play service is up2date and what is the version number?

@Jack29913
Copy link

Jack29913 commented Jan 21, 2021

@zwu52
Are you asking these?
classpath 'com.google.gms:google-services:4.3.4'

'com.google.android.gms:play-services-base:17.5.0'
'com.google.firebase:firebase-messaging:21.0.1'

@zjamshidi
Copy link

zjamshidi commented Feb 3, 2021

I'm facing the same issue

classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1'
...
implementation 'com.google.firebase:firebase-messaging:21.0.0'

image

@JeremyR34
Copy link

Same issue here
implementation platform('com.google.firebase:firebase-bom:26.3.0')

@zwu52
Copy link
Member

zwu52 commented Feb 5, 2021

@Jack29913 Jack,
Thanks for the info and patience. I can't seem to reproduce the ANR with the corresponding config. Here is what we can decipher from the attached stack scripts.

For 1st one on Android 5.0 - Android 7.1, main shows the last trace to be on some shared preference operations. Couple possible reasons that this can happen. 1. Shared preference is dead locked somehow. 2. Shared preference is ok and the stack just trace shows the tail of your processes. This could be caused by slow disk write typically on older devices where storage is less than 1G.

For 2nd one on Android 9 - Android 10, the UI thread seems to be just chilling out and not blocked.

I'd like to triage this to our Crashlytics folks to further diagnose if possible.

@zjamshidi @JeremyR34, the ANR could be caused by various reasons, please check out the #594 to see if it helps. Otherwise, we'll update in this thread.

@mrwillis21
Copy link
Contributor

Hi everyone - just wanted to let you know that the com.crashlytics... SDK is deprecated, and that it should be replaced with com.google.firebase.crashlytics.

@zjamshidi
Copy link

@zwu52 You are true. ANR could be caused by other reasons. I made some changes in my code and will see if the resolve the issue.

@Jack29913
Copy link

I am using firebase.crashlytics already. And seeing massive numbers anr's coming from every android versions except 11: 5.0, 5.1, 6.0, 7.0, 7.1, 8.0, 8.1, 9 and 10.
This is my top 4 ANR's.

Screen Shot 2021-02-09 at 17 36 47

@nzayatz14
Copy link

I also started receiving these ANRs when updating com.google.firebase:firebase-messaging from 20.1.7 to 21.0.1.

Also, I have seen them happen on Android 11 devices

ANR

@rlazo rlazo removed their assignment Feb 9, 2021
@RodolfoGS
Copy link
Author

@google-oss-bot ¯_(ツ)_/¯

@joelfernandes19
Copy link

We have high volume of DAUs and we're seeing this ANR more often. Using com.google.firebase:firebase-messaging version 20.1.7.

Any updates on this?

firebase iid anr

--

@nzayatz14 @zjamshidi after updating to 21.0.0 (or above) do you notice any drop in ANRs?

@nzayatz14
Copy link

@joelfernandes19 I actually had a huge increase in ANRs when upgrading to 21.0.1. I recently reverted back to 20.1.7 and the ANRs went away

@zjamshidi
Copy link

I fixed the ANRS. They weren't related to Firebase SDK and the source was how we access the DB.

@RodolfoGS
Copy link
Author

@zjamshidi Could you share what kind of changes you made?, maybe I or anyone have the same issue. Thanks,

@zjamshidi
Copy link

The ANR was:
Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=xxxx cmp=xxxx/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) }

So I was suspicious of Firebase SDK but when I checked the stack trace I noticed we wait for reading data from DB in the application onCreate method.

at java.lang.Object.wait (Object.java)
  at java.lang.Thread.parkFor$ (Thread.java:2137)
  at sun.misc.Unsafe.park (Unsafe.java:358)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)
  at java.util.concurrent.FutureTask.awaitDone (FutureTask.java:450)
  at java.util.concurrent.FutureTask.get (FutureTask.java:192)
  at android.os.AsyncTask.get (AsyncTask.java:542)
  at xxxx.objectmodel.DatabaseHandler.getUser (DatabaseHandler.java:1125)
  at xxxx.utility.UserUtil.<init> (UserUtil.java:66)
  at xxxx.utility.UserUtil.getInstance (UserUtil.java:73)
  at xxxx.XApp.onCreate (XApp.java:118)

I moved this part from the application onCreate to the first activity after the splash and it's fixed now.

In general, what I learned is we should not do or wait for a task that may take longer than 5 seconds (like reading data from db) on the main thread. Very simple!

@RodolfoGS
Copy link
Author

@zjamshidi Got it, I'll check that in my app, thanks a lot!

@Jack29913
Copy link

Jack29913 commented Mar 8, 2021

This is not the case at all. This is the stacktrace of main thread. Also there is no DB access in our app.
Firebase changed something in their code, we didn't get so many ANR's before.

#00 pc 0000000000055780 /system/lib/libc.so (__epoll_pwait+20) #00 pc 0000000000027159 /system/lib/libc.so (epoll_wait+16) #00 pc 000000000000f0e9 /system/lib/libutils.so (android::Looper::pollInner(int)+116) #00 pc 000000000000eff3 /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+26) #00 pc 00000000000be47d /system/lib/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long long, int)+26) at android.os.MessageQueue.nativePollOnce (Native method) at android.os.MessageQueue.next (MessageQueue.java:326) at android.os.Looper.loop (Looper.java:181) at android.app.ActivityThread.main (ActivityThread.java:7073) at java.lang.reflect.Method.invoke (Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:965)

@sahillikeminds
Copy link

any luck so far?

@Jack29913
Copy link

Jack29913 commented Apr 12, 2021

nope. they probably think if no one talks about it, it will magically solve itself.

@mtrezza
Copy link

mtrezza commented Apr 15, 2021

Same issue on com.google.firebase:firebase-messaging:21.0.0, but there is a 21.1.0 release which may fix it:

  • Migrated internal handling of new token callbacks and notification actions from Firebase Instance ID to Firebase Cloud Messaging.
  • Added functionality to generate FCM tokens from FirebaseMessaging.getToken, while continuing to call through to Firebase Instance ID if it is present. This will allow Firebase Cloud Messaging to remove its dependency on Firebase Instance ID in the future.

It actually removes the dependency on FirebaseInstanceId which is always part of these crash logs.
You'd need to get the token from FirebaseMessaging instead of FirebaseInstanceId, see here.

Did anyone try, using BoM 27.0.0?

@wangirving
Copy link

I have been following this issue for a long time. I found that after I started using App Bundle recently, the anr is much less.I didn't do anything else.

@zwu52
Copy link
Member

zwu52 commented Apr 28, 2021

To organize the thread bit since there is a mix of ANR here, some are resolved some aren't yet resolved. Below are two seemingly ongoing issue:

OP @RodolfoGS on FM 20.2.4: ANRing in the FirebaseApp init ContentProvider (before FM initialization). The original stack traces shows dependencies on deprecated com. crashlytics. @RodolfoGS please let us know if your ANRs were resolved after updating the dependecies.

@Jack29913 on FM 20.3.0 stack traces. It looks like FM threads aren't blocked or locked. It might be app taking too long to process the broadcast? I am seeing there is a change to optimize FM internal broadcast flows that is code ready and queued up for upcoming release. I'll update the thread and please monitor and feedback @Jack29913

@prcaen
Copy link

prcaen commented May 19, 2021

@mtrezza have you try BOM 27.0.0 or above finally?
Does it fix?
Thanks

@prcaen
Copy link

prcaen commented May 21, 2021

I updated BOM to version 28.0.1, and still have the ANR :(.

@kiranInmobi
Copy link

Any update on this? Even we are facing lot many ANR

@zwu52
Copy link
Member

zwu52 commented Aug 3, 2021

Hi @prcaen , @kiranInmobi and rest of friends who are experiencing ANR,

I am inclining to close this thread because it's becoming a soup of ANR by different root cause as far as I could tell and hard to read and follow for folks coming later.

Please read above & see if you could find your crashes/fixes above. If not, please fill a separate bug attaching a full bug report.

As you might have noticed from above, ANR could be caused by many factors including low RAM/disk, fcm related, non-fcm related issues. Majority of the stack traces provided don't contain enough information for us to diagnose forward. So if a comprehensive bug report or logcat could be provided that would super helpful and greatly appreciated.

Cheers 🍺

@google-oss-bot
Copy link
Contributor

Hey @RodolfoGS. 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
Copy link
Contributor

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

@RodolfoGS 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.

@firebase firebase locked and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests