Quickstart-android: ANR

Created on 10 Aug 2018  ·  56Comments  ·  Source: firebase/quickstart-android

Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 pkg=com.addcn.android.house591 cmp=com.addcn.android.house591/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) }
com.google.firebase.iid.FirebaseInstanceIdReceiver
messaging internal-bug-filed

Most helpful comment

You are literally the 4th result on the first page of search results for "Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 ANR". It would be good of you to take on a bit of responsibility and investigate.

If you read the news group thread at search result 3 it looks like Vitalii may have already debugged it for you. https://groups.google.com/d/msg/firebase-talk/5mo7-z8gqFA/RugthckUCgAJ. I cannot overstate my disappointment with such apathy.

All 56 comments

@LiuDongCai this is not enough information to debug. Are you getting this from Crashlytics or something? Is this a new issue? If so, does it correspond to an SDK update?

@samtstern
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x72f69730 self=0x7532ac3a00
| sysTid=17865 nice=0 cgrp=default sched=0/0 handle=0x75374189b0
| state=S schedstat=( 1887679225 229007884 1067 ) utm=162 stm=26 core=1 HZ=100
| stack=0x7fea58c000-0x7fea58e000 stackSize=8MB
| held mutexes=
#00 pc 0000000000068e18 /system/lib64/libc.so (__epoll_pwait+8)
#01 pc 000000000001fa98 /system/lib64/libc.so (epoll_pwait+48)
#02 pc 0000000000015c1c /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+144)
#03 pc 0000000000015b04 /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+108)
#04 pc 0000000000111de4 /system/lib64/libandroid_runtime.so (???)
#05 pc 00000000001e605c /system/framework/arm64/boot-framework.oat (Java_android_os_MessageQueue_nativePollOnce__JI+140)
at android.os.MessageQueue.nativePollOnce (Native method)
at android.os.MessageQueue.next (MessageQueue.java:375)
at android.os.Looper.loop (Looper.java:225)
at android.app.ActivityThread.main (ActivityThread.java:6572)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:767)

This is anr in Google play. It just happen at Android 8.0.
And my Firebase Version:
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.firebase:firebase-perf:16.0.0'

@LiuDongCai while I do believe this is a real issue for you, it's not possible to begin fixing it unless we can reproduce the issue as well.

See this page for more information on how to file an actionable bug report:
https://stackoverflow.com/help/mcve

You are literally the 4th result on the first page of search results for "Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 ANR". It would be good of you to take on a bit of responsibility and investigate.

If you read the news group thread at search result 3 it looks like Vitalii may have already debugged it for you. https://groups.google.com/d/msg/firebase-talk/5mo7-z8gqFA/RugthckUCgAJ. I cannot overstate my disappointment with such apathy.

@nmr8acme sorry that you're disappointed. It certainly wasn't "apathy" that led me to close this issue, it was a lack of the information we need to debug the issue. A copy-pasted dump from a crash report just isn't enough.

