slow animation optimizations? [SOLVED]

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

slow animation optimizations? [SOLVED]

Post by SteveTX » Sun Jul 07, 2013 11:29 am

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
Last edited by SteveTX on Mon Jul 08, 2013 3:51 am, edited 1 time in total.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: slow animation optimizations?

Post by Klaus » Sun Jul 07, 2013 1:21 pm

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

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: slow animation optimizations?

Post by SteveTX » Sun Jul 07, 2013 6:01 pm

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: slow animation optimizations?

Post by Klaus » Sun Jul 07, 2013 6:31 pm

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

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: slow animation optimizations?

Post by SteveTX » Sun Jul 07, 2013 9:08 pm

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.

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: slow animation optimizations?

Post by dave_probertGA6e24 » Sun Jul 07, 2013 11:28 pm

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 ;)
Attachments
animatedMenu.livecode.zip
Queued Animation test
(1.77 KiB) Downloaded 354 times
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: slow animation optimizations?

Post by SteveTX » Mon Jul 08, 2013 3:14 am

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?

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: slow animation optimizations? [SOLVED]

Post by SteveTX » Mon Jul 08, 2013 3:51 am

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!

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: slow animation optimizations? [SOLVED]

Post by William Jamieson » Wed Aug 07, 2013 11:34 pm

@ 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!

Post Reply