In my android logcat log, I see:
01-02 02:01:46.523 E/ActivityManager( 459): ANR in com.android.phone (com.android.phone/.InCallScreen)
And then when I go to /data/anr/traces.txt, I see
Cmd line: com.android.phone
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x410f7508 self=0x40eeeb68
| sysTid=649 nice=0 sched=0/0 cgrp=apps handle=1075429168
| schedstat=( 0 0 0 ) utm=1361 stm=314 core=1
#00 pc 0000dac0 /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 00063aeb /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22)
#04 pc 0001df30 /system/lib/libdvm.so (dvmPlatformInvoke+112)
#05 pc 0004d1fb /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+394)
#06 pc 00038f4d /system/lib/libdvm.so (dvmCheckCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+8)
#07 pc 00000214 /dev/ashmem/dalvik-jit-code-cache (deleted)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:125)
at android.os.Looper.loop(Looper.java:124)
at android.app.ActivityThread.main(ActivityThread.java:4921)
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:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
My question is why android thinks the app is in ANR when the stack trace shows the main thread in Looper waiting for message? That seems normal to me. I understand android shows ANR when the main thread is downloading something/doing a long operation. But it seems normal that it is waiting for a message. Please corect me if I am wrong.
I have found this interesting bug report:
http://code.google.com/p/android/issues/detail?id=41755
Short summary is that there seems to be a bug in the NDK wrapper code which means that events coming in from multiple sources can cause an ANR. This precisely matches my use case --- I have an NDK app with work happening in background threads and a gamepad, and the ANR I'm getting precisely matches the one you described and the one in the bug report.
Is this similar to your setup?
Update: more info: http://ps3computing.blogspot.co.uk/2012/12/anr-application-not-responding.html
After having applied the fix described on his blog, I don't seem to be able to make the ANR manifest again. That's not to say it's gone, though...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With