ANR keyDispatchingTimedOut

ilkrkls

Member
Licensed User
Longtime User
Hello,

I have created my first app, named "fingerbilliards" on the market.
It is a 3 ball billiards game, and I am trying to improve it.

The problem is; ANR keyDispatchingTimedOut errors. There are very few reports from the market about it, but I do encounter this problem in my own device also.

You hit the balls with your finger, the balls hit each other and the cushions, and some time later they stop. It runs smooth and there is no problem.

After some minutes, you hit the ball, the ball starts to move, and suddenly the phone hangs.
Later a "force close" dialogue appears.

All about the game is processed in the same activity. The speed of the finger to shoot the ball is calculated within touch down-move-up events. No problem about this part I guess.

After the ball is shot, the timer tick event begins. The moves of the balls are calculated and drawn in the timer event. When the speed of all the balls are zero, the timer is disabled.

App Not Responding happens during the timer_tick, when the first ball is on the move.
The interval of the timer is 4 ms since the game loses smoothness at higher intervals.

So, I guess the system cannot handle other calls during timer event.
I tried to put doevents line, but that did not help.

Can you help me with suggestions?
Maybe I can use threading library, but I do not know how to timer sub within threading sub. Or if I make the calculations in a code module, will that prevent the main activity from being freezed?

Thank you

ilker
 

ilkrkls

Member
Licensed User
Longtime User
v1.09


19 Mar 2012 19:46:14


OTHER

--------------------------------------------------------------------------------

DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 SUSPENDED
| group="main" sCount=1 dsCount=0 obj=0x2aad2260 self=0xd168
| sysTid=16044 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1876218976
at com.ilkerkeles.fingerbilliards.main02._timer1_tick(main02.java:~1529)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:113)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:103)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
at dalvik.system.NativeStart.main(Native Method)

"Binder Thread #3" prio=5 tid=8 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x2b0a5b68 self=0x374630
| sysTid=16051 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=3607560
at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #2" prio=5 tid=7 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x2afc55c8 self=0x20abe8
| sysTid=16050 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=2141096
at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #1" prio=5 tid=6 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x2afc5500 self=0x11f098
| sysTid=16049 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=2624520
at dalvik.system.NativeStart.run(Native Method)

"Compiler" daemon prio=5 tid=5 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x2afc15d0 self=0x2809e8
| sysTid=16048 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=603696
at dalvik.system.NativeStart.run(Native Method)

"Signal Catcher" daemon prio=5 tid=4 RUNNABLE
| group="system" sCount=0 dsCount=0 obj=0x2afc1510 self=0x176650
| sysTid=16047 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1533456
at dalvik.system.NativeStart.run(Native Method)

"GC" daemon prio=5 tid=3 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x2afc1468 self=0x20c1e0
| sysTid=16046 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=2146720
at dalvik.system.NativeStart.run(Native Method)

"HeapWorker" daemon prio=5 tid=2 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x2afc13b0 self=0x176310
| sysTid=16045 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1178312
at dalvik.system.NativeStart.run(Native Method)
 

ilkrkls

Member
Licensed User
Longtime User
line 1527-1531 of main02.java is;


while (_vvv7-_vv7<_vv0) {
//BA.debugLineNum = 738;BA.debugLine="merkezbeyazx=merkezbeyazx+(CosD(acibeyaz)*hizbeyaz*xspeed/8)";
_vvv7 = (float)(_vvv7+(anywheresoftware.b4a.keywords.Common.CosD(_vvvvvvv3)*_vvvvvvv2*_v5/(double)8));
}
;

Timer1_Tick code is too long to be posted I guess...
But it handles all the calculations + draws the panels.
 

ilkrkls

Member
Licensed User
Longtime User
some other reports;



v1.01


12 Mar 2012 11:08:35


OTHER

--------------------------------------------------------------------------------

DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 SUSPENDED
| group="main" sCount=1 dsCount=0 obj=0x40027550 self=0xd010
| sysTid=8394 nice=0 sched=0/0 cgrp=default handle=-1345002112
| schedstat=( 134964721715 32148864698 69390 )
at com.ilkerkeles.fingerbilliards.main02._timer1_tick(main02.java:~1513)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)



v1.05


17 Mar 2012 11:19:54


OTHER

--------------------------------------------------------------------------------

DALVIK THREADS:
"main" prio=5 tid=1 RUNNABLE
| group="main" sCount=1 dsCount=0 s=Y obj=0x4001d8b0 self=0xcd30
| sysTid=1115 nice=0 sched=0/0 cgrp=default handle=-1345017808
| schedstat=( 21322862776 1857601850 6081 )
at anywheresoftware.b4a.keywords.Common.CosD(Common.java:~243)
at com.ilkerkeles.fingerbilliards.main02._timer1_tick(main02.java:1479)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)




v1.06


17 Mar 2012 13:30:47


OTHER

--------------------------------------------------------------------------------

DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x4002a278 self=0xcf50
| sysTid=6128 nice=0 sched=0/0 cgrp=default handle=-1345006528
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)




v1.09


19 Mar 2012 08:44:48


OTHER

--------------------------------------------------------------------------------

DALVIK THREADS:
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 s=Y obj=0x40028970 self=0xcd38
| sysTid=5340 nice=0 sched=0/0 cgrp=unknown handle=-1345026008
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:457)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:493)
at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:74)
 

ilkrkls

Member
Licensed User
Longtime User
there are mostly if-then blocks.
do-while blocks are only when the balls hit each other, and should not take too long.
moreover, the code runs smooth. I cannot predict when it freezes.

may I send you the project via email?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm sorry but I don't have the time to privately go over your project.

The problem is most likely in this code:
B4X:
while (_vvv7-_vv7<_vv0) {
//BA.debugLineNum = 738;BA.debugLine="merkezbeyazx=merkezbeyazx+(CosD( acibeyaz)*hizbeyaz*xspeed/8)";
_vvv7 = (float)(_vvv7+(anywheresoftware.b4a.keywords.Commo n.CosD(_vvvvvvv3)*_vvvvvvv2*_v5/(double)8));
}
 

ilkrkls

Member
Licensed User
Longtime User
ok, I added a count variable and exit inside the do-while loops.
I hope there will be no more freezes.

So, basically
Can we say that the operations inside the timer_tick loop do not freeze the phone (if there are no while loops and errors, only mathematical calculations)?
 
Top