我的Unity Android游戏偶尔会生成一个ANR keyDispatchingTimedOut。我自己没有亲眼见过,但我收到了开发者控制台的报告。
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40f834c0 self=0x11ed808
| sysTid=12086 nice=0 sched=0/0 cgrp=default handle=1074333044
| schedstat=( 101396229 44869695 78 ) utm=8 stm=2 core=1
at com.unity3d.player.NativeLoader.load(Native Method)
at com.unity3d.player.UnityPlayer.a((null):-1)
at com.unity3d.player.UnityPlayer.<init>((null):-1)
at com.unity3d.player.UnityPlayerNativeActivity.onCreate((null):-1)
at android.app.Activity.performCreate(Activity.java:4478)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2124)
at android.app.ActivityThread.access$600(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1248)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4645)
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:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)
"Thread-932" prio=5 tid=10 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x418d84a8 self=0x1535b88
| sysTid=12100 nice=0 sched=0/0 cgrp=default handle=20362336
| schedstat=( 531615 7318385 4 ) utm=0 stm=0 core=1
at dalvik.system.NativeStart.run(Native Method)
"Binder Thread #2" prio=5 tid=9 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x418a4690 self=0x14b9598
| sysTid=12098 nice=0 sched=0/0 cgrp=default handle=21437456
| schedstat=( 7238385 612384 5 ) utm=0 stm=0 core=0
at dalvik.system.NativeStart.run(Native Method)
"Binder Thread #1" prio=5 tid=8 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x418a4538 self=0x1548380
| sysTid=12097 nice=0 sched=0/0 cgrp=default handle=21599232
| schedstat=( 5762539 628077 9 ) utm=0 stm=0 core=0
at dalvik.system.NativeStart.run(Native Method)
"FinalizerWatchdogDaemon" daemon prio=5 tid=7 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x418a0ff0 self=0x14d8600
| sysTid=12096 nice=0 sched=0/0 cgrp=default handle=21571632
| schedstat=( 670846 1434538 6 ) utm=0 stm=0 core=0
at java.lang.VMThread.sleep(Native Method)
at java.lang.Thread.sleep(Thread.java:1031)
at java.lang.Thread.sleep(Thread.java:1013)
at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:213)
at java.lang.Thread.run(Thread.java:856)
"FinalizerDaemon" daemon prio=5 tid=6 WAIT
| group="main" sCount=1 dsCount=0 obj=0x418a0e98 self=0x1528680
| sysTid=12095 nice=0 sched=0/0 cgrp=default handle=21572056
| schedstat=( 518768 6248386 4 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x40f795d0> (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:168)
at java.lang.Thread.run(Thread.java:856)
"ReferenceQueueDaemon" daemon prio=5 tid=5 WAIT
| group="main" sCount=1 dsCount=0 obj=0x418a0d30 self=0x1548890
| sysTid=12094 nice=0 sched=0/0 cgrp=default handle=21700000
| schedstat=( 306001 1676076 4 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x40f794f8>
at java.lang.Object.wait(Object.java:364)
at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:128)
at java.lang.Thread.run(Thread.java:856)
"Compiler" daemon prio=5 tid=4 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x418a0c40 self=0x14785b0
| sysTid=12092 nice=0 sched=0/0 cgrp=default handle=21838632
| schedstat=( 2274538 10397923 5 ) utm=0 stm=0 core=0
at dalvik.system.NativeStart.run(Native Method)
"Signal Catcher" daemon prio=5 tid=3 RUNNABLE
| group="system" sCount=0 dsCount=0 obj=0x418a0b48 self=0x14b7808
| sysTid=12090 nice=0 sched=0/0 cgrp=default handle=21471592
| schedstat=( 4066231 2657077 7 ) utm=0 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=0x418a0a68 self=0x152b8b8
| sysTid=12087 nice=0 sched=0/0 cgrp=default handle=21598632
| schedstat=( 1544846 2687077 3 ) utm=0 stm=0 core=1
at dalvik.system.NativeStart.run(Native Method)
据我所知,ANR是由在主UI线程上运行长操作引起的。
我的问题是,由于报告主要部分中提到的所有方法都是内部Unity方法或内部Android方法,我不知道从哪里开始寻找问题。
任何指针都会有所帮助。