Your link to the google groups post (which I hadn't seen before) contains much more information and is very helpful! I will use this to file a more detailed bug report with the authors of the InstanceID SDK and see if they can fix it.

Looking at the source for FirebaseInstanceIdReceiver I can see that the potentially problematic code has been changed a few times since Vitali deobfuscated it, so it's possible a fix is already in. I will report back.

Requiring a repro is a rather high bar to set for what looks like a tricky bug. Thank you for pursuing it. FWIW I am experiencing this bug on firebase-iid 16.0.0. I'll try updating, which, to complain more, would be substantially easier if InstanceIDListenerService hadn't been deprecated.

Here are some initial thoughts I got from the engineer who wrote the code involved here (slightly paraphrased to remove internal terminology).

It seems that we're aware of the general issue and we're using a number of techniques to try and avoid this, but there are still cases where the broadcast doesn't finish fast enough and we see ANRs. We are continuing to investigate.


An FCM message broadcast comes in via the FirebaseInstanceIdReceiver which routes it to FirebaseMessagingService (and/or FirebaseInstanceIdService if it's IID related).

If the app is running on a device startService, they get a background service, virtually no chance of an ANR as the receiver will always finish quickly.

[...]

For normal priority messages, we keep the broadcast going (via goAsync), and bind to their service. This gives 60s for their service to run before the broadcast ANRs. As a fail safe we also set a 9s timer to finish the broadcast if their code is still running to avoid ANRs, at this stage there's no guarantee Android won't just kill their app even though their code is still running - they could use a foreground service, or schedule the work for later if they wanted to.

The [recent changes mean] that for high priority messages, where [the system gives] the app a short whitelist that allows them to take wake locks, hit the network, start services, etc. we use startService, similar to what we used to do which should greatly reduce the rate of ANRs. If this fails for whatever reason we fall back to using the bind approach above.

This is much more important here as for high priority messages we use a foreground broadcast that triggers an ANR in the receiver after 10s (which is why we set the timeout to 9s) - but worse than that can cause system issues as foreground broadcasts are expected to be fast.

Even with that change though I still hear some reports of ANRs, which I haven't been able to diagnose.

@nmr8acme our reccomendations right now:

  • Update your dependencies to the latest version if possible (partial fixes went into firebase-iid version 17.0.2 but you might as well use the latest).
  • Look for any operations your app does in response to high-priority messages that could take more than 10 seconds and consider adding a shorter timeout to avoid the operations being killed by the system.
  • Look out for any possibly slow operations in your Applications onCreate method, which could cause an ANR if your app takes too long to respond to a message.

Great advice, thanks. Part of what makes this a tough bug is that the stack traces in the ANR tombstones are "empty", i.e. main thread is not blocked, just sitting there in the looper, which is a bit baffling.

  #00  pc 000000000004a4d0  /system/lib/libc.so (__epoll_pwait+20)
   #01  pc 000000000001bcd5  /system/lib/libc.so (epoll_pwait+60)
   #02  pc 000000000001bd05  /system/lib/libc.so (epoll_wait+12)
   #03  pc 0000000000010407  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+118)
   #04  pc 00000000000102f9  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+32)
   #05  pc 00000000000e465d  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+24)
   #06  pc 00000000001a8b45  /system/framework/arm/boot-framework.oat (Java_android_os_MessageQueue_nativePollOnce__JI+92)
   at android.os.MessageQueue.nativePollOnce (Native method)
   at android.os.MessageQueue.next (MessageQueue.java:325)
   at android.os.Looper.loop (Looper.java:142)
   at android.app.ActivityThread.main (ActivityThread.java:6938)
   at java.lang.reflect.Method.invoke (Native method)
   at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

We had the same ANR issue
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x72885518 self=0xf098f000
| sysTid=13756 nice=0 cgrp=default sched=0/0 handle=0xf4b944a4
| state=S schedstat=( 1682598454 870098442 3521 ) utm=127 stm=40 core=3 HZ=100
| stack=0xff63a000-0xff63c000 stackSize=8MB
| held mutexes=
#00 pc 0000000000049bcc /system/lib/libc.so (__epoll_pwait+20)
#01 pc 000000000001b4c9 /system/lib/libc.so (epoll_pwait+60)
#02 pc 000000000001b4f9 /system/lib/libc.so (epoll_wait+12)
#03 pc 0000000000010163 /system/lib/libutils.so (android::Looper::pollInner(int)+118)
#04 pc 0000000000010055 /system/lib/libutils.so (android::Looper::pollOnce(int, int, int, void*)+32)
#05 pc 00000000000b95e1 /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv
, _jobject*, int)+24)
#06 pc 000000000019b9fd /system/framework/arm/boot-framework.oat (Java_android_os_MessageQueue_nativePollOnce__JI+92)
at android.os.MessageQueue.nativePollOnce (Native method)
at android.os.MessageQueue.next (MessageQueue.java:379)
at android.os.Looper.loop (Looper.java:144)
at android.app.ActivityThread.main (ActivityThread.java:7555)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:963)

same thing to me

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

"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x722f2840 self=0xa5544000
| sysTid=5909 nice=0 cgrp=default sched=0/0 handle=0xa9cbb4b8
| state=S schedstat=( 0 0 0 ) utm=21 stm=21 core=3 HZ=100
| stack=0xbe356000-0xbe358000 stackSize=8MB
| held mutexes=
#00 pc 0000000000049974 /system/lib/libc.so (__epoll_pwait+20)
#01 pc 000000000001ba15 /system/lib/libc.so (epoll_pwait+60)
#02 pc 000000000001ba45 /system/lib/libc.so (epoll_wait+12)
#03 pc 000000000001002d /system/lib/libutils.so (android::Looper::pollInner(int)+120)
#04 pc 000000000000ff1d /system/lib/libutils.so (android::Looper::pollOnce(int, int, int, void*)+32)
#05 pc 00000000000ba081 /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv
, _jobject*, int)+24)
#06 pc 0000000000176265 /system/framework/arm/boot-framework.oat (Java_android_os_MessageQueue_nativePollOnce__JI+92)
at android.os.MessageQueue.nativePollOnce (Native method)
at android.os.MessageQueue.next (MessageQueue.java:325)
at android.os.Looper.loop (Looper.java:142)
at android.app.ActivityThread.main (ActivityThread.java:7000)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)

