0

我在 Android 2.2 上收到 ANR

我在一台设备上注意到它并认为它很慢,但继续尝试优化。现在我在模拟器上尝试了它,所以我可以获得错误日志(因为 StrictPolicy 在 Android 2.2 上不可用),我确实有。但是我也将模拟器升级到了 Android 2.3,并且没有发生 ANR。

其他事实,ANR 发生在一切都完成加载之后。应用程序没有停止响应,用户输入和交互会完全正常,没有任何延迟,然后会弹出随机 ANR。如果用户点击等待,ANR 不会再次出现,正常运行的应用程序将继续正常运行。

我已经做了很多优化来解决这个问题:

  • 优化 GPS 并确保它脱离 UI 线程
  • 将 SharedPreferences 写入移动到异步加载器
  • 将文件 I/O 移动到线程中

所以现在,它挂在哪里,UI线程中似乎没有发生任何事情,其他线程似乎已经完成

这是 traces.txt ,它并没有真正告诉我任何有用的信息,但也许你

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)
4

0 回答 0