I have a huge problem! Some people that are using my app are getting an ANR (app is not responding), when they are doing a database operation (like updating an Object to the database), while an (intent-)service with database reading is running.
In detail:
I am using a single-instance pattern with the Application-Desgin. That means the given context to the SQLiteOpenHelper is the ApplicationContext
the block operations are:
ArrayList<Workposition> web_list = (ArrayList<Workposition>) sessionDAO
.getWorkpositionDao().queryBuilder().list();
AND
sessionDAO.getWorkpositionDao().update(plantevent);
The both sessionDao using the a SQLLiteHelper with the ApplicationContext. The first read operation is happening in the background and the second operation happens at an onClick method
if you are interested in reading the ANR there you go, but the most important stuff is listed above.
The code lines mentioned above are in EventView and in Workposition.
----- pid 23262 at 2014-10-21 07:58:59 -----
Cmd line: de.myApp
JNI: CheckJNI is off; workarounds are off; pins=0; globals=293
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41806ea0 self=0x416fcb78
| sysTid=23262 nice=0 sched=0/0 cgrp=apps handle=1073869140
| state=S schedstat=( 0 0 0 ) utm=306 stm=55 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x41806f70> (a java.lang.VMThread) held by tid=1 (main)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
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.acquireQueued(AbstractQueuedSynchronizer.java:846)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1175)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:180)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:256)
at de.greenrobot.dao.identityscope.IdentityScopeLong.put2(IdentityScopeLong.java:85)
at de.greenrobot.dao.identityscope.IdentityScopeLong.put(IdentityScopeLong.java:76)
at de.greenrobot.dao.identityscope.IdentityScopeLong.put(IdentityScopeLong.java:31)
at de.greenrobot.dao.AbstractDao.attachEntity(AbstractDao.java:695)
at de.greenrobot.dao.AbstractDao.updateInsideSynchronized(AbstractDao.java:680)
at de.greenrobot.dao.AbstractDao.update(AbstractDao.java:654)
at de.myApp.views.EventView$1.run(EventView.java:122)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
"IntentService[a]" prio=5 tid=13 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42e28460 self=0x7b5302c0
| sysTid=23337 nice=0 sched=0/0 cgrp=apps handle=2005620856
| state=S schedstat=( 0 0 0 ) utm=7309 stm=180 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x42c4b8f8> (a java.lang.VMThread) held by tid=13 (IntentService[a])
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:197)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:739)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:400)
at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:905)
at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:152)
at android.database.sqlite.SQLiteCursor.onMove(SQLiteCursor.java:124)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:214)
at android.database.AbstractCursor.moveToNext(AbstractCursor.java:245)
at de.greenrobot.dao.AbstractDao.loadAllFromCursor(AbstractDao.java:392)
at de.greenrobot.dao.AbstractDao.loadAllAndCloseCursor(AbstractDao.java:184)
at de.greenrobot.dao.InternalQueryDaoAccess.loadAllAndCloseCursor(InternalQueryDaoAccess.java:21)
at de.greenrobot.dao.query.Query.list(Query.java:121)
at de.greenrobot.dao.query.QueryBuilder.list(QueryBuilder.java:374)
at de.myApp.modelDAO.Workposition.upload(Workposition.java:588)
at de.myApp.service.ApiService.update(ApiService.java:138)
at de.myApp.service.ApiService.onHandleIntent(ApiService.java:51)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.os.HandlerThread.run(HandlerThread.java:61)
"Binder_3" prio=5 tid=11 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x42fc7e68 self=0x778c0300
| sysTid=23306 nice=0 sched=0/0 cgrp=apps handle=2006715504
| state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1
#00 pc 0002072c /system/lib/libc.so (__ioctl+8)
#01 pc 0002cec3 /system/lib/libc.so (ioctl+14)
#02 pc 0001d3ed /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+140)
#03 pc 0001daf7 /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+6)
#04 pc 0001db8d /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+48)
#05 pc 000219e9 /system/lib/libbinder.so
#06 pc 0000ea5d /system/lib/libutils.so (android::Thread::_threadLoop(void*)+216)
#07 pc 00052299 /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+68)
#08 pc 0000e58f /system/lib/libutils.so
#09 pc 0000d278 /system/lib/libc.so (__thread_entry+72)
#10 pc 0000d410 /system/lib/libc.so (pthread_create+240)
at dalvik.system.NativeStart.run(Native Method)
"AsyncTask #1" prio=5 tid=10 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42e06f38 self=0x778c2768
| sysTid=23301 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=2005674944
| state=S schedstat=( 0 0 0 ) utm=29 stm=5 core=2
at java.lang.Object.wait(Native Method)
- waiting on <0x42e070d0> (a java.lang.VMThread) held by tid=10 (AsyncTask #1)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2017)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
"pool-1-thread-1" prio=5 tid=12 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42ca18e0 self=0x79564280
| sysTid=23281 nice=0 sched=0/0 cgrp=apps handle=2035697368
| state=S schedstat=( 0 0 0 ) utm=1 stm=1 core=2
at java.lang.Object.wait(Native Method)
- waiting on <0x42ca1a28> (a java.lang.VMThread) held by tid=12 (pool-1-thread-1)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2017)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
"Binder_2" prio=5 tid=9 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x42a3f878 self=0x7255dc60
| sysTid=23273 nice=0 sched=0/0 cgrp=apps handle=1918229016
| state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=0
#00 pc 0002072c /system/lib/libc.so (__ioctl+8)
#01 pc 0002cec3 /system/lib/libc.so (ioctl+14)
#02 pc 0001d3ed /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+140)
#03 pc 0001daf7 /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+6)
#04 pc 0001db8d /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+48)
#05 pc 000219e9 /system/lib/libbinder.so
#06 pc 0000ea5d /system/lib/libutils.so (android::Thread::_threadLoop(void*)+216)
#07 pc 00052299 /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+68)
#08 pc 0000e58f /system/lib/libutils.so
#09 pc 0000d278 /system/lib/libc.so (__thread_entry+72)
#10 pc 0000d410 /system/lib/libc.so (pthread_create+240)
at dalvik.system.NativeStart.run(Native Method)
I have no idea why this problem apears. Is it because of the single-instance? would it work if i would use two different contexts? or should i execute update in an background thread?
You should never access the database on the main thread. Lots of database operations use a single lock so when you do this, any long running background query can block your main thread. Since background tasks will have lower priority, it can easily cause an ANR.
In addition to this, disk access may be slowed by any random reason (e.g. play store updating apps). You really don't want to rely your UI on that (don't forget, your UI has only 16 ms).
In this ANR, the background thread already has the Identity Scope lock, waiting to get an SqliteConnection while your main thread is blocked by the Identity Scope lock of Green Dao. Nothing shows why database is taking so much to provide the connection (are there any other threads not shown in the ANR?).
Just make sure you never access the database on main thread. (write or read, does not matter much). I believe system would eventually solve this conflict (e.g. a connection will eventually be available)
Run your app with StrictMode enabled to see where you're doing long-running operations on the UI thread then move those operations to an AsyncTask or something.
Related
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
I get the following complete error message: Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 2. Wait queue head age: 9379.7ms.)
See below the code + traces. It seems that the lock happens at GetIP_WAN.java:32 which is the line:
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
I call this function whenever I detect a network change wifi-3g/4g-no internet. and in a few other places. it happens on every occasion but much more from the network change detection obviously.
I verify if the public IP has changed this way:
ipwan = giw.getWanIpAddress();
and in getWanIpAddress:
ipwan = new GetIP_WAN().execute().get();
ipwan being a String pointing to the public IP.
I am not able to reproduce this ANR.
My app uses several async tasks that might be an intensive async task for several seconds. If I test it with a strong load and I switch off wifi I don't have problems.
Input would be much appreciated!!!
public class GetIP_WAN extends AsyncTask<Void, Integer, String> {
#Override
protected String doInBackground(Void... params) {
URL url;
String ipwan = null;
try {
// get URL content
url = new URL("http://ipv4bot.whatismyipaddress.com/");
URLConnection conn = url.openConnection();
conn.setConnectTimeout(3000);
// open the stream and put it into BufferedReader
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
ipwan = br.readLine();
br.close();
} catch (java.net.SocketTimeoutException e) {
return ("timeout");
} catch (MalformedURLException e) {
e.printStackTrace();
return ("malformed");
} catch (IOException e) {
e.printStackTrace();
return ("exception");
}
return (ipwan);
}
}
and here is the trace (my code where the lock happens is identified by >>>):
"main" tid=1 Waiting
"main" prio=5 tid=1 Waiting
| group="main" sCount=1 dsCount=0 obj=0x7331b000 self=0xb81bb2c0
| sysTid=23053 nice=-4 cgrp=default sched=0/0 handle=0xb6f5cbec
| state=S schedstat=( 26983505120 16031385654 42843 ) utm=2225 stm=473 core=0 HZ=100
| stack=0xbe5d4000-0xbe5d6000 stackSize=8MB
| held mutexes=
at java.lang.Object.wait! (Native method)
- waiting on <0x0448108a> (a java.lang.Object)
at java.lang.Thread.parkFor (Thread.java:1220)
- locked <0x0448108a> (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.FutureTask.awaitDone (FutureTask.java:400)
at java.util.concurrent.FutureTask.get (FutureTask.java:162)
at android.os.AsyncTask.get (AsyncTask.java:487)
>>> at com.bernard_zelmans.checksecurity.Connectivity.GetInfoWan.getWanIpAddress (GetInfoWan.java:168)
>>> at com.bernard_zelmans.checksecurity.Connectivity.ConnectivityFragment$2.onClick (ConnectivityFragment.java:155)
at android.view.View.performClick (View.java:4781)
at android.view.View$PerformClick.run (View.java:19874)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:135)
at android.app.ActivityThread.main (ActivityThread.java:5254)
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:902)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:697)
"AsyncTask #5" tid=21 Native Performing network I/O
"AsyncTask #5" prio=5 tid=21 Native
| group="main" sCount=1 dsCount=0 obj=0x1372b0a0 self=0xb8537190
| sysTid=23175 nice=10 cgrp=bg_non_interactive sched=0/0 handle=0xb8536ee0
| state=S schedstat=( 9854319 53209536 49 ) utm=0 stm=0 core=0 HZ=100
| stack=0xa413d000-0xa413f000 stackSize=1036KB
| held mutexes=
native: pc 000000000003a180 /system/lib/libc.so (recvfrom+16)
native: pc 0000000000020165 /system/lib/libjavacore.so (???)
native: pc 00000000002d557d /data/dalvik-cache/arm/system#framework#boot.oat (Java_libcore_io_Posix_recvfromBytes__Ljava_io_FileDescriptor_2Ljava_lang_Object_2IIILjava_net_InetSocketAddress_2+176)
at libcore.io.Posix.recvfromBytes (Native method)
at libcore.io.Posix.recvfrom (Posix.java:185)
at libcore.io.BlockGuardOs.recvfrom (BlockGuardOs.java:250)
at libcore.io.IoBridge.recvfrom (IoBridge.java:553)
at java.net.PlainSocketImpl.read (PlainSocketImpl.java:485)
at java.net.PlainSocketImpl.access$000 (PlainSocketImpl.java:37)
at java.net.PlainSocketImpl$PlainSocketInputStream.read (PlainSocketImpl.java:237)
at com.android.okio.Okio$2.read (Okio.java:113)
at com.android.okio.RealBufferedSource.indexOf (RealBufferedSource.java:147)
at com.android.okio.RealBufferedSource.readUtf8LineStrict (RealBufferedSource.java:94)
at com.android.okhttp.internal.http.HttpConnection.readResponse (HttpConnection.java:179)
at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders (HttpTransport.java:101)
at com.android.okhttp.internal.http.HttpEngine.readResponse (HttpEngine.java:628)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute (HttpURLConnectionImpl.java:388)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse (HttpURLConnectionImpl.java:332)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream (HttpURLConnectionImpl.java:199)
>>> at com.bernard_zelmans.checksecurity.Connectivity.GetIP_WAN.doInBackground (GetIP_WAN.java:32)
>>> at com.bernard_zelmans.checksecurity.Connectivity.GetIP_WAN.doInBackground (GetIP_WAN.java:16)
at android.os.AsyncTask$2.call (AsyncTask.java:292)
at java.util.concurrent.FutureTask.run (FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
at java.lang.Thread.run (Thread.java:818)
"WifiManager" tid=22 Native
"WifiManager" prio=5 tid=22 Native
| group="main" sCount=1 dsCount=0 obj=0x137192e0 self=0xb85369a0
| sysTid=23176 nice=0 cgrp=default sched=0/0 handle=0xb84af978
| state=S schedstat=( 2818438 6808230 23 ) utm=0 stm=0 core=1 HZ=100
| stack=0xa4035000-0xa4037000 stackSize=1036KB
| held mutexes=
native: pc 000000000003a0ac /system/lib/libc.so (__epoll_pwait+20)
native: pc 0000000000011483 /system/lib/libc.so (epoll_pwait+26)
native: pc 0000000000011491 /system/lib/libc.so (epoll_wait+6)
native: pc 0000000000010edf /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+98)
native: pc 0000000000011109 /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+92)
native: pc 000000000007e371 /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvi+22)
native: pc 000000000010e76b /data/dalvik-cache/arm/system#framework#boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+102)
at android.os.MessageQueue.nativePollOnce (Native method)
at android.os.MessageQueue.next (MessageQueue.java:143)
at android.os.Looper.loop (Looper.java:122)
at android.os.HandlerThread.run (HandlerThread.java:61)
"Heap thread pool worker thread 1" tid=2 Native
"Heap thread pool worker thread 1" prio=5 tid=2 Native (still starting up)
| group="" sCount=1 dsCount=0 obj=0x0 self=0xb8337008
| sysTid=23060 nice=0 cgrp=default sched=0/0 handle=0xb81c1910
| state=S schedstat=( 2796719 5468959 19 ) utm=0 stm=0 core=0 HZ=100
| stack=0xb49ce000-0xb49d0000 stackSize=1020KB
| held mutexes=
native: pc 000000000000f9b0 /system/lib/libc.so (syscall+28)
native: pc 00000000000a8c4b /system/lib/libart.so (_ZN3art17ConditionVariable4WaitEPNS_6ThreadE+82)
native: pc 000000000022f877 /system/lib/libart.so (_ZN3art10ThreadPool7GetTaskEPNS_6ThreadE+50)
native: pc 000000000022f81f /system/lib/libart.so (_ZN3art16ThreadPoolWorker3RunEv+54)
native: pc 000000000023005d /system/lib/libart.so (_ZN3art16ThreadPoolWorker8CallbackEPv+52)
native: pc 00000000000132bb /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: pc 00000000000111e7 /system/lib/libc.so (__start_thread+6)
"Heap thread pool worker thread 2" tid=3 Native
"Heap thread pool worker thread 2" prio=5 tid=3 Native (still starting up)
| group="" sCount=1 dsCount=0 obj=0x0 self=0xb81c0ea0
| sysTid=23061 nice=0 cgrp=default sched=0/0 handle=0xb833a0b0
| state=S schedstat=( 5997967 2723698 18 ) utm=0 stm=0 core=0 HZ=100
| stack=0xb48ce000-0xb48d0000 stackSize=1020KB
| held mutexes=
native: pc 000000000000f9b0 /system/lib/libc.so (syscall+28)
native: pc 00000000000a8c4b /system/lib/libart.so (_ZN3art17ConditionVariable4WaitEPNS_6ThreadE+82)
native: pc 000000000022f877 /system/lib/libart.so (_ZN3art10ThreadPool7GetTaskEPNS_6ThreadE+50)
native: pc 000000000022f81f /system/lib/libart.so (_ZN3art16ThreadPoolWorker3RunEv+54)
native: pc 000000000023005d /system/lib/libart.so (_ZN3art16ThreadPoolWorker8CallbackEPv+52)
native: pc 00000000000132bb /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: pc 00000000000111e7 /system/lib/libc.so (__start_thread+6)
"Heap thread pool worker thread 0" tid=4 Native
"Heap thread pool worker thread 0" prio=5 tid=4 Native (still starting up)
| group="" sCount=1 dsCount=0 obj=0x0 self=0xb83390c0
| sysTid=23059 nice=0 cgrp=default sched=0/0 handle=0xb82a4b58
| state=S schedstat=( 3379426 4137085 15 ) utm=0 stm=0 core=1 HZ=100
| stack=0xb4ace000-0xb4ad0000 stackSize=1020KB
| held mutexes=
native: pc 000000000000f9b0 /system/lib/libc.so (syscall+28)
native: pc 00000000000a8c4b /system/lib/libart.so (_ZN3art17ConditionVariable4WaitEPNS_6ThreadE+82)
native: pc 000000000022f877 /system/lib/libart.so (_ZN3art10ThreadPool7GetTaskEPNS_6ThreadE+50)
native: pc 000000000022f81f /system/lib/libart.so (_ZN3art16ThreadPoolWorker3RunEv+54)
native: pc 000000000023005d /system/lib/libart.so (_ZN3art16ThreadPoolWorker8CallbackEPv+52)
native: pc 00000000000132bb /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: pc 00000000000111e7 /system/lib/libc.so (__start_thread+6)
"HeapTrimmerDaemon" tid=6 Waiting
"HeapTrimmerDaemon" daemon prio=5 tid=6 Waiting
| group="system" sCount=1 dsCount=0 obj=0x12c061c0 self=0xb833c230
| sysTid=23066 nice=0 cgrp=default sched=0/0 handle=0xb833ca20
| state=S schedstat=( 16039218 18453438 23 ) utm=1 stm=0 core=3 HZ=100
| stack=0xa6f4e000-0xa6f50000 stackSize=1036KB
| held mutexes=
at java.lang.Object.wait! (Native method)
- waiting on <0x1c7546fb> (a java.lang.Daemons$HeapTrimmerDaemon)
at java.lang.Daemons$HeapTrimmerDaemon.run (Daemons.java:311)
- locked <0x1c7546fb> (a java.lang.Daemons$HeapTrimmerDaemon)
at java.lang.Thread.run (Thread.java:818)
"GCDaemon" tid=7 Waiting
"FinalizerWatchdogDaemon" tid=8 Waiting
"Binder_1" tid=9 Native
"FinalizerDaemon" tid=10 Waiting
"ReferenceQueueDaemon" tid=11 Waiting
"Binder_2" tid=12 Native
"AsyncTask #1" tid=13 Waiting
"Timer-0" tid=14 Waiting
"RenderThread" tid=15 Native
"AsyncTask #2" tid=18 Waiting
"AsyncTask #3" tid=19 Waiting
"AsyncTask #4" tid=20 Waiting
"Binder_3" tid=23 Native
"AdWorker(Default) #1" tid=24 TimedWaiting
"java.lang.ProcessManager" tid=25 Waiting
"AdWorker(Default) #2" tid=26 TimedWaiting
"AdWorker(Default) #3" tid=27 TimedWaiting
"AdWorker(Default) #4" tid=28 TimedWaiting
"AdWorker(Default) #5" tid=29 TimedWaiting
"Binder_6" tid=30 Native
"Binder_4" tid=40 Native
"Binder_7" tid=45 Native
"Binder_5" tid=49 Native
"Signal Catcher" tid=5 Runnable
"Signal Catcher" daemon prio=5 tid=5 Runnable
| group="system" sCount=0 dsCount=0 obj=0x12c000a0 self=0xb833abf8
| sysTid=23062 nice=0 cgrp=default sched=0/0 handle=0xb8339498
| state=R schedstat=( 166092660 21972502 124 ) utm=8 stm=8 core=0 HZ=100
| stack=0xb47c4000-0xb47c6000 stackSize=1012KB
| held mutexes= "thread list lock" "mutator lock"(exclusive held)
native: pc 0000000000004758 /system/lib/libbacktrace_libc++.so (_ZN13UnwindCurrent6UnwindEjP8ucontext+23)
native: pc 0000000000002f8d /system/lib/libbacktrace_libc++.so (_ZN9Backtrace6UnwindEjP8ucontext+8)
native: pc 00000000002411c9 /system/lib/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiPKcPNS_6mirror9ArtMethodE+68)
native: pc 0000000000225591 /system/lib/libart.so (_ZNK3art6Thread4DumpERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+148)
native: pc 000000000022e8bb /system/lib/libart.so (_ZN3art10ThreadList14DumpForSigQuitERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+142)
native: pc 0000000000215ca5 /system/lib/libart.so (_ZN3art7Runtime14DumpForSigQuitERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+68)
native: pc 000000000021a431 /system/lib/libart.so (_ZN3art13SignalCatcher13HandleSigQuitEv+752)
native: pc 000000000021aadb /system/lib/libart.so (_ZN3art13SignalCatcher3RunEPv+318)
native: pc 00000000000132bb /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: pc 00000000000111e7 /system/lib/libc.so (__start_thread+6)
I think your problem is that you're calling AsyncTask.get() right after you call GetIP_WAN().execute(). I assume that you're calling GetIP_WAN().execute() on the UI thread. If it's in an onClick callback or a BroadcastReceiver it most certainly is. So what I believe is happening is your GetIP_WAN task is correctly executing on a background thread completing but the get() call is attempting to retrieve the data that will get returned from doInBackground(). But that call (get()) will NEVER return before doInBackground and maybe onPostExecute(...) returns, thus causing blocking on the UI thread. If you read the documentation for get inside of the AsyncTask class it says
/**
* Waits if necessary for the computation to complete, and then
* retrieves its result.
*
* #return The computed result.
*
* #throws CancellationException If the computation was cancelled.
* #throws ExecutionException If the computation threw an exception.
* #throws InterruptedException If the current thread was interrupted
* while waiting.
*/
Ironically, you are negating the purpose of you AsnycTask. Even though the work is taking place on the background thread, you are forcing the UI thread to wait for the work to complete before any additional processing on the UI thread can complete. The Android OS handles creating a ANR dialog when it detects the UI/Main thread has been blocking for 5 seconds.
I assume you are calling get so you can get your data from GetIP_WAN, so you can manipulate/display it on the UI thread. What I recommend is you pass some form of reference to the owning activity or fragment into the GetIP_WAN and when the task completes and fires onPostExecute(...) which will be fired on the UI/Main thread, you act upon the activity or fragment to update it's UI with the data you downloaded in doInBackground(...). One pattern I'd recommend is passing a Handler reference that's wrapped inside of a WeakReference into GetIP_WAN and in onPostExecute(...), send an empty message indicating that the work was completed and it's safe to call GetIP_WAN.get().
I have developed a game on AIR using Starling Framework. I am receiving a lot of ANR's from users. The game involves drag - drop mechanism and it is turn based game so there is a timer running on background.
Many ANR's involve similar stack traces to the dump below.
DALVIK THREADS:(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41f44508 self=0x4003e008
| sysTid=5019 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1075220272
| schedstat=( 312982116691 68901855364 485609 ) utm=28822 stm=2476 core=1
#00 pc 0000dc80 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012db4 /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012e10 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 00012ea8 /system/lib/libc.so (pthread_join+108)
#04 pc 001dc775 /data/data/air.com.macarongames.riskokey/lib/libCore.so
at com.adobe.air.customHandler.callTimeoutFunction(Native Method)
at com.adobe.air.customHandler.handleMessage(customHandler.java:22)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
"Thread-2107" prio=5 tid=22 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x42a55750 self=0x6042a7d0
| sysTid=5946 nice=-16 sched=0/0 cgrp=[no-cpu-subsys] handle=1615378384
| schedstat=( 689605688 91613777 1862 ) utm=56 stm=12 core=0
#00 pc 0000dc80 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012174 /system/lib/libc.so
#02 pc 0012ad95 /data/data/air.com.macarongames.riskokey/lib/libCore.so
#03 pc 0010e787 /data/data/air.com.macarongames.riskokey/lib/libCore.so
#04 pc 001aa151 /data/data/air.com.macarongames.riskokey/lib/libCore.so
at dalvik.system.NativeStart.run(Native Method)
"AudioTrack" prio=10 tid=21 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x42a861c0 self=0x6042c910
| sysTid=5945 nice=-16 sched=0/0 cgrp=[no-cpu-subsys] handle=1614836480
| schedstat=( 649810821 215698216 7041 ) utm=24 stm=40 core=1
#00 pc 0000d300 /system/lib/libc.so (nanosleep+12)
#01 pc 0001a89f /system/lib/libc.so (usleep+30)
#02 pc 0003a2ef /system/lib/libmedia.so (android::AudioTrack::processAudioBuffer(android::sp<android::AudioTrack::AudioTrackThread> const&)+402)
#03 pc 0003a3ab /system/lib/libmedia.so (android::AudioTrack::AudioTrackThread::threadLoop()+70)
#04 pc 0001103b /system/lib/libutils.so (android::Thread::_threadLoop(void*)+94)
#05 pc 0004b44b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+66)
#06 pc 00010bb5 /system/lib/libutils.so
#07 pc 00012d70 /system/lib/libc.so (__thread_entry+48)
#08 pc 000124c8 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"AsyncTask #3" prio=5 tid=17 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42b02af0 self=0x60e4da28
| sysTid=5178 nice=10 sched=0/0 cgrp=[no-cpu-subsys] handle=1540363888
| schedstat=( 21789549 60577394 30 ) utm=2 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x42a4d218> (a java.lang.VMThread) held by tid=17 (AsyncTask #3)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"AsyncTask #2" prio=5 tid=23 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42a3cdc8 self=0x5bca8f30
| sysTid=5167 nice=10 sched=0/0 cgrp=[no-cpu-subsys] handle=1539370024
| schedstat=( 109405514 857849122 431 ) utm=8 stm=2 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42a752a8> (a java.lang.VMThread) held by tid=23 (AsyncTask #2)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"Timer-1" prio=5 tid=20 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42af1508 self=0x5bca8708
| sysTid=5096 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1540493584
| schedstat=( 119934078 250213626 359 ) utm=9 stm=2 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x42af1508> (a java.util.Timer$TimerImpl)
at java.lang.Object.wait(Object.java:401)
at java.util.Timer$TimerImpl.run(Timer.java:238)
"Timer-0" prio=5 tid=19 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42aff6e0 self=0x5bd20628
| sysTid=5095 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1540493520
| schedstat=( 147308362 235565175 342 ) utm=14 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x42aff6e0> (a java.util.Timer$TimerImpl)
at java.lang.Object.wait(Object.java:401)
at java.util.Timer$TimerImpl.run(Timer.java:238)
From what I have analyzed many of these traces are in the similar form such as after "AudioTrack" thread, there comes an "AsyncTask #3" which is the first thread waiting.
Thanks for the help.
Try and loop a background sound on volume 0, that is what worked for me. In my case it prevented the audio channel from closing and thus the threads never locked.
I've got an ANR happening, while trying to open 2 separate activities. Very sporadic, only certain users, haven't been able to replicate on any of our test hardware. Both reports have a series of nondescript threads, and two background threads of ours rightly waiting on their notifier locks. The main thread is doing this, in both cases:
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41790710 self=0x41775c90
| sysTid=347 nice=0 sched=0/0 cgrp=apps handle=1074003964
| state=S schedstat=( 0 0 0 ) utm=10817 stm=2453 core=0
#00 pc 0001b6e4 /system/lib/libc.so (__ioctl+8)
#01 pc 0002be67 /system/lib/libc.so (ioctl+14)
#02 pc 0001b929 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+140)
#03 pc 0001c0c7 /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 00001451 /system/lib/libsystem_server.so (system_init+384)
#05 pc 00020b4c /system/lib/libdvm.so (dvmPlatformInvoke+112)
#06 pc 000516ab /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#07 pc 00029fe0 /system/lib/libdvm.so
#08 pc 0002e9a4 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#09 pc 00063aeb /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+350)
#10 pc 0006b80f /system/lib/libdvm.so
#11 pc 00029fe0 /system/lib/libdvm.so
#12 pc 0002e9a4 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#13 pc 0006382d /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
#14 pc 0004d27f /system/lib/libdvm.so
#15 pc 0005477b /system/lib/libandroid_runtime.so
#16 pc 00055ca3 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+378)
#17 pc 0000105b /system/bin/app_process
#18 pc 0000ddf7 /system/lib/libc.so (__libc_init+50)
#19 pc 00000d7c /system/bin/app_process
at com.android.server.SystemServer.init1(Native Method)
at com.android.server.SystemServer.main(SystemServer.java:2012)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at dalvik.system.NativeStart.main(Native Method)
Here is the app dump:
"AsyncTask #4" prio=5 tid=17 WAIT
| group="main" sCount=1 dsCount=0 obj=0x424f4178 self=0x5bad64c8
| sysTid=2943 nice=0 sched=0/0 cgrp=apps handle=1537449072
| schedstat=( 0 0 0 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x424f4298> (a java.lang.VMThread) held by tid=17 (AsyncTask #4)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"Thread-8753" prio=5 tid=1 VMWAIT
| group="main" sCount=1 dsCount=0 obj=0x42647520 self=0x413fa188
| sysTid=2903 nice=0 sched=0/0 cgrp=apps handle=1074526288
| schedstat=( 0 0 0 ) utm=27 stm=8 core=0
#00 pc 0000dce0 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012ef4 /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012f50 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 0004b12f /system/lib/libdvm.so
#04 pc 0004e191 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+416)
#05 pc 00000dcf /system/bin/app_process
#06 pc 000171d3 /system/lib/libc.so (__libc_init+38)
#07 pc 00000b34 /system/bin/app_process
at dalvik.system.NativeStart.run(Native Method)
"AsyncTask #3" prio=5 tid=15 WAIT
| group="main" sCount=1 dsCount=0 obj=0x424dc8a0 self=0x5c0252c0
| sysTid=2941 nice=0 sched=0/0 cgrp=apps handle=1516141776
| schedstat=( 0 0 0 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x424dc9c0> (a java.lang.VMThread) held by tid=15 (AsyncTask #3)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"Thread-8740" prio=5 tid=10 WAIT
| group="main" sCount=1 dsCount=0 obj=0x424860c8 self=0x5a5e1d88
| sysTid=2929 nice=0 sched=0/0 cgrp=apps handle=1543661352
| schedstat=( 0 0 0 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42486340> (a java.lang.VMThread) held by tid=10 (Thread-8740)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at com.my_foo2.Bluetooth.ModelAccessorNew$SingleStuffProcessingThread.run(ModelAccessorNew.java:139)
"pool-1-thread-2" prio=5 tid=13 WAIT
| group="main" sCount=1 dsCount=0 obj=0x421cb830 self=0x5a5e1730
| sysTid=2927 nice=0 sched=0/0 cgrp=apps handle=1094606048
| schedstat=( 0 0 0 ) utm=11 stm=4 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x421cbd98> (a java.lang.VMThread) held by tid=13 (pool-1-thread-2)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"Thread-8735" prio=5 tid=12 WAIT
| group="main" sCount=1 dsCount=0 obj=0x4216e7f0 self=0x413e4f20
| sysTid=2926 nice=0 sched=0/0 cgrp=apps handle=1094604160
| schedstat=( 0 0 0 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x4216e918> (a java.lang.Object)
at java.lang.Object.wait(Object.java:364)
at com.my_foo2.Persistence.Factories.StuffFactory$CalculationThread.run(StuffFactory.java:97)
"pool-1-thread-1" prio=5 tid=11 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42144498 self=0x413e46d0
| sysTid=2924 nice=0 sched=0/0 cgrp=apps handle=1094601544
| schedstat=( 0 0 0 ) utm=18 stm=5 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x421447e8> (a java.lang.VMThread) held by tid=11 (pool-1-thread-1)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"Binder_2" prio=5 tid=9 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x42097bd8 self=0x5183e668
| sysTid=2915 nice=0 sched=0/0 cgrp=apps handle=1538927224
| schedstat=( 0 0 0 ) utm=0 stm=0 core=1
#00 pc 0000cbd0 /system/lib/libc.so (__ioctl+8)
#01 pc 00028035 /system/lib/libc.so (ioctl+16)
#02 pc 00016b6d /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+124)
#03 pc 0001731f /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001af55 /system/lib/libbinder.so
#05 pc 00011087 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+114)
#06 pc 0004c985 /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+44)
#07 pc 00010bed /system/lib/libutils.so
#08 pc 00012eb0 /system/lib/libc.so (__thread_entry+48)
#09 pc 00012608 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"Binder_1" prio=5 tid=8 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x420978a8 self=0x5183e010
| sysTid=2914 nice=0 sched=0/0 cgrp=apps handle=1538927416
| schedstat=( 0 0 0 ) utm=0 stm=0 core=0
#00 pc 0000cbd0 /system/lib/libc.so (__ioctl+8)
#01 pc 00028035 /system/lib/libc.so (ioctl+16)
#02 pc 00016b6d /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+124)
#03 pc 0001731f /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001af55 /system/lib/libbinder.so
#05 pc 00011087 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+114)
#06 pc 0004c985 /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+44)
#07 pc 00010bed /system/lib/libutils.so
#08 pc 00012eb0 /system/lib/libc.so (__thread_entry+48)
#09 pc 00012608 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"FinalizerWatchdogDaemon" daemon prio=5 tid=7 WAIT
| group="system" sCount=1 dsCount=0 obj=0x420940e8 self=0x412487a8
| sysTid=2913 nice=0 sched=0/0 cgrp=apps handle=1538927528
| schedstat=( 0 0 0 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x41414ec8> (a java.lang.Daemons$FinalizerWatchdogDaemon)
at java.lang.Object.wait(Object.java:364)
at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:214)
at java.lang.Thread.run(Thread.java:856)
"FinalizerDaemon" daemon prio=5 tid=6 WAIT
| group="system" sCount=1 dsCount=0 obj=0x42093f90 self=0x41248358
| sysTid=2912 nice=0 sched=0/0 cgrp=apps handle=1538927616
| schedstat=( 0 0 0 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x41403690> (a java.lang.ref.ReferenceQueue)
at java.lang.Object.wait(Object.java:401)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:102)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:73)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:169)
at java.lang.Thread.run(Thread.java:856)
"ReferenceQueueDaemon" daemon prio=5 tid=5 WAIT
| group="system" sCount=1 dsCount=0 obj=0x42093e28 self=0x5bb9f218
| sysTid=2911 nice=0 sched=0/0 cgrp=apps handle=1538927752
| schedstat=( 0 0 0 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x414035b8>
at java.lang.Object.wait(Object.java:364)
at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:129)
at java.lang.Thread.run(Thread.java:856)
"Compiler" daemon prio=5 tid=4 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x42093d38 self=0x400173b8
| sysTid=2910 nice=0 sched=0/0 cgrp=apps handle=1087627008
| schedstat=( 0 0 0 ) utm=9 stm=4 core=1
#00 pc 0000dce0 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012ef4 /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012f50 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 0006e7d7 /system/lib/libdvm.so
#04 pc 0005425b /system/lib/libdvm.so
#05 pc 00012eb0 /system/lib/libc.so (__thread_entry+48)
#06 pc 00012608 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"Signal Catcher" daemon prio=5 tid=3 RUNNABLE
| group="system" sCount=0 dsCount=0 obj=0x42093c40 self=0x40cfa8a8
| sysTid=2909 nice=0 sched=0/0 cgrp=apps handle=1087816224
| schedstat=( 0 0 0 ) utm=1 stm=0 core=0
at dalvik.system.NativeStart.run(Native Method)
"GC" daemon prio=5 tid=2 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x42093b60 self=0x40d6bdd0
| sysTid=2907 nice=0 sched=0/0 cgrp=apps handle=1538927840
| schedstat=( 0 0 0 ) utm=0 stm=0 core=0
#00 pc 0000dce0 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012ef4 /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012f50 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 0006d5db /system/lib/libdvm.so
#04 pc 0005425b /system/lib/libdvm.so
#05 pc 00012eb0 /system/lib/libc.so (__thread_entry+48)
#06 pc 00012608 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
----- end 2903 -----
The other thing that's weird is that this is the only user code I'm seeing. I've tracked where these two threads get started and its during onCreate events of various activities, but the activities themselves aren't running, or at least not visible in the trace. Any ideas would be appreciated.
Our app sometimes locks up with ANR after it has been in device foreground for a long time, say over night. The app starts, but only shows black screen. Back and home buttons don't respond until about 10 seconds after they were pressed.
Running the app in strict mode, doesn't highlight any problems. All network activity, and long running tasks are done on background threads.
Looking at the traces file for our app, I can't identify the "main" thread, so I can't diagnose what is locking up the UI.
This question sounds like the same symptoms, but our app doesn't use the offending library: JmDNS.
----- pid 21220 at 2013-11-26 08:32:09 -----
Cmd line: com.mygreatapp.reptile
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"java.lang.ProcessManager" daemon prio=5 tid=11 WAIT
| group="main" sCount=1 dsCount=0 obj=0x4242b590 self=0x60d506f0
| sysTid=21305 nice=0 sched=0/0 cgrp=apps handle=1626388752
| schedstat=( 1686960 1679167 34 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x42413810> (a java.util.HashMap)
at java.lang.Object.wait(Object.java:364)
at java.lang.ProcessManager.waitForMoreChildren(ProcessManager.java:140)
at java.lang.ProcessManager.watchChildren(ProcessManager.java:105)
at java.lang.ProcessManager.access$000(ProcessManager.java:40)
at java.lang.ProcessManager$1.run(ProcessManager.java:58)
"Thread-30992" prio=5 tid=1 VMWAIT
| group="main" sCount=1 dsCount=0 obj=0x4528c3f8 self=0x60f0e488
| sysTid=21220 nice=0 sched=0/0 cgrp=apps handle=1074544432
| schedstat=( 500594685618 30706953168 460765 ) utm=44353 stm=5705 core=3
#00 pc 0000dca0 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012e44 /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012ea0 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 0004a1af /system/lib/libdvm.so
#04 pc 0003a4a1 /system/lib/libdvm.so
#05 pc 0004d585 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+452)
#06 pc 00000dcf /system/bin/app_process
#07 pc 00017123 /system/lib/libc.so (__libc_init+38)
#08 pc 00000b34 /system/bin/app_process
at dalvik.system.NativeStart.run(Native Method)
"pool-4-thread-1" prio=5 tid=15 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41e20c58 self=0x410e1520
| sysTid=21281 nice=0 sched=0/0 cgrp=apps handle=1089112720
| schedstat=( 102424840 33825634 517 ) utm=6 stm=3 core=3
at java.lang.Object.wait(Native Method)
- waiting on <0x41cc4b30> (a java.lang.VMThread) held by tid=15 (pool-4-thread-1)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"Thread-30976" prio=5 tid=29 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41e407c8 self=0x60b1cdf0
| sysTid=21279 nice=0 sched=0/0 cgrp=apps handle=1466754424
| schedstat=( 22878231471 2961981162 8385 ) utm=2103 stm=184 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x41d189a8> (a java.lang.VMThread) held by tid=29 (Thread-30976)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at crittercism.android.cq.a((null):-1)
at crittercism.android.cv.run((null):-1)
at java.lang.Thread.run(Thread.java:856)
"android.hardware.SystemSensorManager$SensorThread" prio=5 tid=28 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41f7d9c8 self=0x60b5f5d0
| sysTid=21277 nice=-8 sched=0/0 cgrp=apps handle=1466031464
| schedstat=( 629417858 226101457 2481 ) utm=62 stm=0 core=0
#00 pc 0000da70 /system/lib/libc.so (epoll_wait+12)
#01 pc 00014899 /system/lib/libutils.so (android::Looper::pollInner(int)+96)
#02 pc 00014b01 /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+104)
#03 pc 00023f5d /system/lib/libgui.so (android::SensorEventQueue::waitForEvent() const+36)
#04 pc 0007e085 /system/lib/libandroid_runtime.so
#05 pc 0001def0 /system/lib/libdvm.so (dvmPlatformInvoke+112)
#06 pc 0004d14b /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+394)
#07 pc 00000214 /dev/ashmem/dalvik-jit-code-cache (deleted)
at android.hardware.SystemSensorManager.sensors_data_poll(Native Method)
at android.hardware.SystemSensorManager$SensorThread$SensorThreadRunnable.run(SystemSensorManager.java:133)
at java.lang.Thread.run(Thread.java:856)
"Binder_4" prio=5 tid=26 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41cedae0 self=0x58c98ec0
| sysTid=21272 nice=0 sched=0/0 cgrp=apps handle=1488945728
| schedstat=( 701164079 37010713 402 ) utm=66 stm=4 core=0
#00 pc 0000cb90 /system/lib/libc.so (__ioctl+8)
#01 pc 00027fcd /system/lib/libc.so (ioctl+16)
#02 pc 00016bfd /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+124)
#03 pc 000173af /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001b171 /system/lib/libbinder.so
#05 pc 0001104f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+114)
#06 pc 0004ba7b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+66)
#07 pc 00010bb5 /system/lib/libutils.so
#08 pc 00012e00 /system/lib/libc.so (__thread_entry+48)
#09 pc 00012558 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"Binder_3" prio=5 tid=25 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41cfbe58 self=0x58ca4e68
| sysTid=21271 nice=0 sched=0/0 cgrp=apps handle=1485257944
| schedstat=( 29564295 25159912 195 ) utm=1 stm=1 core=0
#00 pc 0000cb90 /system/lib/libc.so (__ioctl+8)
#01 pc 00027fcd /system/lib/libc.so (ioctl+16)
#02 pc 00016bfd /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+124)
#03 pc 000173af /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001b171 /system/lib/libbinder.so
#05 pc 0001104f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+114)
#06 pc 0004ba7b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+66)
#07 pc 00010bb5 /system/lib/libutils.so
#08 pc 00012e00 /system/lib/libc.so (__thread_entry+48)
#09 pc 00012558 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"AsyncTask #5" prio=5 tid=24 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41cf26f0 self=0x57682458
| sysTid=21266 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1464170168
| schedstat=( 135820845754 105683034246 2907951 ) utm=10204 stm=3378 core=2
at java.lang.Object.wait(Native Method)
- waiting on <0x41d1d280> (a java.lang.VMThread) held by tid=24 (AsyncTask #5)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"AsyncTask #4" prio=5 tid=23 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41edc388 self=0x57682008
| sysTid=21265 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1465817672
| schedstat=( 132577127701 105107036747 2873808 ) utm=9956 stm=3301 core=2
at java.lang.Object.wait(Native Method)
- waiting on <0x41c8dbe0> (a java.lang.VMThread) held by tid=23 (AsyncTask #4)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"RefQueueWorker#org.apache.http.impl.conn.tsccm.ConnPoolByRoute#41eff7c8" daemon prio=5 tid=22 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41e2ac40 self=0x576129a8
| sysTid=21262 nice=0 sched=0/0 cgrp=apps handle=1465983376
| schedstat=( 211376 507582 7 ) utm=0 stm=0 core=2
at java.lang.Object.wait(Native Method)
- waiting on <0x41f00830> (a java.lang.ref.ReferenceQueue)
at java.lang.Object.wait(Object.java:401)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:102)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:73)
at org.apache.http.impl.conn.tsccm.RefQueueWorker.run(RefQueueWorker.java:102)
at java.lang.Thread.run(Thread.java:856)
"AsyncTask #3" prio=5 tid=21 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41ea3cd8 self=0x40e8a150
| sysTid=21261 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1088988576
| schedstat=( 147758360521 113209347880 3132414 ) utm=11120 stm=3655 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x41eb3510> (a java.lang.VMThread) held by tid=21 (AsyncTask #3)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
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:1282)
at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:207)
at roboguice.util.SafeAsyncTask$Task.postToUiThreadAndWait(SafeAsyncTask.java:285)
at roboguice.util.SafeAsyncTask$Task.doFinally(SafeAsyncTask.java:248)
at roboguice.util.SafeAsyncTask$Task.call(SafeAsyncTask.java:188)
at roboguice.util.SafeAsyncTask$Task.call(SafeAsyncTask.java:158)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"AsyncTask #2" prio=5 tid=20 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41f6d6c0 self=0x57600af0
| sysTid=21260 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1465924288
| schedstat=( 137061046899 106138943361 2940968 ) utm=10317 stm=3388 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x41f6d990> (a java.lang.VMThread) held by tid=20 (AsyncTask #2)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"pool-3-thread-1" prio=5 tid=19 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41ec84e8 self=0x57600688
| sysTid=21259 nice=0 sched=0/0 cgrp=apps handle=1089548880
| schedstat=( 333892046105 50531397520 395232 ) utm=24001 stm=9387 core=3
at java.lang.Object.wait(Native Method)
- waiting on <0x41cd3cb0> (a java.lang.VMThread) held by tid=19 (pool-3-thread-1)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"AsyncTask #1" prio=5 tid=18 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41e43190 self=0x57600238
| sysTid=21258 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1093436480
| schedstat=( 122133361244 94201913504 2662437 ) utm=9133 stm=3079 core=3
at java.lang.Object.wait(Native Method)
- waiting on <0x41e93b30> (a java.lang.VMThread) held by tid=18 (AsyncTask #1)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"pool-1-thread-1" prio=5 tid=17 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41d8d558 self=0x40018928
| sysTid=21257 nice=0 sched=0/0 cgrp=apps handle=1073843576
| schedstat=( 538748652 44112875 1633 ) utm=30 stm=23 core=2
at java.lang.Object.wait(Native Method)
- waiting on <0x41d958b8> (a java.lang.VMThread) held by tid=17 (pool-1-thread-1)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"com.google.inject.internal.util.$Finalizer" daemon prio=5 tid=14 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41d82388 self=0x40ea8430
| sysTid=21248 nice=0 sched=0/0 cgrp=apps handle=1089147888
| schedstat=( 135958 26125 2 ) utm=0 stm=0 core=2
at java.lang.Object.wait(Native Method)
- waiting on <0x41d824a8> (a java.lang.ref.ReferenceQueue)
at java.lang.Object.wait(Object.java:401)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:102)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:73)
at com.google.inject.internal.util.$Finalizer.run(Finalizer.java:114)
"OPTMZ" prio=5 tid=12 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41ce5b60 self=0x40f1c8c8
| sysTid=21243 nice=0 sched=0/0 cgrp=apps handle=1089677856
| schedstat=( 241167 3985041 22 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x41ce5530> (a android.os.ConditionVariable)
at java.lang.Object.wait(Object.java:364)
at android.os.ConditionVariable.block(ConditionVariable.java:97)
at crittercism.android.f.run((null):-1)
at crittercism.android.cq.a((null):-1)
at crittercism.android.cv.run((null):-1)
at java.lang.Thread.run(Thread.java:856)
"Binder_2" prio=5 tid=10 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41c97448 self=0x40f17500
| sysTid=21232 nice=0 sched=0/0 cgrp=apps handle=1089092880
| schedstat=( 35924382 39652369 228 ) utm=1 stm=2 core=0
#00 pc 0000cb90 /system/lib/libc.so (__ioctl+8)
#01 pc 00027fcd /system/lib/libc.so (ioctl+16)
#02 pc 00016bfd /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+124)
#03 pc 000173af /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001b171 /system/lib/libbinder.so
#05 pc 0001104f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+114)
#06 pc 0004ba7b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+66)
#07 pc 00010bb5 /system/lib/libutils.so
#08 pc 00012e00 /system/lib/libc.so (__thread_entry+48)
#09 pc 00012558 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"Binder_1" prio=5 tid=9 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41c971b8 self=0x40eb0008
| sysTid=21231 nice=0 sched=0/0 cgrp=apps handle=1088983768
| schedstat=( 41858044 25543380 342 ) utm=2 stm=2 core=0
#00 pc 0000cb90 /system/lib/libc.so (__ioctl+8)
#01 pc 00027fcd /system/lib/libc.so (ioctl+16)
#02 pc 00016bfd /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+124)
#03 pc 000173af /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001b171 /system/lib/libbinder.so
#05 pc 0001104f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+114)
#06 pc 0004ba7b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+66)
#07 pc 00010bb5 /system/lib/libutils.so
#08 pc 00012e00 /system/lib/libc.so (__thread_entry+48)
#09 pc 00012558 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"FinalizerWatchdogDaemon" daemon prio=5 tid=8 WAIT
| group="system" sCount=1 dsCount=0 obj=0x41c94180 self=0x40e096f0
| sysTid=21230 nice=0 sched=0/0 cgrp=apps handle=1089149536
| schedstat=( 193951857 409607638 3031 ) utm=8 stm=10 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x41311cf8> (a java.lang.Daemons$FinalizerWatchdogDaemon)
at java.lang.Object.wait(Object.java:364)
at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:214)
at java.lang.Thread.run(Thread.java:856)
"FinalizerDaemon" daemon prio=5 tid=7 WAIT
| group="system" sCount=1 dsCount=0 obj=0x41c93fd0 self=0x40ea38c0
| sysTid=21229 nice=0 sched=0/0 cgrp=apps handle=1074231352
| schedstat=( 2874811820 653275129 6681 ) utm=224 stm=62 core=3
at java.lang.Object.wait(Native Method)
- waiting on <0x413005d0> (a java.lang.ref.ReferenceQueue)
at java.lang.Object.wait(Object.java:401)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:102)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:73)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:169)
at java.lang.Thread.run(Thread.java:856)
"ReferenceQueueDaemon" daemon prio=5 tid=6 WAIT
| group="system" sCount=1 dsCount=0 obj=0x41c93e68 self=0x40ea78a8
| sysTid=21228 nice=0 sched=0/0 cgrp=apps handle=1089109240
| schedstat=( 579457779 268872517 10279 ) utm=44 stm=13 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x413004f8>
at java.lang.Object.wait(Object.java:364)
at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:129)
at java.lang.Thread.run(Thread.java:856)
"Compiler" daemon prio=5 tid=5 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x41c93d78 self=0x40ed3568
| sysTid=21227 nice=0 sched=0/0 cgrp=apps handle=1089689680
| schedstat=( 13840664945 2175691525 62372 ) utm=829 stm=555 core=3
#00 pc 0000dca0 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012e44 /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012ea0 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 0006f955 /system/lib/libdvm.so
#04 pc 00053b8f /system/lib/libdvm.so
#05 pc 00012e00 /system/lib/libc.so (__thread_entry+48)
#06 pc 00012558 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"JDWP" daemon prio=5 tid=4 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x41c93c90 self=0x40dcf718
| sysTid=21226 nice=0 sched=0/0 cgrp=apps handle=1087520184
| schedstat=( 164604246 215945407 747 ) utm=14 stm=1 core=1
#00 pc 0000d758 /system/lib/libc.so (recvmsg+8)
#01 pc 00060383 /system/lib/libdvm.so
#02 pc 00060581 /system/lib/libdvm.so
#03 pc 0006327b /system/lib/libdvm.so
#04 pc 00053b8f /system/lib/libdvm.so
#05 pc 00012e00 /system/lib/libc.so (__thread_entry+48)
#06 pc 00012558 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"Signal Catcher" daemon prio=5 tid=3 RUNNABLE
| group="system" sCount=0 dsCount=0 obj=0x41c93b98 self=0x40f01ca8
| sysTid=21224 nice=0 sched=0/0 cgrp=apps handle=1089261720
| schedstat=( 89234254 24155125 31 ) utm=4 stm=4 core=0
at dalvik.system.NativeStart.run(Native Method)
"GC" daemon prio=5 tid=2 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x41c93ab8 self=0x410cfde0
| sysTid=21222 nice=0 sched=0/0 cgrp=apps handle=1464184336
| schedstat=( 75670018971 4421244466 25704 ) utm=7432 stm=135 core=3
#00 pc 0000dca0 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012e44 /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012ea0 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 0006e65b /system/lib/libdvm.so
#04 pc 00053b8f /system/lib/libdvm.so
#05 pc 00012e00 /system/lib/libc.so (__thread_entry+48)
#06 pc 00012558 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
NATIVE THREADS:
"ekeeper.reptile" sysTid=21267 nice=0 sched=0/0 cgrp=apps
| schedstat=( 18500 0 1 ) utm=0 stm=0 core=0
"ekeeper.reptile" sysTid=21268 nice=0 sched=0/0 cgrp=apps
| schedstat=( 572297498 198605347 10711 ) utm=25 stm=32 core=1
"ekeeper.reptile" sysTid=21269 nice=0 sched=0/0 cgrp=apps
| schedstat=( 1489497433 692708683 24726 ) utm=39 stm=109 core=2
----- end 21220 -----
Some more info in dumpstate file. (Retrieved from device after ANR at /data/log/dumpstate_app_anr.txt.gz) Process ID of app is 16042 with Unix user app_112. Looking at the more detailed logcat (search for MAIN LOG in the file), it looks like OutOfMemoryException. But I would expect the JVM to crash and restart, not lockup in this zombie state. What is keeping the app from crashing successfully?
More info of /proc/PID/ folder in zip file of frozen Android app.
I haven't seen the main thread stack in your ANR trace, where is it?
And, from the "java.lang.ProcessManager" stack, I am guessing you are doing something by forking child processes?
I have met this issue before, it is very strange bug that the the Java process wrapper sometimes got blocked when waiting for the child process to quit.
I am not sure it is a bug, in my case, my child process is already gone, but the main process is still waiting for it in the main thread. Then ANR happened.
Finally, I write some JNI code to wrap C library "system("cmd")" to workaround this issue.