@samtstern i have some operations that could take more than 10 seconds but i use AsyncTask to execute those operations even i tried with WorkManager and the result is the same i got a lot of ARNs
this problem happens even with this library com.google.android.gms.ads
i got this similar ARN

Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000010

pkg=schan.main cmp=schan.main/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) ### }, VisibleToUser

com.google.firebase.iid.FirebaseInstanceIdReceiver


Motorola Moto X Play (lux), Android 7.1

"main" tid=1 WaitingForGc 
"main" prio=5 tid=1 WaitingForGcToComplete
  | group="main" sCount=1 dsCount=0 obj=0x73ffd700 self=0xa5504400
  | sysTid=25274 nice=-10 cgrp=default sched=0/0 handle=0xa8207534
  | state=S schedstat=( 337564206094 73424441135 444182 ) utm=29001 stm=4754 core=0 HZ=100
  | stack=0xbe37d000-0xbe37f000 stackSize=8MB
  | held mutexes=
  #00  pc 00000000000174d4  /system/lib/libc.so (syscall+28)
  #01  pc 00000000000b6fc9  /system/lib/libart.so (_ZN3art17ConditionVariable16WaitHoldingLocksEPNS_6ThreadE+92)
  #02  pc 0000000000186839  /system/lib/libart.so (_ZN3art2gc4Heap25WaitForGcToCompleteLockedENS0_7GcCauseEPNS_6ThreadE+236)
  #03  pc 0000000000192b79  /system/lib/libart.so (_ZN3art2gc4Heap19WaitForGcToCompleteENS0_7GcCauseEPNS_6ThreadE+172)
  #04  pc 000000000018ce8d  /system/lib/libart.so (_ZN3art2gc4Heap22AllocateInternalWithGcEPNS_6ThreadENS0_13AllocatorTypeEbjPjS5_S5_PPNS_6mirror5ClassE+84)
  #05  pc 0000000000127b8d  /system/lib/libart.so (_ZN3art2gc4Heap24AllocObjectWithAllocatorILb1ELb1ENS_6mirror21SetStringCountVisitorEEEPNS3_6ObjectEPNS_6ThreadEPNS3_5ClassEjNS0_13AllocatorTypeERKT1_+2360)
  #06  pc 000000000029c9cd  /system/lib/libart.so (_ZN3art6mirror6String14AllocFromUtf16EPNS_6ThreadEiPKt+84)
  #07  pc 000000000027cdff  /system/lib/libart.so (_ZN3art3JNI9NewStringEP7_JNIEnvPKti+430)
  #08  pc 000000000009334d  /system/lib/libandroid_runtime.so (???)
  #09  pc 0000000000c03db5  /data/dalvik-cache/arm/system@[email protected] (Java_android_os_Parcel_nativeReadString__J+88)
  at android.os.Parcel.nativeReadString (Native method)
  at android.os.Parcel.readString (Parcel.java:1738)
  at android.content.pm.ApplicationInfo.<init> (ApplicationInfo.java:1019)
  at android.content.pm.ApplicationInfo.<init> (ApplicationInfo.java)
  at android.content.pm.ApplicationInfo$1.createFromParcel (ApplicationInfo.java:996)
  at android.content.pm.ApplicationInfo$1.createFromParcel (ApplicationInfo.java:995)
  at android.content.pm.PackageInfo.<init> (PackageInfo.java:352)
  at android.content.pm.PackageInfo.<init> (PackageInfo.java)
  at android.content.pm.PackageInfo$1.createFromParcel (PackageInfo.java:332)
  at android.content.pm.PackageInfo$1.createFromParcel (PackageInfo.java:331)
  at android.content.pm.IPackageManager$Stub$Proxy.getPackageInfo (IPackageManager.java:2493)
  at android.app.ApplicationPackageManager.getPackageInfoAsUser (ApplicationPackageManager.java:139)
  at android.app.ApplicationPackageManager.getPackageInfo (ApplicationPackageManager.java:132)
  at com.google.android.gms.common.GooglePlayServicesUtilLight.zza (unavailable:34)
  at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable (unavailable:22)
  at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable (unavailable:5)
  at com.google.android.gms.internal.ads.zzazt.zzc (unavailable:67)
  at com.google.android.gms.internal.ads.zzys.zzd (unavailable:35)
  at com.google.android.gms.internal.ads.zzabb.zza (unavailable:100)
  at com.google.android.gms.ads.BaseAdView.loadAd (unavailable:15)
  at com.google.android.gms.ads.AdView.loadAd (unavailable:18)
  at schan.main.ChatActivity.loadAds (ChatActivity.java:614)
  at schan.main.ChatActivity.onCreate (ChatActivity.java:551)
  at android.app.Activity.performCreate (Activity.java:6687)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1140)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2631)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2743)
  at android.app.ActivityThread.-wrap12 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1490)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:6165)
  at java.lang.reflect.Method.invoke! (Native method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:888)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:778)
