We have an application that uses Android webview and we have noticed since 04/07/2021 ANRs when call the code below (The code is called in UIThread):
public void onLoadUrlWithHeaders(final String url, final Map<String, String> headers) {
Log.d(TAG, "onLoadUrl with headers : " + url);
webView.loadUrl(url, headers);
}
The problem is intermittent, and only happens on some devices. For exemple on our test devices:
Motorola Moto X (4) Android 9 (SDK 28)
Samsung SM - A520F Android 8 (SDK 26) - Webview Chrome 90.0.4430.82
The problem is happening in a version of our app released in December 2020 and that version had not been presenting the mentioned ANR until April.
excerpt from the /data/anr/traces.txt file of A520F after the ANR
suspend all histogram: Sum: 340.474ms 99% C.I. 0.042ms-187.678ms Avg: 4.365ms Max: 283.301ms
DALVIK THREADS (69):
"Signal Catcher" daemon prio=5 tid=3 Runnable
| group="system" sCount=0 dsCount=0 flags=0 obj=0x13680248 self=0x7d302c1400
| sysTid=15932 nice=0 cgrp=default sched=0/0 handle=0x7d254fe4f0
| state=R schedstat=( 0 0 0 ) utm=2 stm=3 core=3 HZ=100
| stack=0x7d25404000-0x7d25406000 stackSize=1005KB
| held mutexes= "mutator lock"(shared held)
native: #00 pc 0000000000397510 /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+212)
native: #01 pc 000000000045dce8 /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMapb+348)
native: #02 pc 000000000047549c /system/lib64/libart.so (_ZN3art14DumpCheckpoint3RunEPNS_6ThreadE+880)
native: #03 pc 000000000046d774 /system/lib64/libart.so (_ZN3art10ThreadList13RunCheckpointEPNS_7ClosureES2_+480)
native: #04 pc 000000000046d17c /system/lib64/libart.so (_ZN3art10ThreadList4DumpERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEb+796)
native: #05 pc 000000000046cd1c /system/lib64/libart.so (_ZN3art10ThreadList14DumpForSigQuitERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+920)
native: #06 pc 00000000004426f0 /system/lib64/libart.so (_ZN3art7Runtime14DumpForSigQuitERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+196)
native: #07 pc 000000000044bb88 /system/lib64/libart.so (_ZN3art13SignalCatcher13HandleSigQuitEv+1676)
native: #08 pc 000000000044a9c0 /system/lib64/libart.so (_ZN3art13SignalCatcher3RunEPv+388)
native: #09 pc 0000000000067d04 /system/lib64/libc.so (_ZL15__pthread_startPv+200)
native: #10 pc 000000000001f348 /system/lib64/libc.so (__start_thread+68)
(no managed stack frames)
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x731fda50 self=0x7d302c0a00
| sysTid=15926 nice=-10 cgrp=default sched=0/0 handle=0x7d353e19c8
| state=R schedstat=( 0 0 0 ) utm=4634 stm=638 core=2 HZ=100
| stack=0x7fd505c000-0x7fd505e000 stackSize=8MB
| held mutexes=
kernel: (couldn't read /proc/self/task/15926/stack)
native: #00 pc 00000000035e867c /data/app/com.android.chrome-ZK4DDobzNyyzf7J8pPGLPg==/base.apk (???)
native: #01 pc 00000000033e32d8 /data/app/com.android.chrome-ZK4DDobzNyyzf7J8pPGLPg==/base.apk (???)
at J.N.MAqmDh4t(Native method)
**at org.chromium.content.browser.framehost.NavigationControllerImpl.c(chromium-Monochrome.aab-stable-443008223:17)
at org.chromium.android_webview.AwContents.w(chromium-Monochrome.aab-stable-443008223:35)
at org.chromium.android_webview.AwContents.v(chromium-Monochrome.aab-stable-443008223:14)
at com.android.webview.chromium.WebViewChromium.loadUrl(chromium-Monochrome.aab-stable-443008223:5)**
at android.webkit.WebView.loadUrl(WebView.java:927)
at br.com.gabba.box.l.o(:-1)
at br.com.gabba.box.model.BO.k$a.c(:-1)
at br.com.gabba.box.model.BO.k$a.b(:-1)
at br.com.gabba.box.model.BO.LoginAuthBO.i(:-1)
at br.com.gabba.box.model.BO.LoginAuthBO_.H(:-1)
at br.com.gabba.box.model.BO.LoginAuthBO_$a.run(:-1)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
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)
Here is the entire traces.txt
Similar problem in Google Mobile Ads SDK Developers
There was a legacy code called on Activity onDestroy.
#Override
protected void onDestroy() {
super.onDestroy();
WebView webView = getWebView();
if (webView != null) {
webView.setWebViewClient(null);
webView.setWebChromeClient(null);
webView.loadUrl("about:blank");
}
}
This code could be executed immediately after a logout request in webview. When the response was still pending.
At some point, after a chromium update, when this happened (onDestroy with pending response) an ANR was observed in the next execution of webView.loadUrl.
We create a control to wait the logout response to finish the activity. The number of ANRs registered in the Play Store decreased more than 99%. Or you could simply remove the above code from ondestroy.
We have an ANR where the HeapTaskDaemon is blocked and the main thread is waiting and not busy/blocked. There are no parts of our code in any of the threads. How to debug this ANR? From what I see there is no deadlock and nothing heavy is being done on the main thread.
It also doesn't seem to be a long running operation in an INTENT.
Any trips on understanding the ANR would be really helpful. Also what does HeapTaskDaemon waiting to lock unknown object mean ?
Here is the HeapTaskDaemon thread:
HeapTaskDaemon" daemon prio=5 tid=6 Blocked
| group="system" sCount=1 dsCount=0 flags=1 obj=0x140c0338 self=0xa41d1400
| sysTid=1239 nice=4 cgrp=default sched=0/0 handle=0x99e3b970
| state=S schedstat=( 0 0 0 ) utm=515 stm=86 core=1 HZ=100
| stack=0x99d39000-0x99d3b000 stackSize=1038KB
| held mutexes=
#00 pc 000000000001902c /system/lib/libc.so (syscall+28)
#01 pc 00000000000b7289 /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+88)
#02 pc 00000000001cc795 /system/lib/libart.so (art::gc::TaskProcessor::GetTask(art::Thread*)+284)
#03 pc 00000000001ccd75 /system/lib/libart.so (art::gc::TaskProcessor::RunAllTasks(art::Thread*)+44)
#04 pc 00000000000551e3 /system/framework/arm/boot-core-libart.oat (Java_dalvik_system_VMRuntime_runHeapTasks__+74)
at dalvik.system.VMRuntime.runHeapTasks (Native method)
- waiting to lock an unknown object
at java.lang.Daemons$HeapTaskDaemon.runInternal (Daemons.java:461)
at java.lang.Daemons$Daemon.run (Daemons.java:103)
at java.lang.Thread.run (Thread.java:764)
Main Thread:
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x70cb3f08 self=0xac6a8000
| sysTid=1230 nice=-2 cgrp=default sched=0/0 handle=0xb07a64a4
| state=S schedstat=( 0 0 0 ) utm=2107 stm=662 core=1 HZ=100
| stack=0xbe6e0000-0xbe6e2000 stackSize=8MB
| held mutexes=
#00 pc 0000000000049658 /system/lib/libc.so (__epoll_pwait+20)
#01 pc 000000000001b7b5 /system/lib/libc.so (epoll_pwait+60)
#02 pc 000000000001b7e5 /system/lib/libc.so (epoll_wait+12)
#03 pc 000000000001008b /system/lib/libutils.so (android::Looper::pollInner(int)+118)
#04 pc 000000000000ff7d /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+32)
#05 pc 00000000000b2d0d /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, _jobject*, int)+24)
#06 pc 00000000000ba5d5 /system/framework/arm/boot-framework.oat (Java_android_os_MessageQueue_nativePollOnce__JI+92)
at android.os.MessageQueue.nativePollOnce (MessageQueue.java)
at android.os.MessageQueue.next (MessageQueue.java:325)
at android.os.Looper.loop (Looper.java:142)
at com.android.server.SystemServer.run (SystemServer.java:423)
at com.android.server.SystemServer.main (SystemServer.java:274)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:787)
The full ANR log is at https://pastebin.com/i4F4VgTS
Once again Google/Android9 crashes somewhere in native code library without giving any idea through Java stack trace or otherwise about where it happened and why.
In my case it happened during "REGISTER_AGENT" intent issued by Samsung SAP library.
Probably it's related to Samsung SAP library, but it's specific to Android9 only and it doesn't happen very often.
Any hint and help are appreciated.
Broadcast of Intent { act=com.samsung.accessory.action.REGISTER_AGENT flg=0x30 pkg=[package_name] cmp=[package_name]/com.samsung.android.sdk.accessory.RegisterUponInstallReceiver }
com.samsung.android.sdk.accessory.RegisterUponInstallReceiver
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x75952fb8 self=0x7368414c00
| sysTid=16534 nice=0 cgrp=default sched=0/0 handle=0x73eee21560
| state=S schedstat=( 92637885 21726999 102 ) utm=1 stm=7 core=1 HZ=100
| stack=0x7fd3ecd000-0x7fd3ecf000 stackSize=8MB
| held mutexes=
#00 pc 00000000000712e0 /system/lib64/libc.so (__epoll_pwait+8)
#01 pc 00000000000141c0 /system/lib64/libutils.so (android::Looper::pollInner(int)+144)
#02 pc 000000000001408c /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+60)
#03 pc 000000000012c25c /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44)
at android.os.MessageQueue.nativePollOnce (MessageQueue.java)
at android.os.MessageQueue.next (MessageQueue.java:326)
at android.os.Looper.loop (Looper.java:181)
at android.app.ActivityThread.main (ActivityThread.java:6990)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1445)
"Jit thread pool worker thread 0" tid=2 Native
"Jit thread pool worker thread 0" daemon prio=5 tid=2 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x132001a0 self=0x7361e24400
| sysTid=16540 nice=9 cgrp=default sched=0/0 handle=0x7361dff4f0
| state=S schedstat=( 1490961 201962 5 ) utm=0 stm=0 core=1 HZ=100
| stack=0x7361d01000-0x7361d03000 stackSize=1021KB
| held mutexes=
#00 pc 000000000001eeac /system/lib64/libc.so (syscall+28)
#01 pc 00000000000d7c24 /system/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+148)
#02 pc 00000000004b6614 /system/lib64/libart.so (art::ThreadPool::GetTask(art::Thread*)+260)
#03 pc 00000000004b5b6c /system/lib64/libart.so (art::ThreadPoolWorker::Run()+124)
#04 pc 00000000004b561c /system/lib64/libart.so (art::ThreadPoolWorker::Callback(void*)+148)
#05 pc 0000000000084df8 /system/lib64/libc.so (__pthread_start(void*)+208)
#06 pc 0000000000023ac4 /system/lib64/libc.so (__start_thread+68)
"ReferenceQueueDaemon" tid=4 Waiting
"ReferenceQueueDaemon" daemon prio=5 tid=4 Waiting
| group="system" sCount=1 dsCount=0 flags=1 obj=0x132002b0 self=0x73684e2000
| sysTid=16542 nice=4 cgrp=default sched=0/0 handle=0x7350ed74f0
| state=S schedstat=( 1160387 6055884 11 ) utm=0 stm=0 core=0 HZ=100
| stack=0x7350dd4000-0x7350dd6000 stackSize=1041KB
| held mutexes=
at java.lang.Object.wait (Native method)
- waiting on <0x0727dab7> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
at java.lang.Daemons$ReferenceQueueDaemon.runInternal (Daemons.java:178)
- locked <0x0727dab7> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
at java.lang.Daemons$Daemon.run (Daemons.java:103)
at java.lang.Thread.run (Thread.java:764)
"FinalizerWatchdogDaemon" tid=5 Waiting
"FinalizerWatchdogDaemon" daemon prio=5 tid=5 Waiting
| group="system" sCount=1 dsCount=0 flags=1 obj=0x13200338 self=0x73684e3800
| sysTid=16544 nice=4 cgrp=default sched=0/0 handle=0x7350ccb4f0
| state=S schedstat=( 428733 6635577 9 ) utm=0 stm=0 core=0 HZ=100
| stack=0x7350bc8000-0x7350bca000 stackSize=1041KB
| held mutexes=
at java.lang.Object.wait (Native method)
- waiting on <0x01261224> (a java.lang.Daemons$FinalizerWatchdogDaemon)
at java.lang.Daemons$FinalizerWatchdogDaemon.sleepUntilNeeded (Daemons.java:297)
- locked <0x01261224> (a java.lang.Daemons$FinalizerWatchdogDaemon)
at java.lang.Daemons$FinalizerWatchdogDaemon.runInternal (Daemons.java:277)
at java.lang.Daemons$Daemon.run (Daemons.java:103)
at java.lang.Thread.run (Thread.java:764)
"FinalizerDaemon" tid=6 Waiting
"FinalizerDaemon" daemon prio=5 tid=6 Waiting
| group="system" sCount=1 dsCount=0 flags=1 obj=0x132003c0 self=0x73684e2c00
| sysTid=16543 nice=4 cgrp=default sched=0/0 handle=0x7350dd14f0
| state=S schedstat=( 1754693 6156655 10 ) utm=0 stm=0 core=0 HZ=100
| stack=0x7350cce000-0x7350cd0000 stackSize=1041KB
| held mutexes=
at java.lang.Object.wait (Native method)
- waiting on <0x0294e18d> (a java.lang.Object)
at java.lang.Object.wait (Object.java:422)
at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:188)
- locked <0x0294e18d> (a java.lang.Object)
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)
"Binder:16534_1" tid=8 Native
"Binder:16534_1" prio=5 tid=8 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x13200448 self=0x735e88d000
| sysTid=16546 nice=0 cgrp=default sched=0/0 handle=0x73509c14f0
| state=S schedstat=( 1058729 78231 14 ) utm=0 stm=0 core=1 HZ=100
| stack=0x73508c6000-0x73508c8000 stackSize=1009KB
| held mutexes=
#00 pc 00000000000713cc /system/lib64/libc.so (__ioctl+4)
#01 pc 0000000000029c48 /system/lib64/libc.so (ioctl+136)
#02 pc 000000000005ac9c /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+260)
#03 pc 000000000005ae78 /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+24)
#04 pc 000000000005b5cc /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+60)
#05 pc 000000000007c090 /system/lib64/libbinder.so (android::PoolThread::threadLoop()+24)
#06 pc 000000000000fb80 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+280)
#07 pc 00000000000bcbf4 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+140)
#08 pc 0000000000084df8 /system/lib64/libc.so (__pthread_start(void*)+208)
#09 pc 0000000000023ac4 /system/lib64/libc.so (__start_thread+68)
"Binder:16534_2" tid=9 Native
"Binder:16534_2" prio=5 tid=9 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x132004d0 self=0x735fd04000
| sysTid=16547 nice=0 cgrp=default sched=0/0 handle=0x73508c34f0
| state=S schedstat=( 5113655 9872309 15 ) utm=0 stm=0 core=1 HZ=100
| stack=0x73507c8000-0x73507ca000 stackSize=1009KB
| held mutexes=
#00 pc 00000000000713cc /system/lib64/libc.so (__ioctl+4)
#01 pc 0000000000029c48 /system/lib64/libc.so (ioctl+136)
#02 pc 000000000005ac9c /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+260)
#03 pc 000000000005ae78 /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+24)
#04 pc 000000000005b5cc /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+60)
#05 pc 000000000007c090 /system/lib64/libbinder.so (android::PoolThread::threadLoop()+24)
#06 pc 000000000000fb80 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+280)
#07 pc 00000000000bcbf4 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+140)
#08 pc 0000000000084df8 /system/lib64/libc.so (__pthread_start(void*)+208)
#09 pc 0000000000023ac4 /system/lib64/libc.so (__start_thread+68)
"Profile Saver" tid=10 Native
"Profile Saver" daemon prio=5 tid=10 Native
| group="system" sCount=1 dsCount=0 flags=1 obj=0x13200558 self=0x7361e29800
| sysTid=16548 nice=9 cgrp=default sched=0/0 handle=0x73500034f0
| state=S schedstat=( 13089538 7896001 11 ) utm=0 stm=0 core=0 HZ=100
| stack=0x734ff08000-0x734ff0a000 stackSize=1009KB
| held mutexes=
#00 pc 000000000001eeac /system/lib64/libc.so (syscall+28)
#01 pc 00000000000d7c24 /system/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+148)
#02 pc 000000000032a168 /system/lib64/libart.so (art::ProfileSaver::Run()+384)
#03 pc 000000000032d58c /system/lib64/libart.so (art::ProfileSaver::RunProfileSaverThread(void*)+92)
#04 pc 0000000000084df8 /system/lib64/libc.so (__pthread_start(void*)+208)
#05 pc 0000000000023ac4 /system/lib64/libc.so (__start_thread+68)
"Timer-0" tid=11 TimedWaiting
"Timer-0" prio=5 tid=11 TimedWaiting
| group="main" sCount=1 dsCount=0 flags=1 obj=0x132005e0 self=0x735fcae000
| sysTid=16551 nice=0 cgrp=default sched=0/0 handle=0x734fe5b4f0
| state=S schedstat=( 24982964 11812847 67 ) utm=1 stm=0 core=1 HZ=100
| stack=0x734fd58000-0x734fd5a000 stackSize=1041KB
| held mutexes=
at java.lang.Object.wait (Native method)
- waiting on <0x062b2f42> (a java.util.TaskQueue)
at java.lang.Object.wait (Object.java:422)
at java.util.TimerThread.mainLoop (Timer.java:559)
- locked <0x062b2f42> (a java.util.TaskQueue)
at java.util.TimerThread.run (Timer.java:512)
"RegistrationThread" tid=12 Waiting
"RegistrationThread" prio=5 tid=12 Waiting
| group="main" sCount=1 dsCount=0 flags=1 obj=0x132006a8 self=0x73684b3000
| sysTid=16555 nice=0 cgrp=default sched=0/0 handle=0x734fd554f0
| state=S schedstat=( 360153 6123923 4 ) utm=0 stm=0 core=0 HZ=100
| stack=0x734fc52000-0x734fc54000 stackSize=1041KB
| held mutexes=
at java.lang.Object.wait (Native method)
- waiting on <0x07d56b53> (a java.lang.Object)
at java.lang.Thread.parkFor$ (Thread.java:2137)
- locked <0x07d56b53> (a java.lang.Object)
at sun.misc.Unsafe.park (Unsafe.java:358)
at java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)
at java.util.concurrent.FutureTask.awaitDone (FutureTask.java:450)
at java.util.concurrent.FutureTask.get (FutureTask.java:192)
at com.samsung.android.sdk.accessory.RegisterUponInstallReceiver$1.run (unavailable)
"RegistreationThread" tid=13 Native
"RegistreationThread" prio=5 tid=13 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x13200990 self=0x73684b3c00
| sysTid=16556 nice=0 cgrp=default sched=0/0 handle=0x734fc4f4f0
| state=S schedstat=( 8286656 6348153 18 ) utm=0 stm=0 core=1 HZ=100
| stack=0x734fb4c000-0x734fb4e000 stackSize=1041KB
| held mutexes=
#00 pc 00000000000713cc /system/lib64/libc.so (__ioctl+4)
#01 pc 0000000000029c48 /system/lib64/libc.so (ioctl+136)
#02 pc 000000000005ac9c /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+260)
#03 pc 000000000005bb70 /system/lib64/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+360)
#04 pc 000000000005b890 /system/lib64/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+176)
#05 pc 0000000000051560 /system/lib64/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+72)
#06 pc 000000000013c110 /system/lib64/libandroid_runtime.so (android_os_BinderProxy_transact(_JNIEnv*, _jobject*, int, _jobject*, _jobject*, int)+152)
at android.os.BinderProxy.transactNative (Native method)
at android.os.BinderProxy.transact (Binder.java:1142)
at com.samsung.accessory.api.ISAFrameworkManagerV2$Stub$Proxy.registerComponent (unavailable)
at com.samsung.android.sdk.accessory.SAAdapter.a (unavailable)
- locked <0x01c42c90> (a com.samsung.android.sdk.accessory.SAAdapter)
at com.samsung.android.sdk.accessory.j$a.a (unavailable)
at com.samsung.android.sdk.accessory.j$a.call (unavailable)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.lang.Thread.run (Thread.java:764)
"Binder:16534_3" tid=14 Native
"Binder:16534_3" prio=5 tid=14 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x13201170 self=0x735e918000
| sysTid=16617 nice=0 cgrp=default sched=0/0 handle=0x734fb494f0
| state=S schedstat=( 4330424 370692 5 ) utm=0 stm=0 core=1 HZ=100
| stack=0x734fa4e000-0x734fa50000 stackSize=1009KB
| held mutexes=
#00 pc 00000000000713cc /system/lib64/libc.so (__ioctl+4)
#01 pc 0000000000029c48 /system/lib64/libc.so (ioctl+136)
#02 pc 000000000005ac9c /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+260)
#03 pc 000000000005ae78 /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+24)
#04 pc 000000000005b5cc /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+60)
#05 pc 000000000007c090 /system/lib64/libbinder.so (android::PoolThread::threadLoop()+24)
#06 pc 000000000000fb80 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+280)
#07 pc 00000000000bcbf4 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+140)
#08 pc 0000000000084df8 /system/lib64/libc.so (__pthread_start(void*)+208)
#09 pc 0000000000023ac4 /system/lib64/libc.so (__start_thread+68)
"Signal Catcher" tid=3 Runnable
"Signal Catcher" daemon prio=5 tid=3 Runnable
| group="system" sCount=0 dsCount=0 flags=0 obj=0x13200228 self=0x7368416400
| sysTid=16541 nice=0 cgrp=default sched=0/0 handle=0x7361cfe4f0
| state=R schedstat=( 53512999 6126116 5 ) utm=2 stm=2 core=0 HZ=100
| stack=0x7361c03000-0x7361c05000 stackSize=1009KB
| held mutexes= "mutator lock"(shared held)
#00 pc 00000000003cb35c /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+220)
#01 pc 000000000049aca8 /system/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+352)
#02 pc 00000000004b4d9c /system/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+844)
#03 pc 00000000004adadc /system/lib64/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+476)
#04 pc 00000000004acec0 /system/lib64/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool)+1120)
#05 pc 00000000004ac974 /system/lib64/libart.so (art::ThreadList::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char>>&)+884)
#06 pc 000000000047c26c /system/lib64/libart.so (art::Runtime::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char>>&)+188)
#07 pc 00000000004881bc /system/lib64/libart.so (art::SignalCatcher::HandleSigQuit()+1468)
#08 pc 0000000000486ea4 /system/lib64/libart.so (art::SignalCatcher::Run(void*)+380)
#09 pc 0000000000084df8 /system/lib64/libc.so (__pthread_start(void*)+208)
#10 pc 0000000000023ac4 /system/lib64/libc.so (__start_thread+68)
"HeapTaskDaemon" tid=7
"HeapTaskDaemon" daemon prio=5 tid=7 WaitingForTaskProcessor
| group="system" sCount=1 dsCount=0 flags=1 obj=0x132011f8 self=0x735fc37c00
| sysTid=16545 nice=4 cgrp=default sched=0/0 handle=0x7350bc54f0
| state=S schedstat=( 49512888 1873077 14 ) utm=4 stm=0 core=1 HZ=100
| stack=0x7350ac2000-0x7350ac4000 stackSize=1041KB
| held mutexes=
#00 pc 000000000001eeac /system/lib64/libc.so (syscall+28)
#01 pc 00000000000d7c24 /system/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+148)
#02 pc 0000000000230820 /system/lib64/libart.so (art::gc::TaskProcessor::GetTask(art::Thread*)+504)
#03 pc 0000000000231098 /system/lib64/libart.so (art::gc::TaskProcessor::RunAllTasks(art::Thread*)+96)
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)
© 2019 Google · Mobile App · Help · Site Terms · Privacy · Developer Distribution Agreement
In an native cpp application compiled for Android I am getting ANR error with the cause keyDispatchingTimedOut.It only happens sometimes when the app switches from native activity to java activity.
Nothing in the error report really stands out. Most of the threads just sit in a loop waiting for input. I cant disclose any code but the code at 58b505 is from android_native_app_glue library.
I have attached the ANR error report: full ANR on pastebin
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 obj=0x741e33c0 self=0xab684ea8
| sysTid=29202 nice=-1 cgrp=default sched=0/0 handle=0xf778fb34
| state=S schedstat=( 962236509 24407600 624 ) utm=84 stm=12 core=4 HZ=100
| stack=0xff56e000-0xff570000 stackSize=8MB
| held mutexes=
native: pc 0000000000042c9c /system/lib/libc.so (__epoll_pwait+20)
native: pc 00000000000195cf /system/lib/libc.so (epoll_pwait+26)
native: pc 00000000000195dd /system/lib/libc.so (epoll_wait+6)
native: pc 0000000000012d8b /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+102)
native: pc 0000000000013007 /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+130)
native: pc 00000000000836fd /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+22)
native: pc 000000000000055d /data/dalvik-cache/arm/system#framework#boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+96)
at android.os.MessageQueue.nativePollOnce (Native method)
at android.os.MessageQueue.next (MessageQueue.java:323)
at android.os.Looper.loop (Looper.java:135)
at android.app.ActivityThread.main (ActivityThread.java:5438)
at java.lang.reflect.Method.invoke! (Native method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:628)
"Thread-295" prio=6 tid=17 Native
| group="main" sCount=1 dsCount=0 obj=0x12c630a0 self=0xabdbcd60
| sysTid=29269 nice=-1 cgrp=default sched=0/0 handle=0xdabfd930
| state=S schedstat=( 15667236 2344530 115 ) utm=0 stm=1 core=6 HZ=100
| stack=0xdab01000-0xdab03000 stackSize=1014KB
| held mutexes=
native: pc 0000000000016908 /system/lib/libc.so (syscall+28)
native: pc 000000000004167b /system/lib/libc.so (_ZL33__pthread_cond_timedwait_relativeP23pthread_cond_internal_tP15pthread_mutex_tPK8timespec+56)
native: pc 000000000058b505 /data/app/com.package-1/lib/arm/libgame.so (???)
native: pc 000000000058b2ed /data/app/com.package-1/lib/arm/libgame.so (???)
native: pc 00000000005ac4c7 /data/app/com.package-1/lib/arm/libgame.so (???)
native: pc 000000000004185b /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: pc 00000000000192a5 /system/lib/libc.so (__start_thread+6)
There is one ANR report which I need help to understand it. It is only happened to this user so far. Under the main thread, I can't find anything related to my app package.
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 obj=0x7392f2a0 self=0xb8bdcd80
| sysTid=1973 nice=-2 cgrp=native sched=0/0 handle=0xb6f3cb34
| state=S schedstat=( 52372964435 58689172479 125804 ) utm=3878 stm=1359 core=7 HZ=100
| stack=0xbe395000-0xbe397000 stackSize=8MB
| held mutexes=
kernel: (couldn't read /proc/self/task/1973/stack)
native: #00 pc 00042f0c /system/lib/libc.so (__epoll_pwait+20)
native: #01 pc 0001967f /system/lib/libc.so (epoll_pwait+26)
native: #02 pc 0001968d /system/lib/libc.so (epoll_wait+6)
native: #03 pc 00012da3 /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+102)
native: #04 pc 0001301f /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+130)
native: #05 pc 00083ed1 /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+22)
native: #06 pc 00000585 /system/framework/arm/boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+96)
at android.os.MessageQueue.nativePollOnce(Native method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:135)
at com.android.server.SystemServer.run(SystemServer.java:288)
at com.android.server.SystemServer.main(SystemServer.java:173)
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)
And I noticed this thread which is blocked. However, I don't know how to trace from there.
"HeapTaskDaemon" daemon prio=5 tid=6 Blocked
| group="system" sCount=1 dsCount=0 obj=0x12c041c0 self=0xb8c02318
| sysTid=1982 nice=0 cgrp=native sched=0/0 handle=0xb40c3930
| state=S schedstat=( 68261230481 5881920066 14105 ) utm=6561 stm=265 core=7 HZ=100
| stack=0xb3fc1000-0xb3fc3000 stackSize=1038KB
| held mutexes=
kernel: (couldn't read /proc/self/task/1982/stack)
native: #00 pc 000169b8 /system/lib/libc.so (syscall+28)
native: #01 pc 000f60bb /system/lib/libart.so (_ZN3art17ConditionVariable4WaitEPNS_6ThreadE+82)
native: #02 pc 001cdff1 /system/lib/libart.so (_ZN3art2gc13TaskProcessor7GetTaskEPNS_6ThreadE+92)
native: #03 pc 001ce505 /system/lib/libart.so (_ZN3art2gc13TaskProcessor11RunAllTasksEPNS_6ThreadE+60)
native: #04 pc 00000387 /system/framework/arm/boot.oat (Java_dalvik_system_VMRuntime_runHeapTasks__+74)
at dalvik.system.VMRuntime.runHeapTasks(Native method)
- waiting to lock an unknown object
at java.lang.Daemons$HeapTaskDaemon.run(Daemons.java:355)
at java.lang.Thread.run(Thread.java:818)
Here is the complete file. Thanks for the input.
ANR file