invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.64k stars 2.21k forks source link

🔥[🐛] ANRs: Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 } #6206

Closed Spejbl closed 2 years ago

Spejbl commented 2 years ago

Issue

We are getting bunch of ANRs in the Google Play console related to the Firebase messaging. We suspect that this is happening when user has their app force closed and they receive the push notification. Is there any solution for this?

image

Stack trace Type "main" prio=5 tid=1 Blocked at android.app.QueuedWork.processPendingWork (QueuedWork.java:245) at android.app.QueuedWork.waitToFinish (QueuedWork.java:172) at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3945) at android.app.ActivityThread.access$1800 (ActivityThread.java:248) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1861) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loop (Looper.java:216) at android.app.ActivityThread.main (ActivityThread.java:7266) at java.lang.reflect.Method.invoke (Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975) Type "queued-work-looper" prio=5 tid=28 Native #00 pc 0000000000019e74 /system/lib/libc.so (syscall+28) #00 pc 00000000000a7477 /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+86) #00 pc 00000000002a8963 /system/lib/libart.so (art::JNI::ReleaseByteArrayElements(_JNIEnv*, _jbyteArray*, signed char*, int)+350) #00 pc 00000000000217a5 /system/lib/libjavacore.so (Linux_writeBytes(_JNIEnv*, _jobject*, _jobject*, _jbyteArray*, int, int)+248) at libcore.io.Linux.writeBytes (Native method) at libcore.io.Linux.write (Linux.java:288) at libcore.io.BlockGuardOs.write (BlockGuardOs.java:348) at libcore.io.IoBridge.write (IoBridge.java:526) at java.io.FileOutputStream.write (FileOutputStream.java:381) at com.android.internal.util.FastXmlSerializer.flushBytes (FastXmlSerializer.java:250) at com.android.internal.util.FastXmlSerializer.flush (FastXmlSerializer.java:271) at com.android.internal.util.FastXmlSerializer.append (FastXmlSerializer.java:110) at com.android.internal.util.FastXmlSerializer.escapeAndAppendString (FastXmlSerializer.java:159) at com.android.internal.util.FastXmlSerializer.text (FastXmlSerializer.java:411) at com.android.internal.util.XmlUtils.writeValueXml (XmlUtils.java:655) at com.android.internal.util.XmlUtils.writeMapXml (XmlUtils.java:300) at com.android.internal.util.XmlUtils.writeMapXml (XmlUtils.java:269) at com.android.internal.util.XmlUtils.writeMapXml (XmlUtils.java:235) at com.android.internal.util.XmlUtils.writeMapXml (XmlUtils.java:192) at android.app.SharedPreferencesImpl.writeToFile (SharedPreferencesImpl.java:773) at android.app.SharedPreferencesImpl.access$900 (SharedPreferencesImpl.java:54) at android.app.SharedPreferencesImpl$2.run (SharedPreferencesImpl.java:642) at android.app.QueuedWork.processPendingWork (QueuedWork.java:258) at android.app.QueuedWork.access$000 (QueuedWork.java:49) at android.app.QueuedWork$QueuedWorkHandler.handleMessage (QueuedWork.java:278) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loop (Looper.java:216) at android.os.HandlerThread.run (HandlerThread.java:65) Type "Jit thread pool worker thread 0" daemon prio=5 tid=2 Native #00 pc 0000000000019e74 /system/lib/libc.so (syscall+28) #00 pc 00000000000a7477 /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+86) #00 pc 0000000000398201 /system/lib/libart.so (art::ThreadPool::GetTask(art::Thread*)+172) #00 pc 0000000000397aab /system/lib/libart.so (art::ThreadPoolWorker::Run()+62) #00 pc 00000000003976cf /system/lib/libart.so (art::ThreadPoolWorker::Callback(void*)+94) #00 pc 00000000000659d3 /system/lib/libc.so (__pthread_start(void*)+22) #00 pc 000000000001e491 /system/lib/libc.so (__start_thread+32) Type "FinalizerDaemon" daemon prio=5 tid=4 Waiting at java.lang.Object.wait (Native method) at java.lang.Object.wait (Object.java:422) at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:188) at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:209) at java.lang.Daemons$FinalizerDaemon.runInternal (Daemons.java:232) at java.lang.Daemons$Daemon.run (Daemons.java:103) at java.lang.Thread.run (Thread.java:764) Type "ReferenceQueueDaemon" daemon prio=5 tid=5 Waiting at java.lang.Object.wait (Native method) at java.lang.Daemons$ReferenceQueueDaemon.runInternal (Daemons.java:178) at java.lang.Daemons$Daemon.run (Daemons.java:103) at java.lang.Thread.run (Thread.java:764) Type "FinalizerWatchdogDaemon" daemon prio=5 tid=6 Sleeping at java.lang.Thread.sleep (Native method) at java.lang.Thread.sleep (Thread.java:373) at java.lang.Thread.sleep (Thread.java:314) at java.lang.Daemons$FinalizerWatchdogDaemon.sleepFor (Daemons.java:342) at java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization (Daemons.java:364) at java.lang.Daemons$FinalizerWatchdogDaemon.runInternal (Daemons.java:281) at java.lang.Daemons$Daemon.run (Daemons.java:103) at java.lang.Thread.run (Thread.java:764) Type "Binder:18502_1" prio=5 tid=7 Native #00 pc 000000000005587c /system/lib/libc.so (__ioctl+8) #00 pc 0000000000022343 /system/lib/libc.so (ioctl+38) #00 pc 000000000003d863 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+206) #00 pc 000000000003d9b3 /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+10) #00 pc 000000000003df3b /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+38) #00 pc 0000000000054bcd /system/lib/libbinder.so (android::PoolThread::threadLoop()+12) #00 pc 000000000000c10f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+170) #00 pc 000000000007353b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+82) #00 pc 00000000000659d3 /system/lib/libc.so (__pthread_start(void*)+22) #00 pc 000000000001e491 /system/lib/libc.so (__start_thread+32) Type "Binder:18502_2" prio=5 tid=9 Native #00 pc 000000000005587c /system/lib/libc.so (__ioctl+8) #00 pc 0000000000022343 /system/lib/libc.so (ioctl+38) #00 pc 000000000003d863 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+206) #00 pc 000000000003d9b3 /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+10) #00 pc 000000000003df3b /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+38) #00 pc 0000000000054bcd /system/lib/libbinder.so (android::PoolThread::threadLoop()+12) #00 pc 000000000000c10f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+170) #00 pc 000000000007353b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+82) #00 pc 00000000000659d3 /system/lib/libc.so (__pthread_start(void*)+22) #00 pc 000000000001e491 /system/lib/libc.so (__start_thread+32) Type "Binder:18502_3" prio=5 tid=10 Native #00 pc 000000000005587c /system/lib/libc.so (__ioctl+8) #00 pc 0000000000022343 /system/lib/libc.so (ioctl+38) #00 pc 000000000003d863 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+206) #00 pc 000000000003d9b3 /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+10) #00 pc 000000000003df3b /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+38) #00 pc 0000000000054bcd /system/lib/libbinder.so (android::PoolThread::threadLoop()+12) #00 pc 000000000000c10f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+170) #00 pc 000000000007353b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+82) #00 pc 00000000000659d3 /system/lib/libc.so (__pthread_start(void*)+22) #00 pc 000000000001e491 /system/lib/libc.so (__start_thread+32) Type "Binder:18502_4" prio=5 tid=11 Native #00 pc 000000000005587c /system/lib/libc.so (__ioctl+8) #00 pc 0000000000022343 /system/lib/libc.so (ioctl+38) #00 pc 000000000003d863 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+206) #00 pc 000000000003d9b3 /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+10) #00 pc 000000000003df3b /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+38) #00 pc 0000000000054bcd /system/lib/libbinder.so (android::PoolThread::threadLoop()+12) #00 pc 000000000000c10f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+170) #00 pc 000000000007353b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+82) #00 pc 00000000000659d3 /system/lib/libc.so (__pthread_start(void*)+22) #00 pc 000000000001e491 /system/lib/libc.so (__start_thread+32) Type "Profile Saver" daemon prio=5 tid=12 Native #00 pc 0000000000019e74 /system/lib/libc.so (syscall+28) #00 pc 00000000000a7477 /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+86) #00 pc 00000000002660e1 /system/lib/libart.so (art::ProfileSaver::Run()+360) #00 pc 0000000000268a29 /system/lib/libart.so (art::ProfileSaver::RunProfileSaverThread(void*)+52) #00 pc 00000000000659d3 /system/lib/libc.so (__pthread_start(void*)+22) #00 pc 000000000001e491 /system/lib/libc.so (__start_thread+32) Type "pool-2-thread-1" prio=5 tid=13 Waiting at java.lang.Object.wait (Native method) 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.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2059) 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 java.lang.Thread.run (Thread.java:764) Type "pool-6-thread-1" prio=5 tid=14 TimedWaiting at java.lang.Object.wait (Native method) at java.lang.Thread.parkFor$ (Thread.java:2137) at sun.misc.Unsafe.park (Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:230) at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill (SynchronousQueue.java:461) at java.util.concurrent.SynchronousQueue$TransferStack.transfer (SynchronousQueue.java:362) at java.util.concurrent.SynchronousQueue.poll (SynchronousQueue.java:937) at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1091) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764) Type "ScionFrontendApi" prio=5 tid=15 TimedWaiting at java.lang.Object.wait (Native method) at java.lang.Thread.parkFor$ (Thread.java:2137) at sun.misc.Unsafe.park (Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:230) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos (AbstractQueuedSynchronizer.java:2101) at java.util.concurrent.LinkedBlockingQueue.poll (LinkedBlockingQueue.java:467) at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1091) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764) Type "pool-9-thread-1" prio=5 tid=16 Waiting at java.lang.Object.wait (Native method) 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.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2059) 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 java.lang.Thread.run (Thread.java:764) Type "Firebase-Messaging-Topics-Io" prio=5 tid=17 Waiting at java.lang.Object.wait (Native method) 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.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2059) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:1120) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:849) 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.android.gms.common.util.q.b.run at java.lang.Thread.run (Thread.java:764) Type "Firebase-Messaging-Init" prio=5 tid=18 Waiting at java.lang.Object.wait (Native method) 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.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2059) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:1120) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:849) 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.android.gms.common.util.q.b.run at java.lang.Thread.run (Thread.java:764) Type "pool-10-thread-1" prio=5 tid=19 TimedWaiting at java.lang.Object.wait (Native method) at java.lang.Thread.parkFor$ (Thread.java:2137) at sun.misc.Unsafe.park (Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:230) at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill (SynchronousQueue.java:461) at java.util.concurrent.SynchronousQueue$TransferStack.transfer (SynchronousQueue.java:362) at java.util.concurrent.SynchronousQueue.poll (SynchronousQueue.java:937) at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1091) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764) Type "pool-8-thread-1" prio=5 tid=20 TimedWaiting at java.lang.Object.wait (Native method) at java.lang.Thread.parkFor$ (Thread.java:2137) at sun.misc.Unsafe.park (Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:230) at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill (SynchronousQueue.java:461) at java.util.concurrent.SynchronousQueue$TransferStack.transfer (SynchronousQueue.java:362) at java.util.concurrent.SynchronousQueue.poll (SynchronousQueue.java:937) at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1091) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764) Type "pool-7-thread-1" prio=5 tid=21 TimedWaiting at java.lang.Object.wait (Native method) at java.lang.Thread.parkFor$ (Thread.java:2137) at sun.misc.Unsafe.park (Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:230) at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill (SynchronousQueue.java:461) at java.util.concurrent.SynchronousQueue$TransferStack.transfer (SynchronousQueue.java:362) at java.util.concurrent.SynchronousQueue.poll (SynchronousQueue.java:937) at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1091) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764) Type "GmsDynamite" prio=5 tid=22 Waiting at java.lang.Object.wait (Native method) at com.google.android.gms.dynamite.a.run Type "pool-16-thread-1" prio=5 tid=23 Waiting at java.lang.Object.wait (Native method) 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.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2059) 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 java.lang.Thread.run (Thread.java:764) Type "pool-16-thread-2" prio=5 tid=24 Waiting at java.lang.Object.wait (Native method) 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.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2059) 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 java.lang.Thread.run (Thread.java:764) Type "Measurement Worker" prio=5 tid=25 Native #00 pc 0000000000019e74 /system/lib/libc.so (syscall+28) #00 pc 00000000000a7477 /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+86) #00 pc 00000000003e78ff /system/lib/libart.so (art::GoToRunnable(art::Thread*) (.llvm.1086285645)+322) #00 pc 00000000003e7795 /system/lib/libart.so (art::JniMethodEnd(unsigned int, art::Thread*)+8) at android.os.BinderProxy.transactNative (Native method) at android.os.BinderProxy.transact (Binder.java:1145) at ah.b (com.google.android.gms.dynamite_measurementdynamite@220920062@22.09.20 (100304-0):2) at if.d (com.google.android.gms.dynamite_measurementdynamite@220920062@22.09.20 (100304-0)) at lc.run (com.google.android.gms.dynamite_measurementdynamite@220920062@22.09.20 (100304-0):5) at lx.r (com.google.android.gms.dynamite_measurementdynamite@220920062@22.09.20 (100304-0):3) at lx.L (com.google.android.gms.dynamite_measurementdynamite@220920062@22.09.20 (100304-0):2) at lt.run (com.google.android.gms.dynamite_measurementdynamite@220920062@22.09.20 (100304-0):1) at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:459) at java.util.concurrent.FutureTask.run (FutureTask.java:266) at iy.run (com.google.android.gms.dynamite_measurementdynamite@220920062@22.09.20 (100304-0):5) Type "HybridData DestructorThread" prio=5 tid=26 Waiting at java.lang.Object.wait (Native method) at java.lang.Object.wait (Object.java:422) at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:188) at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:209) at com.facebook.jni.DestructorThread$1.run (DestructorThread.java:1) Type "firebase-installations-executor-1" prio=5 tid=29 TimedWaiting at java.lang.Object.wait (Native method) at java.lang.Thread.parkFor$ (Thread.java:2137) at sun.misc.Unsafe.park (Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:230) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos (AbstractQueuedSynchronizer.java:2101) at java.util.concurrent.LinkedBlockingQueue.poll (LinkedBlockingQueue.java:467) at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1091) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764) Type "firebase-installations-executor-2" prio=5 tid=30 TimedWaiting at java.lang.Object.wait (Native method) at java.lang.Thread.parkFor$ (Thread.java:2137) at sun.misc.Unsafe.park (Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:230) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos (AbstractQueuedSynchronizer.java:2101) at java.util.concurrent.LinkedBlockingQueue.poll (LinkedBlockingQueue.java:467) at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1091) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764) Type "ConnectivityThread" prio=5 tid=31 Native #00 pc 0000000000055740 /system/lib/libc.so (__epoll_pwait+20) #00 pc 0000000000027109 /system/lib/libc.so (epoll_wait+16) #00 pc 000000000000f139 /system/lib/libutils.so (android::Looper::pollInner(int)+116) #00 pc 000000000000f043 /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+26) #00 pc 00000000000befc9 /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:183) at android.os.HandlerThread.run (HandlerThread.java:65) Type "mqt_js" prio=5 tid=32 Native #00 pc 0000000000019e74 /system/lib/libc.so (syscall+28) #00 pc 00000000000a7477 /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+86) #00 pc 0000000000272d05 /system/lib/libart.so (art::JNI::CallObjectMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+356) #00 pc 0000000000085a4b /data/data/gg.wasder.app/lib-0/libreactnativejni.so (_JNIEnv::CallObjectMethod(_jobject*, _jmethodID*, ...)+30) #00 pc 000000000009d24f /data/data/gg.wasder.app/lib-0/libreactnativejni.so (facebook::jni::JMethod::JavaPart, facebook::jni::JObject, void>::_javaobject* ()>::operator()(facebook::jni::alias_ref<_jobject*>) const+22) #00 pc 000000000009d177 /data/data/gg.wasder.app/lib-0/libreactnativejni.so (facebook::react::JavaNativeModule::getConstants()+50) #00 pc 0000000000027459 /data/data/gg.wasder.app/lib-0/libhermes-executor-common-release.so (facebook::react::ModuleRegistry::getConfig(std::__ndk1::basic_string, std::__ndk1::allocator> const&)+132) #00 pc 0000000000023659 /data/data/gg.wasder.app/lib-0/libhermes-executor-common-release.so (facebook::react::JSINativeModules::createModule(facebook::jsi::Runtime&, std::__ndk1::basic_string, std::__ndk1::allocator> const&)+156) #00 pc 00000000000234c5 /data/data/gg.wasder.app/lib-0/libhermes-executor-common-release.so (facebook::react::JSINativeModules::getModule(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)+192) #00 pc 0000000000020f5d /data/data/gg.wasder.app/lib-0/libhermes-executor-common-release.so (facebook::react::JSIExecutor::NativeModuleProxy::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)+128) #00 pc 000000000001cf0d /data/data/gg.wasder.app/lib-0/libhermes-executor-common-release.so (facebook::jsi::DecoratedHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)+12) #00 pc 00000000000174c1 /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 000000000003af5b /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 0000000000030305 /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 000000000002e067 /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 00000000000346f5 /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 000000000001cfdd /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 000000000001b9bf /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 000000000003aef9 /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 0000000000030305 /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 000000000002e067 /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 00000000000346f5 /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 000000000001cfdd /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 000000000001b9bf /data/data/gg.wasder.app/lib-0/libhermes.so (???) #00 pc 000000000003a961 / Type "Signal Catcher" daemon prio=5 tid=3 Runnable #00 pc 00000000002e618f /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+134) #00 pc 0000000000380b6d /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream>&, bool, BacktraceMap*, bool) const+212) #00 pc 000000000037d12b /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream>&, bool, BacktraceMap*, bool) const+34) #00 pc 0000000000396e17 /system/lib/libart.so (art::DumpCheckpoint::Run(art::Thread*)+654) #00 pc 0000000000390863 /system/lib/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+322) #00 pc 000000000038fecf /system/lib/libart.so (art::ThreadList::Dump(std::__1::basic_ostream>&, bool)+830) #00 pc 000000000038fabb /system/lib/libart.so (art::ThreadList::DumpForSigQuit(std::__1::basic_ostream>&)+650) #00 pc 0000000000368b69 /system/lib/libart.so (art::Runtime::DumpForSigQuit(std::__1::basic_ostream>&)+120) #00 pc 0000000000371f99 /system/lib/libart.so (art::SignalCatcher::HandleSigQuit()+1116) #00 pc 00000000003710af /system/lib/libart.so (art::SignalCatcher::Run(void*)+274) #00 pc 00000000000659d3 /system/lib/libc.so (__pthread_start(void*)+22) #00 pc 000000000001e491 /system/lib/libc.so (__start_thread+32) Type "HeapTaskDaemon" daemon prio=5 tid=8 WaitingForTaskProcessor #00 pc 0000000000019e78 /system/lib/libc.so (syscall+32) #00 pc 00000000000a77bf /system/lib/libart.so (art::ConditionVariable::TimedWait(art::Thread*, long long, int)+106) #00 pc 00000000001ae51b /system/lib/libart.so (art::gc::TaskProcessor::GetTask(art::Thread*)+254) #00 pc 00000000001aeba1 /system/lib/libart.so (art::gc::TaskProcessor::RunAllTasks(art::Thread*)+48) at dalvik.system.VMRuntime.runHeapTasks (Native method) at java.lang.Daemons$HeapTaskDaemon.runInternal (Daemons.java:475) at java.lang.Daemons$Daemon.run (Daemons.java:103) at java.lang.Thread.run (Thread.java:764)


