K kcorey Member Licensed User Longtime User Sep 13, 2012 #1 Hi All, I found something that drove me mad for a day or so... In my code, I am using the Animation library 1.02. I couldn't see an effect I was hoping to see on the Samsung Galaxy Tab 2 10 (Android 4.0.4) I thought this might be caused by a runaway process...so I put a 'DoEvents' in my code, assuming that it if there were no messages it would effectively be ignored. I happened to try the code on my Nexus 7 (Android 4.1.1) where it worked fine...but the program would seemingly halt on the Samsung. Turns out it was an interesting exception (pasted at the bottom). In looking at the generated java file com.flippinbits.milestones.main, line 3490, I see "DoEvents". Is this a bug, or did I use DoEvents wrong? -Ken ---------------------------------- E/SurfaceTextureClient(15563): Surface::lock failed, already locked E/ViewRootImpl(15563): IllegalArgumentException locking surface E/ViewRootImpl(15563): java.lang.IllegalArgumentException E/ViewRootImpl(15563): at android.view.Surface.lockCanvasNative(Native Method) E/ViewRootImpl(15563): at android.view.Surface.lockCanvas(Surface.java:76) E/ViewRootImpl(15563): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2004) E/ViewRootImpl(15563): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1693) E/ViewRootImpl(15563): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2505) E/ViewRootImpl(15563): at android.os.Handler.dispatchMessage(Handler.java:99) E/ViewRootImpl(15563): at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:211) E/ViewRootImpl(15563): at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:180) E/ViewRootImpl(15563): at anywheresoftware.b4a.keywords.Common.DoEvents(Common.java:367) E/ViewRootImpl(15563): at com.flippinbits.milestones.main._setcard(main.java:3490) E/ViewRootImpl(15563): at com.flippinbits.milestones.main._setgo_animationend(main.java:3528) E/ViewRootImpl(15563): at java.lang.reflect.Method.invokeNative(Native Method) E/ViewRootImpl(15563): at java.lang.reflect.Method.invoke(Method.java:511) E/ViewRootImpl(15563): at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170) E/ViewRootImpl(15563): at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158) E/ViewRootImpl(15563): at anywheresoftware.b4a.BA.raiseEvent(BA.java:154) E/ViewRootImpl(15563): at anywheresoftware.b4a.objects.AnimationWrapper$1.onAnimationEnd(AnimationWrapper.java:104) E/ViewRootImpl(15563): at android.view.animation.Animation.getTransformation(Animation.java:843) E/ViewRootImpl(15563): at android.view.animation.Animation.getTransformation(Animation.java:887) E/ViewRootImpl(15563): at android.view.ViewGroup.drawChild(ViewGroup.java:2668) E/ViewRootImpl(15563): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2500) E/ViewRootImpl(15563): at android.view.View.draw(View.java:11033) E/ViewRootImpl(15563): at android.view.ViewGroup.drawChild(ViewGroup.java:2898) E/ViewRootImpl(15563): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2500) E/ViewRootImpl(15563): at android.view.ViewGroup.drawChild(ViewGroup.java:2896) E/ViewRootImpl(15563): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2500) E/ViewRootImpl(15563): at android.view.ViewGroup.drawChild(ViewGroup.java:2896) E/ViewRootImpl(15563): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2500) E/ViewRootImpl(15563): at android.view.View.draw(View.java:11033) E/ViewRootImpl(15563): at android.widget.FrameLayout.draw(FrameLayout.java:450) E/ViewRootImpl(15563): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2274) E/ViewRootImpl(15563): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2087) E/ViewRootImpl(15563): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1693) E/ViewRootImpl(15563): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2505) E/ViewRootImpl(15563): at android.os.Handler.dispatchMessage(Handler.java:99) E/ViewRootImpl(15563): at android.os.Looper.loop(Looper.java:137) E/ViewRootImpl(15563): at android.app.ActivityThread.main(ActivityThread.java:4514) E/ViewRootImpl(15563): at java.lang.reflect.Method.invokeNative(Native Method) E/ViewRootImpl(15563): at java.lang.reflect.Method.invoke(Method.java:511) E/ViewRootImpl(15563): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) E/ViewRootImpl(15563): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) E/ViewRootImpl(15563): at dalvik.system.NativeStart.main(Native Method)
Hi All, I found something that drove me mad for a day or so... In my code, I am using the Animation library 1.02. I couldn't see an effect I was hoping to see on the Samsung Galaxy Tab 2 10 (Android 4.0.4) I thought this might be caused by a runaway process...so I put a 'DoEvents' in my code, assuming that it if there were no messages it would effectively be ignored. I happened to try the code on my Nexus 7 (Android 4.1.1) where it worked fine...but the program would seemingly halt on the Samsung. Turns out it was an interesting exception (pasted at the bottom). In looking at the generated java file com.flippinbits.milestones.main, line 3490, I see "DoEvents". Is this a bug, or did I use DoEvents wrong? -Ken ---------------------------------- E/SurfaceTextureClient(15563): Surface::lock failed, already locked E/ViewRootImpl(15563): IllegalArgumentException locking surface E/ViewRootImpl(15563): java.lang.IllegalArgumentException E/ViewRootImpl(15563): at android.view.Surface.lockCanvasNative(Native Method) E/ViewRootImpl(15563): at android.view.Surface.lockCanvas(Surface.java:76) E/ViewRootImpl(15563): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2004) E/ViewRootImpl(15563): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1693) E/ViewRootImpl(15563): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2505) E/ViewRootImpl(15563): at android.os.Handler.dispatchMessage(Handler.java:99) E/ViewRootImpl(15563): at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:211) E/ViewRootImpl(15563): at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:180) E/ViewRootImpl(15563): at anywheresoftware.b4a.keywords.Common.DoEvents(Common.java:367) E/ViewRootImpl(15563): at com.flippinbits.milestones.main._setcard(main.java:3490) E/ViewRootImpl(15563): at com.flippinbits.milestones.main._setgo_animationend(main.java:3528) E/ViewRootImpl(15563): at java.lang.reflect.Method.invokeNative(Native Method) E/ViewRootImpl(15563): at java.lang.reflect.Method.invoke(Method.java:511) E/ViewRootImpl(15563): at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170) E/ViewRootImpl(15563): at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158) E/ViewRootImpl(15563): at anywheresoftware.b4a.BA.raiseEvent(BA.java:154) E/ViewRootImpl(15563): at anywheresoftware.b4a.objects.AnimationWrapper$1.onAnimationEnd(AnimationWrapper.java:104) E/ViewRootImpl(15563): at android.view.animation.Animation.getTransformation(Animation.java:843) E/ViewRootImpl(15563): at android.view.animation.Animation.getTransformation(Animation.java:887) E/ViewRootImpl(15563): at android.view.ViewGroup.drawChild(ViewGroup.java:2668) E/ViewRootImpl(15563): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2500) E/ViewRootImpl(15563): at android.view.View.draw(View.java:11033) E/ViewRootImpl(15563): at android.view.ViewGroup.drawChild(ViewGroup.java:2898) E/ViewRootImpl(15563): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2500) E/ViewRootImpl(15563): at android.view.ViewGroup.drawChild(ViewGroup.java:2896) E/ViewRootImpl(15563): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2500) E/ViewRootImpl(15563): at android.view.ViewGroup.drawChild(ViewGroup.java:2896) E/ViewRootImpl(15563): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2500) E/ViewRootImpl(15563): at android.view.View.draw(View.java:11033) E/ViewRootImpl(15563): at android.widget.FrameLayout.draw(FrameLayout.java:450) E/ViewRootImpl(15563): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2274) E/ViewRootImpl(15563): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2087) E/ViewRootImpl(15563): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1693) E/ViewRootImpl(15563): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2505) E/ViewRootImpl(15563): at android.os.Handler.dispatchMessage(Handler.java:99) E/ViewRootImpl(15563): at android.os.Looper.loop(Looper.java:137) E/ViewRootImpl(15563): at android.app.ActivityThread.main(ActivityThread.java:4514) E/ViewRootImpl(15563): at java.lang.reflect.Method.invokeNative(Native Method) E/ViewRootImpl(15563): at java.lang.reflect.Method.invoke(Method.java:511) E/ViewRootImpl(15563): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) E/ViewRootImpl(15563): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) E/ViewRootImpl(15563): at dalvik.system.NativeStart.main(Native Method)
Erel B4X founder Staff member Licensed User Longtime User Sep 14, 2012 #2 Can you post the code? Upvote 0
K kcorey Member Licensed User Longtime User Sep 14, 2012 #3 The code in question is this simple: Code: Copy Sub setcard(idx As Int, cardid As String) Log("setCard "&idx&","&cardid) If cardid="" Then CardViews(idx).Bitmap = cardpics(19) Else CardViews(idx).Bitmap = cardpics(cardnums.Get(cardid)) End If CardViews(idx).Invalidate DoEvents tableau(idx) = cardid End Sub The variables are declared like this: Code: Copy Sub Process_Globals Dim tableau(21) As String End Sub Sub Globals Dim C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20 As ImageView Dim CardViews() As ImageView Dim cardpics(20) As Bitmap End Sub By the time this code is called, the app is well and truly established and running, and all bitmaps are loaded. Any ideas? -Ken Upvote 0
The code in question is this simple: Code: Copy Sub setcard(idx As Int, cardid As String) Log("setCard "&idx&","&cardid) If cardid="" Then CardViews(idx).Bitmap = cardpics(19) Else CardViews(idx).Bitmap = cardpics(cardnums.Get(cardid)) End If CardViews(idx).Invalidate DoEvents tableau(idx) = cardid End Sub The variables are declared like this: Code: Copy Sub Process_Globals Dim tableau(21) As String End Sub Sub Globals Dim C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20 As ImageView Dim CardViews() As ImageView Dim cardpics(20) As Bitmap End Sub By the time this code is called, the app is well and truly established and running, and all bitmaps are loaded. Any ideas? -Ken
Erel B4X founder Staff member Licensed User Longtime User Sep 14, 2012 #4 From the stack trace I see that you are calling DoEvents inside AnimationEnd event. Seems like it breaks the animation mechanism. You can use CallSubDelayed to call a sub right after the event finishes. Upvote 0
From the stack trace I see that you are calling DoEvents inside AnimationEnd event. Seems like it breaks the animation mechanism. You can use CallSubDelayed to call a sub right after the event finishes.
K kcorey Member Licensed User Longtime User Sep 19, 2012 #5 Oh! I get the idea. I can't find documentation on callsubdelayed...but this seems to work: CallSubDelayed(Me,"subname") Is that the idea? -Ken Upvote 0
Oh! I get the idea. I can't find documentation on callsubdelayed...but this seems to work: CallSubDelayed(Me,"subname") Is that the idea? -Ken
Erel B4X founder Staff member Licensed User Longtime User Sep 19, 2012 #6 See the tutorial about CallSubDelayed: Basic4android Search: CallSubDelayed Upvote 0