"Jit thread pool worker thread 0" tid=2 Native 
"FinalizerWatchdogDaemon" tid=5 Sleeping 
"FinalizerDaemon" tid=6 WaitingForGc 
"ReferenceQueueDaemon" tid=7 Waiting 
"Binder:25274_1" tid=8 Native 
"Binder:25274_2" tid=9 Native 
"Profile Saver" tid=10 Native 
"FirebaseInstanceId" tid=12 Waiting 
"pool-2-thread-1" tid=13 Waiting 
"MessengerIpcClient" tid=16 TimedWaiting 
"GoogleApiHandler" tid=22 Native 
"Chrome_IOThread" tid=23 Native 
"PlatformServiceBridgeHandlerThread" tid=24 Native 
"GAC_Executor[0]" tid=26 Waiting 
"ConnectivityManager" tid=27 Native 
"CleanupReference" tid=28 Waiting 
"AudioThread" tid=29 Native 
"Chrome_InProcRendererThread" tid=30 Native 
"Chrome_InProcGpuThread" tid=31 Native 
"GAC_Executor[1]" tid=33 Waiting 
"Binder:25274_3" tid=34 Native 
"LooperProvider" tid=38 Native 
"AdWorker(NG) #1" tid=45 WaitingForGc 
"RenderThread" tid=48 Native 
"JavaBridge" tid=58 Native 
"Signal Catcher" tid=3 Runnable 
"HeapTaskDaemon" tid=4 WaitingForGc 

"main" tid=1 Native
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x72ec1858 self=0xaee44000
| sysTid=10258 nice=0 cgrp=default sched=0/0 handle=0xb35b74b8
| state=S schedstat=( 0 0 0 ) utm=20 stm=78 core=0 HZ=100
| stack=0xbe281000-0xbe283000 stackSize=8MB
| held mutexes=
#00 pc 0000000000049974 /system/lib/libc.so (__epoll_pwait+20)
#01 pc 000000000001ba15 /system/lib/libc.so (epoll_pwait+60)
#02 pc 000000000001ba45 /system/lib/libc.so (epoll_wait+12)
#03 pc 000000000001002d /system/lib/libutils.so (android::Looper::pollInner(int)+120)
#04 pc 000000000000ff1d /system/lib/libutils.so (android::Looper::pollOnce(int, int, int, void*)+32)
#05 pc 00000000000ba081 /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv
, _jobject*, int)+24)
#06 pc 0000000000176265 /system/framework/arm/boot-framework.oat (Java_android_os_MessageQueue_nativePollOnce__JI+92)
at android.os.MessageQueue.nativePollOnce (Native method)
at android.os.MessageQueue.next (MessageQueue.java:325)
at android.os.Looper.loop (Looper.java:142)
at android.app.ActivityThread.main (ActivityThread.java:7000)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)

I am also facing this issue. 95% of the ANRs that are getting reported on my Google Play Console are referring to this issue.

`"main" tid=1 Blocked
"main" prio=5 tid=1 Blocked
| group="main" sCount=1 dsCount=0 flags=1 obj=0x743a7660 self=0xe7fc9000
| sysTid=5740 nice=0 cgrp=default sched=0/0 handle=0xec9f1494
| state=S schedstat=( 792615932 491011320 1059 ) utm=14 stm=65 core=5 HZ=100
| stack=0xff077000-0xff079000 stackSize=8MB
| held mutexes=
at android.app.QueuedWork.processPendingWork (QueuedWork.java:245)

  • waiting to lock <0x092d20d0> (a java.lang.Object) held by thread 13
    at android.app.QueuedWork.waitToFinish (QueuedWork.java:172)
    at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3700)
    at android.app.ActivityThread.access$1600 (ActivityThread.java:202)
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1696)
    at android.os.Handler.dispatchMessage (Handler.java:107)
    at android.os.Looper.loop (Looper.java:198)
    at android.app.ActivityThread.main (ActivityThread.java:6729)
    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:858)`

All these ANRs show that the main thread is either waiting or blocked.
Is there a status update on this issue?

@samtstern hi, I have the same issue.

ANR because of Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE in FirebaseInstanceIdReceiver