Project Files

Javascript

Click To Expand

#### `package.json`: ```json "@react-native-firebase/analytics": "14.7.0", "@react-native-firebase/app": "14.7.0", "@react-native-firebase/dynamic-links": "14.7.0", "@react-native-firebase/messaging": "14.7.0", "@react-native-firebase/perf": "14.7.0", "@react-native-firebase/remote-config": "14.7.0", ``` #### `firebase.json` for react-native-firebase v6: ```json { "react-native": { "messaging_android_notification_channel_id": "high-priority", "perf_auto_collection_enabled": false } } ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [x] my application is an AndroidX application? - [x] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [x] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy buildscript { ext { buildToolsVersion = "30.0.2" minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 30 kotlin_version = '1.5.31' ndkVersion = "21.4.7075529" } repositories { google() jcenter() mavenCentral() } dependencies { classpath('com.android.tools.build:gradle:4.2.2') classpath 'com.google.gms:google-services:4.3.5' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.firebase:perf-plugin:1.4.1' } } subprojects { task listAllDependencies(type: DependencyReportTask) {} // Force all subprojects to use one and only one set of versions ext { compileSdk = rootProject.ext.compileSdkVersion buildTools = rootProject.ext.buildToolsVersion minSdk = rootProject.ext.minSdkVersion targetSdk = rootProject.ext.targetSdkVersion } afterEvaluate { project -> if (!project.name.equalsIgnoreCase("app") && project.hasProperty("android")) { android { compileSdkVersion compileSdk buildToolsVersion buildTools defaultConfig { minSdkVersion minSdk targetSdkVersion targetSdk } } } } } allprojects { repositories { jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } maven { // All of Detox' artifacts are provided via the npm module url "$rootDir/../node_modules/detox/Detox-android" } mavenCentral { // We don't want to fetch react-native from Maven Central as there are // older versions over there. content { excludeGroup "com.facebook.react" } } google() maven { url 'https://maven.google.com' } maven { url 'https://www.jitpack.io' } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.firebase-perf' import com.android.build.OutputFile project.ext.react = [ entryFile: 'index.js', enableHermes: true, // clean and rebuild if changing bundleInStaging: true, bundleInRelease: true, devDisabledInStaging: true, devDisabledInRelease: true, deleteDebugFilesForVariant: { def variant -> variant.name.toLowerCase().contains("release") || variant.name.toLowerCase().contains("staging") } ] apply from: "../../node_modules/react-native/react.gradle" if (getGradle().getStartParameter().getTaskRequests().toString().contains("Release")) { apply from: "../../node_modules/@sentry/react-native/sentry.gradle" } /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = true /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = true /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and that value will be read here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", true); /** * Architectures to build native code for in debug. */ def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures") rootProject.project(":datadog_mobile-react-native").afterEvaluate { ddSdkProject -> def androidExtension = ddSdkProject.extensions.getByName("android") as com.android.build.gradle.LibraryExtension androidExtension.defaultConfig.minSdkVersion 21 } android { dexOptions { javaMaxHeapSize "3g" } ndkVersion rootProject.ext.ndkVersion compileSdkVersion rootProject.ext.compileSdkVersion defaultConfig { applicationId "xxx" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 11889 versionName "1.2.154" multiDexEnabled true vectorDrawables.useSupportLibrary = true // used by react-native-image-crop-picker testBuildType System.getProperty('testBuildType', 'debug') testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk true // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } buildTypes { debug { signingConfig signingConfigs.debug debuggable true applicationIdSuffix ".staging" resValue "string", "app_name", "xxx Debug" if (nativeArchitectures) { ndk { abiFilters nativeArchitectures.split(',') } } } staging { signingConfig signingConfigs.debug debuggable true applicationIdSuffix ".staging" matchingFallbacks = ['release'] resValue "string", "app_name", "xxx Staging" } release { // Caution! In production, you need to generate your own keystore file. // see https://facebook.github.io/react-native/docs/signed-apk-android. signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds shrinkResources enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" resValue "string", "app_name", "xxx" } } packagingOptions { pickFirst "lib/armeabi-v7a/libc++_shared.so" pickFirst "lib/arm64-v8a/libc++_shared.so" pickFirst "lib/x86/libc++_shared.so" pickFirst "lib/x86_64/libc++_shared.so" } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = defaultConfig.versionCode * 1000 + versionCodes.get(abi) } } } configurations.all { resolutionStrategy { force 'androidx.browser:browser:1.3.0' } resolutionStrategy { // Fallback: android-work-runtime 2.7.0+ requires compileSdkVersion 31+ force 'androidx.work:work-runtime:2.6.0' } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation 'com.android.support:multidex:1.0.3' implementation "androidx.annotation:annotation:1.1.0" implementation project(':react-native-safe-area-context') // Firebase Related implementation 'com.google.firebase:firebase-analytics:18.0.2' implementation 'com.google.android.gms:play-services-tagmanager:11.0.4' debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } androidTestImplementation('com.wix:detox:+') { transitive = true } androidTestImplementation 'junit:junit:4.12' if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") stagingImplementation files(hermesPath + "hermes-release.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.implementation into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'xxx' include ':react-native-safe-area-context' project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-safe-area-context/android') include ':react-native-localize' project(':react-native-localize').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-localize/android') apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' ``` #### `MainApplication.java`: ```java package gg.xxx.app; import android.app.Application; import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.th3rdwave.safeareacontext.SafeAreaContextPackage; import com.zoontek.rnlocalize.RNLocalizePackage; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; import java.util.List; import com.facebook.react.bridge.JSIModulePackage; import com.swmansion.reanimated.ReanimatedJSIModulePackage; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: packages.add(new SafeAreaContextPackage()); return packages; } @Override protected String getJSMainModuleName() { return "index"; } @Override protected JSIModulePackage getJSIModulePackage() { return new ReanimatedJSIModulePackage(); } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } /** * Loads Flipper in React Native templates. Call this in the onCreate method with something like * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); * * @param context * @param reactInstanceManager */ private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { if (BuildConfig.DEBUG) { try { /* We use reflection here to pick up the class that initializes Flipper, since Flipper library is not available in release mode */ Class aClass = Class.forName("gg.xxx.app.ReactNativeFlipper"); aClass .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) .invoke(null, context, reactInstanceManager); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 11.3.1 CPU: (8) arm64 Apple M1 Memory: 189.42 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 17.8.0 - /var/folders/qv/75qjdn7j1lgdst5n1b925h100000gn/T/yarn--1650535128517-0.8335724027953211/node Yarn: 1.22.18 - /var/folders/qv/75qjdn7j1lgdst5n1b925h100000gn/T/yarn--1650535128517-0.8335724027953211/yarn npm: 8.5.5 - /opt/homebrew/bin/npm Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 Android SDK: API Levels: 28, 29, 30, 31 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0 System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-31 | Google APIs Intel x86 Atom_64, android-31 | Google Play ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8193401 Xcode: 12.5/12E262 - /usr/bin/xcodebuild Languages: Java: javac 15 - /Users/xxx/Desktop/jdk-15.jdk/Contents/Home/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.67.2 => 0.67.2 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [x] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `14.7.0` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y` & `4.0.5`


mikehardy commented 2 years ago

You are likely right on the sequence of events but firebase messaging can't take the blame unfortunately. What happens is: your app receives an FCM and needs to cold start - so - the FCM is the "proximal cause" however, the real problem is your app's cold start takes too long. FCM received just caused cold start process to happen.

Now your app has an incredibly slow cold start for some reason, and the FCM receipt is tagged in the ANR, but when you enable strict mode and test your app you'll find there are probably all sorts of things making cold start slow

Clean those up, then when you receive an FCM and need to cold start, it'll be fast - FCM receipt itself is not slow

This is unfortunately an odyssey - it takes a while to set the strict mode testing and work through the results iteratively, removing slow code paths, but it's project-specific and will not result in changes here, so unfortunately this is not actionable as an issue. I'll close this then but you'll find plenty of help online about using strict mode to diagnose slow android app startup