firebase / firebase-android-sdk

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

ANR com.google.firebase.app.internal.cpp.JniResultCallback.onCompletion #4182

Closed rkfteam closed 1 year ago

rkfteam commented 1 year ago

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

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

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

We are getting ANR error. Title: JniResultCallback.java line 149 Subtitle: com.google.firebase.app.internal.cpp.JniResultCallback.onCompletion

Steps to reproduce:

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

Honestly, we don't have steps, only Firebase Console:

Screenshot 2022-10-07 в 11 10 20
main (blocked): tid=1 systid=24322 | waiting to lock <0x0d849ea5> (com.google.firebase.app.internal.cpp.JniResultCallback) held by thread 191
       at com.google.firebase.app.internal.cpp.JniResultCallback.onCompletion(JniResultCallback.java:149)
       at com.google.firebase.app.internal.cpp.JniResultCallback$TaskCallback.onSuccess(JniResultCallback.java:67)
       at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@18.0.2:1)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:263)
       at android.app.ActivityThread.main(ActivityThread.java:8326)
       at java.lang.reflect.Method.invoke(Native method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)

Thread-114 (blocked): tid=191 systid=25144 | waiting to lock <0x026c027a> (java.lang.Object) held by thread 1
       at com.google.firebase.app.internal.cpp.JniResultCallback$TaskCallback.disconnect(JniResultCallback.java:102)
       at com.google.firebase.app.internal.cpp.JniResultCallback.onCompletion(JniResultCallback.java:152)
       at com.google.firebase.app.internal.cpp.JniResultCallback.cancel(JniResultCallback.java:143)

Signal Catcher (runnable): tid=6 systid=24333 
#00 pc 0x49f310 libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool) + 140)
#01 pc 0x5abf58 libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap*, bool) const + 376)
#02 pc 0x5c956c libart.so (art::DumpCheckpoint::Run(art::Thread*) + 924)
#03 pc 0x5c3420 libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*) + 528)
#04 pc 0x5c25ec libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool) + 1920)
#05 pc 0x5c1a8c libart.so (art::ThreadList::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) + 776)
#06 pc 0x56e210 libart.so (art::Runtime::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) + 196)
#07 pc 0x583780 libart.so (art::SignalCatcher::HandleSigQuit() + 1396)
#08 pc 0x58274c libart.so (art::SignalCatcher::Run(void*) + 348)
#09 pc 0xda278 libc.so (__pthread_start(void*) + 64)
#10 pc 0x7a448 libc.so (__start_thread + 64)

Jit thread pool worker thread 0 (native): tid=7 systid=24334 
#00 pc 0x7550c libc.so (syscall + 28)
#01 pc 0x1af800 libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*) + 148)
#02 pc 0x5cb294 libart.so (art::ThreadPool::GetTask(art::Thread*) + 120)
#03 pc 0x5ca538 libart.so (art::ThreadPoolWorker::Run() + 144)
#04 pc 0x5ca008 libart.so (art::ThreadPoolWorker::Callback(void*) + 192)
#05 pc 0xda278 libc.so (__pthread_start(void*) + 64)
#06 pc 0x7a448 libc.so (__start_thread + 64)

HeapTaskDaemon (waiting): tid=8 systid=24335 
#00 pc 0x75510 libc.so (syscall + 32)
#01 pc 0x1afbd0 libart.so (art::ConditionVariable::TimedWait(art::Thread*, long, int) + 172)
#02 pc 0x2e5248 libart.so (art::gc::TaskProcessor::GetTask(art::Thread*) + 512)
#03 pc 0x2e5b90 libart.so (art::gc::TaskProcessor::RunAllTasks(art::Thread*) + 92)
       at dalvik.system.VMRuntime.runHeapTasks(Native method)
       at java.lang.Daemons$HeapTaskDaemon.runInternal(Daemons.java:542)
       at java.lang.Daemons$Daemon.run(Daemons.java:144)
       at java.lang.Thread.run(Thread.java:923)

