0

I am getting an ANR on Android 2.2

I noticed it on one device and thought it was just slow, but proceeded to try to optimize. Now I tried it on an emulator so I could get the error log (because StrictPolicy is not available on Android 2.2) and I do have that. But I also bumped the emulator up to Android 2.3 and the ANR does not occur.

Additional facts, the ANR occurs after everything is done loading. The application has not stopped responding, user input and interaction will be completely fine, nothing lagging, and then the random ANR will pop up. If the user clicks wait, the ANR will not come up again, and the normal functioning app will continue to function normally.

I already did a lot of optimizations trying to fix this:

  • optimizing GPS and making sure it was off of the UI thread
  • moving SharedPreferences writes into an asynchronous loader
  • moving File I/O into threads

so now, where it hangs, there is seemingly nothing happening in the UI thread, and other threads seem to have completed

Here is the traces.txt , which doesn't really tell me anything useful, but maybe you

DALVIK THREADS:
"main" prio=5 tid=1 TIMED_WAIT
  | group="main" sCount=1 dsCount=0 s=N obj=0x4001d8e0 self=0xccb0
  | sysTid=323 nice=0 sched=0/0 cgrp=default handle=-1345026008
  | schedstat=( 11941207221 4675177432 906 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x44f9b158> (a android.os.MessageQueue)
  at java.lang.Object.wait(Object.java:326)
  at android.os.MessageQueue.next(MessageQueue.java:142)
  at android.os.Looper.loop(Looper.java:110)
  at android.app.ActivityThread.main(ActivityThread.java:4627)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  at dalvik.system.NativeStart.main(Native Method)

"AsyncTask #2" prio=5 tid=10 WAIT
  | group="main" sCount=1 dsCount=0 s=N obj=0x44fdab88 self=0x30a2b0
  | sysTid=342 nice=10 sched=0/0 cgrp=bg_non_interactive handle=982712
  | schedstat=( 275686031 948836091 47 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x44fdace0> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1535)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:317)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  at java.lang.Thread.run(Thread.java:1096)

"AsyncTask #1" prio=5 tid=9 WAIT
  | group="main" sCount=1 dsCount=0 s=N obj=0x45010410 self=0x11df58
  | sysTid=337 nice=10 sched=0/0 cgrp=bg_non_interactive handle=3054552
  | schedstat=( 309934034 6402364637 55 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x45002e80> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1535)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:317)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  at java.lang.Thread.run(Thread.java:1096)

"FlurryAgent" prio=5 tid=8 WAIT
  | group="main" sCount=1 dsCount=0 s=N obj=0x450138f8 self=0x118f70
  | sysTid=333 nice=0 sched=0/0 cgrp=default handle=1216736
  | schedstat=( 3721243399 3011581274 329 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x45013b28> (a android.os.MessageQueue)
  at java.lang.Object.wait(Object.java:288)
  at android.os.MessageQueue.next(MessageQueue.java:146)
  at android.os.Looper.loop(Looper.java:110)
  at android.os.HandlerThread.run(HandlerThread.java:60)

"FlurryAdThread" prio=5 tid=7 WAIT
  | group="main" sCount=1 dsCount=0 s=N obj=0x45012938 self=0x113e60
  | sysTid=332 nice=0 sched=0/0 cgrp=default handle=1131080
  | schedstat=( 6274000 45081005 9 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x45012b78> (a android.os.MessageQueue)
  at java.lang.Object.wait(Object.java:288)
  at android.os.MessageQueue.next(MessageQueue.java:146)
  at android.os.Looper.loop(Looper.java:110)
  at android.os.HandlerThread.run(HandlerThread.java:60)

"Binder Thread #2" prio=5 tid=6 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x44f95b80 self=0x140c30
  | sysTid=330 nice=0 sched=0/0 cgrp=default handle=1311936
  | schedstat=( 81519008 45820004 33 )
  at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #1" prio=5 tid=5 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x44f955f8 self=0x13bd10
  | sysTid=329 nice=0 sched=0/0 cgrp=default handle=1215096
  | schedstat=( 94873013 51004004 33 )
  at dalvik.system.NativeStart.run(Native Method)

"JDWP" daemon prio=5 tid=4 VMWAIT
  | group="system" sCount=1 dsCount=0 s=N obj=0x44f942a0 self=0x1258b8
  | sysTid=328 nice=0 sched=0/0 cgrp=default handle=1157328
  | schedstat=( 57762005 114193008 290 )
  at dalvik.system.NativeStart.run(Native Method)

"Signal Catcher" daemon prio=5 tid=3 RUNNABLE
  | group="system" sCount=0 dsCount=0 s=N obj=0x44f941e8 self=0x131a68
  | sysTid=326 nice=0 sched=0/0 cgrp=default handle=1239472
  | schedstat=( 16133002 29561002 8 )
  at dalvik.system.NativeStart.run(Native Method)

"HeapWorker" daemon prio=5 tid=2 VMWAIT
  | group="system" sCount=1 dsCount=0 s=N obj=0x437a86c0 self=0x1351c8
  | sysTid=324 nice=0 sched=0/0 cgrp=default handle=1134552
  | schedstat=( 146422015 248849023 62 )
  at dalvik.system.NativeStart.run(Native Method)
CQM
  • 42,592
  • 75
  • 224
  • 366
  • If you can test without Flurry, I'd try that. It stands out as an external library that's running its own threads, so it could be problematic. At least you could isolate that. – dokkaebi Nov 21 '12 at 21:37
  • @dokkaebi right I did consider that, I didn't find anything about it on a quick google search, but I will keep it in mind (and continue using the Flurry library) – CQM Nov 21 '12 at 21:45

0 Answers0