"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x73faf638 self=0xe8c77000
| sysTid=26244 nice=0 cgrp=default sched=0/0 handle=0xed1084bc
| state=S schedstat=( 718806623 1179973180 1307 ) utm=34 stm=37 core=3 HZ=100
| stack=0xff0dc000-0xff0de000 stackSize=8MB
| held mutexes=
#00 pc 0000000000018ebc /system/lib/libc.so (syscall+28)
#01 pc 00000000000b380d /system/lib/libart.so (_ZN3art17ConditionVariable16WaitHoldingLocksEPNS_6ThreadE+88)
#02 pc 00000000003bfa27 /system/lib/libart.so (_ZN3artL12GoToRunnableEPNS_6ThreadE+306)
#03 pc 00000000003bf8c5 /system/lib/libart.so (_ZN3art12JniMethodEndEjPNS_6ThreadE+8)
#04 pc 000000000081bda1 /system/framework/arm/boot-framework.oat (Java_android_os_BinderProxy_transactNative__ILandroid_os_Parcel_2Landroid_os_Parcel_2I+144)
at android.os.BinderProxy.transactNative (BinderProxy.java)
at android.os.BinderProxy.transact (BinderProxy.java:761)
at android.app.IActivityManager$Stub$Proxy.addPackageDependency (IActivityManager.java:6867)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked (LoadedApk.java:613)
at android.app.LoadedApk.getClassLoader (LoadedApk.java:711)

  • locked <0x0fe1b24c> (a android.app.LoadedApk)
    at android.app.ContextImpl.getClassLoader (ContextImpl.java:304)
    at android.webkit.WebViewFactory.getProviderClass (WebViewFactory.java:409)
    at android.webkit.WebViewFactory.getProvider (WebViewFactory.java:211)
  • locked <0x0a344295> (a java.lang.Object)
    at android.webkit.WebSettings.getDefaultUserAgent (WebSettings.java:1259)
    at com.mopub.network.Networking.getUserAgent (Networking.java:175)
    at com.mopub.network.Networking.getRequestQueue (Networking.java:89)
  • locked <0x08c7efaa> (a java.lang.Class)
    at com.mopub.common.MoPub.initializeSdk (MoPub.java:189)
    at com.magicv.airbrush.advertmediation.AdClientManager.initMoPub (AdClientManager.java:64)
    at com.magicv.airbrush.advertmediation.AdClientManager.initializeSdk (AdClientManager.java:41)
    at com.magicv.airbrush.common.AirBrushApplication.initAlbumAd (AirBrushApplication.java:274)
    at com.magicv.airbrush.common.AirBrushApplication.initAds (AirBrushApplication.java:265)
    at com.magicv.airbrush.common.AirBrushApplication.initialize (AirBrushApplication.java:253)
    at com.magicv.airbrush.common.AirBrushApplication.onCreate (AirBrushApplication.java:136)
    at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1126)
    at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6062)
    at android.app.ActivityThread.-wrap1 (ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1764)
    at android.os.Handler.dispatchMessage (Handler.java:105)
    at android.os.Looper.loop (Looper.java:164)
    at android.app.ActivityThread.main (ActivityThread.java:6942)
    at java.lang.reflect.Method.invoke (Method.java)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

Remarks:the resources that reference firebase are as follows:
classpath 'com.google.gms:google-services:4.0.1'
//firebase remoteconfig
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-config:16.0.1'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation 'com.google.firebase:firebase-ads:16.0.1'

compileSdkVersion: 28,
buildToolsVersion: "28.0.3",
targetSdkVersion : 26,

hi Everyone,
I have also the same issue.

ANR because of Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE in FirebaseInstanceIdReceiver

"main" prio=5 tid=1 Waiting
| group="main" sCount=1 dsCount=0 obj=0x751a5000 self=0xb8d3a630
| sysTid=29578 nice=-4 cgrp=apps sched=0/0 handle=0xb6fb6ec8
| state=S schedstat=( 1264064036 710641375 2251 ) utm=96 stm=30 core=0 HZ=100
| stack=0xbe31d000-0xbe31f000 stackSize=8MB
| held mutexes=
at java.lang.Object.wait! (Native method)

  • waiting on <0x13be0a86> (a java.lang.Object)
    at java.lang.Thread.parkFor (Thread.java:1220)
  • locked <0x13be0a86> (a java.lang.Object)
    at sun.misc.Unsafe.park (Unsafe.java:299)
    at java.util.concurrent.locks.LockSupport.park (LockSupport.java:157)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt (AbstractQueuedSynchronizer.java:813)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly (AbstractQueuedSynchronizer.java:973)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly (AbstractQueuedSynchronizer.java:1281)
    at java.util.concurrent.CountDownLatch.await (CountDownLatch.java:202)
    at android.app.SharedPreferencesImpl$EditorImpl$1.run (SharedPreferencesImpl.java:363)
    at android.app.QueuedWork.waitToFinish (QueuedWork.java:88)
    at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3272)
    at android.app.ActivityThread.access$2200 (ActivityThread.java:168)
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1491)
    at android.os.Handler.dispatchMessage (Handler.java:102)
    at android.os.Looper.loop (Looper.java:135)
    at android.app.ActivityThread.main (ActivityThread.java:5753)
    at java.lang.reflect.Method.invoke! (Native method)
    at java.lang.reflect.Method.invoke (Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1405)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1200)

