0

我使用Starling Framework開發了AIR上的遊戲。我收到很多來自用戶的ANR。遊戲涉及拖放機制,它是基於回合的遊戲,所以有一個計時器在後臺運行。ANR Android keyDispatchingTimedOut(AIR 4.0)

許多ANR的堆棧跟蹤類似於下面的轉儲。

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) 

從我分析了很多這些痕跡都是在類似的形式,如後「AudioTrack」線程,總會有一個「的AsyncTask#3」,這是第一個線程等待。

感謝您的幫助。

+0

你解決了你的問題嗎? – 2014-10-04 09:54:48

+0

不幸的是沒有。我發佈在Adobe bugbase上,但他們迴應說這個錯誤不是與AIR相關的。 – berkayk 2014-10-05 10:21:48

回答

0

嘗試並循環播放第0捲上的背景音,這對我來說很合適。在我的情況下,它阻止了音頻通道關閉,從而線程從未鎖定。

+0

感謝您的回答,我會嘗試一下併發布我的結果。 – berkayk 2014-10-11 08:50:48