ReferenceQueueDaemon (waiting): tid=9 systid=24336 
       at java.lang.Object.wait(Native method)
       at java.lang.Object.wait(Object.java:442)
       at java.lang.Object.wait(Object.java:568)
       at java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:222)
       at java.lang.Daemons$Daemon.run(Daemons.java:144)
       at java.lang.Thread.run(Thread.java:923)

FinalizerDaemon (waiting): tid=10 systid=24337 
       at java.lang.Object.wait(Native method)
       at java.lang.Object.wait(Object.java:442)
       at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:190)
       at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:211)
       at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
       at java.lang.Daemons$Daemon.run(Daemons.java:144)
       at java.lang.Thread.run(Thread.java:923)

FinalizerWatchdogDaemon (timed waiting): tid=11 systid=24338 
       at java.lang.Thread.sleep(Native method)
       at java.lang.Thread.sleep(Thread.java:442)
       at java.lang.Thread.sleep(Thread.java:358)
       at java.lang.Daemons$FinalizerWatchdogDaemon.sleepForNanos(Daemons.java:395)
       at java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:430)
       at java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:330)
       at java.lang.Daemons$Daemon.run(Daemons.java:144)
       at java.lang.Thread.run(Thread.java:923)

Binder:24322_1 (native): tid=12 systid=24339 
#00 pc 0xc54a4 libc.so (__ioctl + 4)
#01 pc 0x81db8 libc.so (ioctl + 156)
#02 pc 0x54a34 libbinder.so (android::IPCThreadState::talkWithDriver(bool) + 300)
#03 pc 0x54bbc libbinder.so (android::IPCThreadState::getAndExecuteCommand() + 24)
#04 pc 0x554a0 libbinder.so (android::IPCThreadState::joinThreadPool(bool) + 80)
#05 pc 0x7b488 libbinder.so (android::PoolThread::threadLoop() + 24)
#06 pc 0x154cc libutils.so (android::Thread::_threadLoop(void*) + 260)
#07 pc 0xa4490 libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*) + 144)
#08 pc 0x14d90 libutils.so (thread_data_t::trampoline(thread_data_t const*) + 412)
#09 pc 0xda278 libc.so (__pthread_start(void*) + 64)
#10 pc 0x7a448 libc.so (__start_thread + 64)

Binder:24322_2 (native): tid=13 systid=24340 
#00 pc 0xc54a4 libc.so (__ioctl + 4)
#01 pc 0x81db8 libc.so (ioctl + 156)
#02 pc 0x54a34 libbinder.so (android::IPCThreadState::talkWithDriver(bool) + 300)
#03 pc 0x54bbc libbinder.so (android::IPCThreadState::getAndExecuteCommand() + 24)
#04 pc 0x554a0 libbinder.so (android::IPCThreadState::joinThreadPool(bool) + 80)
#05 pc 0x7b488 libbinder.so (android::PoolThread::threadLoop() + 24)
#06 pc 0x154cc libutils.so (android::Thread::_threadLoop(void*) + 260)
#07 pc 0xa4490 libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*) + 144)
#08 pc 0x14d90 libutils.so (thread_data_t::trampoline(thread_data_t const*) + 412)
#09 pc 0xda278 libc.so (__pthread_start(void*) + 64)
#10 pc 0x7a448 libc.so (__start_thread + 64)

Binder:24322_3 (native): tid=14 systid=24341 
#00 pc 0xc54a4 libc.so (__ioctl + 4)
#01 pc 0x81db8 libc.so (ioctl + 156)
#02 pc 0x54a34 libbinder.so (android::IPCThreadState::talkWithDriver(bool) + 300)
#03 pc 0x54bbc libbinder.so (android::IPCThreadState::getAndExecuteCommand() + 24)
#04 pc 0x554a0 libbinder.so (android::IPCThreadState::joinThreadPool(bool) + 80)
#05 pc 0x7b488 libbinder.so (android::PoolThread::threadLoop() + 24)
#06 pc 0x154cc libutils.so (android::Thread::_threadLoop(void*) + 260)
#07 pc 0xa4490 libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*) + 144)
#08 pc 0x14d90 libutils.so (thread_data_t::trampoline(thread_data_t const*) + 412)
#09 pc 0xda278 libc.so (__pthread_start(void*) + 64)
#10 pc 0x7a448 libc.so (__start_thread + 64)