//firebase remoteconfig
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-appindexing:19.0.0'
implementation 'com.google.firebase:firebase-config:18.0.0'

    compileSdkVersion = 28
    minSdkVersion = 17
    targetSdkVersion = 28

Please help me on it if anyone of you are having solution of this.
Thanks in advance.

Hi, we also got many report on play console with same error.
We already updated to firebase 17.0.1
I also profiled our app start cpu call and no operation blocking more than 10 second.
Any other advice what we should do about it ?

Facing the same issue after upgrade FCM to 17.+ and targetSDKVertion to 28

Is there any fix for this? Got the same ANR in Android 9 only

Any solutions? Lots of same ANRs in my google play console ANR list
firebase version 17.2.1

have same problem with firebase 18.2.0

any update?

@samtstern

triggers an ANR in the receiver after 10s (which is why we set the timeout to 9s)

Correct me if i am wrong, the 9s timer is started in FirebaseInstanceIdReceiver#onReceive(before binding FirebaseMessagingService), but the 10s ANR timer is started before Application#onCreate(which is called before FirebaseInstanceIdReceiver#onReceive). So if Application#onCreate consumes more than 1 second, the 9s timer may not be triggered before the 10s ANR timeout.

Our app is also facing a lot of ANRs from this
Screen Shot 2020-04-06 at 4 52 50 PM

is there any update?

image

Migrate from Fabric ?

Reason: Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) }

Our app is facing a ANR issue like this.what is the solution?

still encounter this ANR frequently. we suspected that finishReceiver is not invoke correctly, but not find the root cause yet. And another doubt maybe the app startup cost too long if broadcast come when the app is not alive?

Maybe the QueueWork blocked by heavy work?

@LiuDongCai @RijoshEnfin @smilewaver Have you tried upgrading your firebase-messaging to the latest version:
com.google.firebase:firebase-messaging:20.1.7 ?
They said the ANR issues were fixed.

Screenshot from 2020-05-14 16-07-44

@samtstern Correct me if I'm wrong.

BTW, beside the ANR log that everybody else has already shared, here is an extra log I got regarding this ANR:

"ActivityManager" prio=5 tid=12 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x12cc7548 self=0x75f9f4d800
| sysTid=5921 nice=-2 cgrp=default sched=0/0 handle=0x75da0ba4f0
| state=S schedstat=( 5360246218928 1545171760396 6169400 ) utm=237405 stm=298619 core=6 HZ=100
| stack=0x75d9fb7000-0x75d9fb9000 stackSize=1041KB
| held mutexes=
kernel: (couldn't read /proc/self/task/5921/stack)
native: #00 pc 0000000000071448 /system/lib64/libc.so (recvfrom+8)
native: #01 pc 0000000000001c54 /system/lib64/libdebuggerd_client.so (debuggerd_trigger_dump(int, DebuggerdDumpType, unsigned int, android::base::unique_fd_impl)+1252)
native: #02 pc 0000000000002868 /system/lib64/libdebuggerd_client.so (dump_backtrace_to_file_timeout(int, DebuggerdDumpType, int, int)+104)
native: #03 pc 000000000011e760 /system/lib64/libandroid_runtime.so (android::dumpTraces(_JNIEnv, int, _jstring, int, DebuggerdDumpType)+124)
native: #04 pc 000000000011dff8 /system/lib64/libandroid_runtime.so (android::android_os_Debug_dumpJavaBacktraceToFileTimeout(_JNIEnv, _jobject, int, _jstring*, int)+28)
at android.os.Debug.dumpJavaBacktraceToFileTimeout(Native method)
at com.android.server.am.ActivityManagerService.dumpJavaTracesTombstoned(ActivityManagerService.java:8292)
at com.android.server.am.ActivityManagerService.dumpStackTraces(ActivityManagerService.java:8382)
at com.android.server.am.ActivityManagerService.dumpStackTraces(ActivityManagerService.java:8169)
at com.android.server.am.AppErrors.appNotResponding(AppErrors.java:1216)
at com.android.server.am.BroadcastQueue$AppNotResponding.run(BroadcastQueue.java:318)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:216)
at android.os.HandlerThread.run(HandlerThread.java:65)
at com.android.server.ServiceThread.run(ServiceThread.java:44)

