Page 1 of 1

slow animation optimizations? [SOLVED]

Posted: Sun Jul 07, 2013 11:29 am
by SteveTX
I've written a menu system where the menu buttons move off screen and fade out after a button is selected. The animation on desktop is jerky and slower than the messages can properly execute, and on mobile it doesn't appear to work at all.

I've got the buttons set to dynamic, and the icon of the buttons are resized 24-bit png images set to alwaysBuffer = true. Thoughts on how to smooth/speed this sucker up? Are such animations simply not feasible on mobile?

Code: Select all

command animateMoveButton theButton startLoc endLoc fadeMode
   debugIt (" animateMoveButton " & theButton & ", " & startLoc & ", " & endLoc & ", " & fadeMode)
   put 1000 into effectTime
   put 50 into effectSteps
   set the loc of button theButton to startLoc
   put the first item of startLoc into startLocX
   put the second item of startLoc into startLocY
   put the first item of endLoc into endLocX
   put the second item of endLoc into endLocY
   set the ink of button theButton to "blendClear"
   if fadeMode = "in" then set the blendLevel of button theButton to 100
   if fadeMode = "out" then set the blendLevel of button theButton to 0
   repeat with i = 1 to effectSteps
      put 0 into theFade
      if fadeMode = "none" then put 0 into theFade
      if fadeMode = "in" then put  (100 - (the round of (i * (100 / effectSteps)))) into theFade
      if fadeMode = "out" then put (the round of (i * 100 / effectSteps)) into theFade
      put round(startLocX + (((endLocX - startLocX) / effectSteps) * i),0) & "," & round(startLocY + (((endLocY - startLocY) / effectSteps) * i),0) into theLoc
      send (moveIt && "theButton, theFade, theLoc") to me in ((effectTime/effectSteps) * i) milliseconds
   end repeat   
end animateMoveButton

command moveIt theButton theFade theLoc
   debugIt (" effect moveIt acting upon button " & theButton & " with fade " & theFade & " and loc " & theLoc)
   set the visible of button theButton to true
   set the blendLevel of button theButton to theFade
   set the loc of button theButton to theLoc
end moveIt

Re: slow animation optimizations?

Posted: Sun Jul 07, 2013 1:21 pm
by Klaus
Hi Steve,

not sure, I need to SEE this :-)
Could you prepare a little stack to test?

But some general hints:
1. parameters need to be separated by COMMA:
...
command animateMoveButton theButton, startLoc, endLoc, fadeMode
...
command moveIt theButton, theFade, theLoc
...

Messages to be sent should go in Quotes:
...
send "moveIt theButton, theFade, theLoc" to me in ((effectTime/effectSteps) * i) milliseconds
...
No that this may cause the jerkyness, but the engine is less and less forgiving with each version,
so getting used to the correct syntax will not hurt ;-)


Best

Kluas

Re: slow animation optimizations?

Posted: Sun Jul 07, 2013 6:01 pm
by SteveTX
Klaus,

I appreciate the dedication to strict syntax, that is very German of you. The good news is after correcting some minor bugs i've found what may be a memory leak. When things break real bad you know you're close to the solution. ;)

Steve

Re: slow animation optimizations?

Posted: Sun Jul 07, 2013 6:31 pm
by Klaus
Hi Steve,

hurra, hurra, hurra! :-D

But my "dedication to strict syntax" is based on experience and not on being a german!
You wouldn't belive how un-"krautly" I am :-)


Best

Klaus

Re: slow animation optimizations?

Posted: Sun Jul 07, 2013 9:08 pm
by SteveTX
A little bit more knowledge for those who go down this path: blends operations appear to be rendered significantly faster than moving objects, regardless if the object is set as static or dynamic. It also looks like compositorType needs opengl support for android, or more generically, for ARM core optimizations, as you're stuck with the software render.

Re: slow animation optimizations?

Posted: Sun Jul 07, 2013 11:28 pm
by dave_probertGA6e24
Hi

Sorry if this is of no interest to you, but I couldn't help noticing that your use of the send in milliseconds way of doing the animation was a little... Jerky! So i made a slight change to see if I could speed it up a bit.

Attached is a simple modified version (well, actually only the moveIt function is still there!!), but this does allow some level of control and a slightly less intensive message sending process.

Obviously it can be improved much more, but it might help you a bit.

Cheers,
Dave

PS. Proper Syntax used where possible ;)

Re: slow animation optimizations?

Posted: Mon Jul 08, 2013 3:14 am
by SteveTX
A little bit up in my hierarchy of code, I've got atomized queues as well. It looks great on win desktop like mine, which has plenty of processing power and probably acceleration. If you compile this code for mobile, you'll see the animation is still jerky and now painfully slow.

Does anyone know what the default value of compositorCacheLimit is set for, and if so, how runrev calculates it?

Re: slow animation optimizations? [SOLVED]

Posted: Mon Jul 08, 2013 3:51 am
by SteveTX
It turns out that livecode's movement of buttons is significantly more overhead intensive (>10x) than its moving of images, but this doesn't get noticed until you're in a limited processing/acceleration environment like mobile. Sticking an image inside a transparent button as its icon is even worse, even if both are set for dynamic. If you have to animate a button, use an image object instead of a button object!

Re: slow animation optimizations? [SOLVED]

Posted: Wed Aug 07, 2013 11:34 pm
by William Jamieson
@ Steve: Wow. Thanks. I have been dealing with slow rendering lately, I think this will really help.

@Dave: The way you used preloading the mulitvariable array to move the objects inspired a whole lot of creativity in how I can move multiple objects in non linear or organic paths. Kudos point to you!