Profile Saver (native): tid=15 systid=24344 
#00 pc 0x7550c libc.so (syscall + 28)
#01 pc 0x1af800 libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*) + 148)
#02 pc 0x353ca4 libart.so (art::ProfileSaver::Run() + 692)
#03 pc 0x358e84 libart.so (art::ProfileSaver::RunProfileSaverThread(void*) + 180)
#04 pc 0xda278 libc.so (__pthread_start(void*) + 64)
#05 pc 0x7a448 libc.so (__start_thread + 64)

GoogleApiHandler (native): tid=19 systid=24404 
#00 pc 0xc6468 libc.so (__epoll_pwait + 8)
#01 pc 0x19acc libutils.so (android::Looper::pollInner(int) + 184)
#02 pc 0x199ac libutils.so (android::Looper::pollOnce(int, int*, int*, void**) + 112)
#03 pc 0x1155b0 libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int) + 44)
       at android.os.MessageQueue.nativePollOnce(Native method)
       at android.os.MessageQueue.next(MessageQueue.java:339)
       at android.os.Looper.loop(Looper.java:199)
       at android.os.HandlerThread.run(HandlerThread.java:67)

pool-4-thread-1 (timed waiting): tid=18 systid=24411 
       at sun.misc.Unsafe.park(Native method)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2141)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132)
       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 java.lang.Thread.run(Thread.java:923)

ScionFrontendApi (timed waiting): tid=20 systid=24423 
       at sun.misc.Unsafe.park(Native method)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2141)
       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:923)

Firebase-Messaging-Topics-Io (waiting): tid=21 systid=24440 
       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:2099)
       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.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.1.0:2)
       at java.lang.Thread.run(Thread.java:923)

pool-10-thread-1 (waiting): tid=22 systid=24436 
       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:2099)
       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:923)

GmsDynamite (waiting): tid=23 systid=24438 
       at java.lang.Object.wait(Native method)
       at java.lang.Object.wait(Object.java:442)
       at java.lang.Object.wait(Object.java:568)
       at com.google.android.gms.dynamite.zza.run(com.google.android.gms:play-services-basement@@18.1.0:2)

Firebase-Messaging-Init (waiting): tid=24 systid=24439 
       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:2099)
       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.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.1.0:2)
       at java.lang.Thread.run(Thread.java:923)

FirebaseInstanceId (waiting): tid=25 systid=24447 
       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:2099)
       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.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.1.0:2)
       at java.lang.Thread.run(Thread.java:923)

firebase-iid-executor (timed waiting): tid=26 systid=24474 
       at sun.misc.Unsafe.park(Native method)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2141)
       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 com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.1.0:2)
       at java.lang.Thread.run(Thread.java:923)

firebase-installations-executor-1 (timed waiting): tid=27 systid=24475 
       at sun.misc.Unsafe.park(Native method)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2141)
       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:923)

firebase-installations-executor-2 (timed waiting): tid=29 systid=24477 
       at sun.misc.Unsafe.park(Native method)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2141)
       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:923)

Crashlytics Exception Handler1 (waiting): tid=28 systid=24491 
       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:2099)
       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:64)
       at com.google.firebase.crashlytics.internal.common.BackgroundPriorityRunnable.run(BackgroundPriorityRunnable.java:27)
       at java.lang.Thread.run(Thread.java:923)

............
google-oss-bot commented 1 year ago

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

argzdev commented 1 year ago

Hi @rkfteam, just a few notes, it seems to me that your app is receiving multiple unique ANRs (in relation to your previous ANRs). That said, your app might be doing a lot of work load processes right at the beginning of your app. Without proper threading, these will definitely cause ANRs. That said, I don't think Firebase is causing these ANRs. I recommend adding custom keys and values to Crashlytics to better identify where an ANR occurred.

Are you using NDK? Also for Unity Firebase issues, please open tickets to the Unity SDK instead.

I'll close this issue for now. Thanks!