Delayed Historical Broadcast foreground #0:
BroadcastRecord{f870e5f u95 com.google.android.c2dm.intent.RECEIVE} to user 95
Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 pkg=com.zing.zalo (has extras) }
caller=com.google.android.gms 27128:com.google.android.gms.persistent/u0a45 pid=27128 uid=10045
enqueueClockTime=2020-05-14 11:44:28.313 dispatchClockTime=2020-05-14 11:44:28.314
dispatchTime=-10s2ms (+1ms since enq) finishTime=-1ms (+10s1ms since disp)
anrCount=1
resultTo=null resultCode=0 resultData=null
resultAbort=false ordered=true sticky=false initialSticky=false
nextReceiver=1 receiver=null
Timeout #0: (manifest), [disp=-10s0ms, fin=-1ms, dur=+9s999ms]
priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=false
ActivityInfo:
name=com.google.firebase.iid.FirebaseInstanceIdReceiver
packageName=com.zing.zalo
enabled=true exported=true directBootAware=false
permission=com.google.android.c2dm.permission.SEND
resizeMode=RESIZE_MODE_RESIZEABLE
requestTransientBarDelay=-1

i am using 20.1.5 version of firebase-messaging and still encountering the same issue. This anr is frequently reported on play console.

i am using 20.1.5 version of firebase-messaging and still encountering the same issue. This anr is frequently reported on play console.

Hi @zainForAndro , how about 20.1.7 ?

@samtstern & Support team,
Did you get any fix for the above reported issue, seems keep increasing the cases?

need-attention

Thanks

My earlier comments on this bug are, unfortunately, the best I will be able to offer. If anyone is able to find a minimal reproducible example for this there may be more to discuss:
https://stackoverflow.com/help/minimal-reproducible-example

@samtstern
Please find the details log if this is helpful for now, It is difficult to reproduce. But this is being logged in Google play console.

"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 obj=0x741a22a0 self=0xb7a48590
| sysTid=29991 nice=0 cgrp=default sched=0/0 handle=0xb6f62b34
| state=S schedstat=( 0 0 0 ) utm=9 stm=35 core=0 HZ=100
| stack=0xbe6ac000-0xbe6ae000 stackSize=8MB
| held mutexes=
#00 pc 0000000000042908 /system/lib/libc.so (__ioctl+8)
#01 pc 000000000004966d /system/lib/libc.so (ioctl+14)
#02 pc 000000000001ea21 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+132)
#03 pc 000000000001f087 /system/lib/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel, int)+38)
#04 pc 000000000001f23d /system/lib/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel, unsigned int)+124)
#05 pc 000000000001a1cf /system/lib/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel
, unsigned int)+30)
#06 pc 0000000000088e21 /system/lib/libandroid_runtime.so (???)
#07 pc 0000000000d93f01 /data/dalvik-cache/arm/system@[email protected] (Java_android_os_BinderProxy_transactNative__ILandroid_os_Parcel_2Landroid_os_Parcel_2I+140)
at android.os.BinderProxy.transactNative (BinderProxy.java)
at android.os.BinderProxy.transact (BinderProxy.java:503)
at android.content.pm.IPackageManager$Stub$Proxy.getApplicationInfo (IPackageManager.java:2319)
at android.app.ApplicationPackageManager.getApplicationInfo (ApplicationPackageManager.java:292)
at com.google.android.gms.common.wrappers.PackageManagerWrapper.getApplicationInfo (PackageManagerWrapper.java:4)
at com.google.android.gms.internal.measurement.zzx.zza (zzx.java:232)
at com.google.android.gms.internal.measurement.zzx.zzi (zzx.java:185)

  • locked <0x05669729> (a java.lang.Class)
    at com.google.android.gms.internal.measurement.zzx.zzb (zzx.java:205)
    at com.google.firebase.analytics.FirebaseAnalytics.getScionFrontendApiImplementation (FirebaseAnalytics.java:98)
    at java.lang.reflect.Method.invoke! (Native method)
    at com.google.android.gms.measurement.AppMeasurement.zzb (AppMeasurement.java:30)
    at com.google.android.gms.measurement.AppMeasurement.zza (AppMeasurement.java:17)
  • locked <0x01730aae> (a java.lang.Class)
    at com.google.firebase.analytics.connector.AnalyticsConnectorImpl.getInstance (AnalyticsConnectorImpl.java:20)
  • locked <0x0bd0c04f> (a java.lang.Class)
    at com.google.firebase.analytics.connector.internal.zzc.create (zzc.java:6)
    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)
  • locked <0x0e9423dc> (a com.google.firebase.components.Lazy)
    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.google.firebase.FirebaseApp.initializeApp (FirebaseApp.java:253)
  • locked <0x00287ce5> (a java.lang.Object)
    at com.google.firebase.provider.FirebaseInitProvider.onCreate (FirebaseInitProvider.java:51)
    at android.content.ContentProvider.attachInfo (ContentProvider.java:1748)
    at android.content.ContentProvider.attachInfo (ContentProvider.java:1723)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo (FirebaseInitProvider.java:45)
    at android.app.ActivityThread.installProvider (ActivityThread.java:5174)
    at android.app.ActivityThread.installContentProviders (ActivityThread.java:4769)
    at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4709)
    at android.app.ActivityThread.-wrap1 (ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1415)
    at android.os.Handler.dispatchMessage (Handler.java:102)
    at android.os.Looper.loop (Looper.java:148)
    at android.app.ActivityThread.main (ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke! (Native method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:618)

Screenshot 2020-05-31 at 10 06 58 AM

@tuancoltech
we have try com.google.firebase:firebase-messaging:20.1.7 in a small release. which has no effect.
and we guess that one possible scene is, AMS call client to deal the broadcast, and the client maybe blocked by any time cost op in main thread. when the block pass, AMS already assume the client ANR.

@LiuDongCai while I do believe this is a real issue for you, it's not possible to begin fixing it unless we can _reproduce_ the issue as well.

I'm glad you're not working for Boeing.

We meet the same thing in the project and update it to 20.1.7 is useless. This problem seems to have existed for at least a year, do you have the plan to solve it?

Same issue

+1

Same issue,do you have the plan to solve it?

@RoyJing I am using implementation 'com.google.firebase:firebase-messaging:20.2.3'
and it is fixed there check release notes.

@RoyJing I am using implementation 'com.google.firebase:firebase-messaging:20.2.3'
and it is fixed there check release notes.

Hi,bro. Did you see after the app was released that the GooglePlay console didn't have this problem?
And can you tell me about your app's DAU? Thank you very much!
Because there are too many users of our app, we dare not upgrade directly, for fear of any new problems

My app use a lot of high priority fcm notification with only payload.I wonder if this happens when user click the notification to open the app or when user receive the notification then the app is process is started?
About 70% ANR are from the FirebaseInstanceIdReceiver.

I've tried to change the fcm notification priority from high to normal, all the ANRS caused by FirebaseInstanceIdReceiver disapeared, except one which has a stacktrace that I think could be resolved. But the notification recieve rate dropped about 10%.

I've also tried to change the fcm notification priority from high to normal, the ANRS caused by FirebaseInstanceIdReceiver decreased a lot. But the notification receive rate dropped about 30%, which has a huge affect to our app...

@RoyJing I am using implementation 'com.google.firebase:firebase-messaging:20.2.3'
and it is fixed there check release notes.

Hi, @mwshubham, I check the release note and it says "Fixed an issue that caused an app to crash when a user tapped on a received notification." I'm aware that it solves the crash instead of ANR issues. I just want to confirm if the updates will help to reduce ANR.

Also, I read the comments from @samtstern which says the devices with >26 will trigger more ANRs instead of <26'devices. But as I see in the play console, many ANRs are reported every day from Android 6 devices with SDK 23. And it's been a year since last suggestion. Do we have any updates on this issue?

Looking forward to your reply :)

I checked the play console. We didnt get the ANR from the last two releases. @Bradmrhong Looks like this is fixed in the latest versions.

We are still getting this error even after

I checked the play console. We didnt get the ANR from the last two releases. @Bradmrhong Looks like this is fixed in the latest versions.

It is still coming in the latest version "com.google.firebase:firebase-messaging:20.2.4"
Anyone else still getting this ANR? The Play Console is filled with this ANR. It is affecting our play store listing.

Same as @arsundram. We have already updated to 20.2.4 but still getting this kind of ANRs at the same high rate.
I checked again in StackOverflow and someone says need to update play-service too? Any more ideas about this?

ANR +1
too many .

I updated to com.google.firebase:firebase-messaging:20.2.4 but the ANRs continue.

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

in com.google.firebase.iid.FirebaseInstanceIdReceiver

I was also getting the same ANR(as it mentioned in early comments). 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.

ir

@pratyesh Interesting.
Can you please explain in more detail how memory leak can lead to com.google.firebase.iid.firebaseinstanceidreceiver ANR?
Thanks.

This issue is closed and is not asigned to anyone. I think that the best is continue comments in this issue:
https://github.com/firebase/firebase-android-sdk/issues/2014

Thanks 👍

@tuancoltech
I had identified in my case the context of Activity/Fragment was being stored in somewhere within ViewModel or some Sdk CallBack(i.e. Google In App Update Popup) is registered with the current context and it never been cleared from memory till to kill the app.

So same way if you guys start looking on your Memory Leak issue and after fixing this then surely your ANR will get reduce.

Thanks.

Was this page helpful?
0 / 5 - 0 ratings