Over the years, I’ve looked at a number of OpenLaszlo applications that have needed performance tuning. Some performance-tuning involves significant re-writing of applications. However, I’ve also seen a number of common patterns that could be addressed by some developer guidelines on things to do, and things to avoid. So I’ve decided to publish this series of tips on OpenLaszlo performance tuning.
This first tip, “Pause Invisible Animations” pertains to runtime performance. I’ll discuss the various areas of performance in a later post, but for now, I figured I’d start this series with a tip that most OpenLaszlo developers can implement right away.
In OpenLaszlo, developers frequently use animated SWF resources in your applications (e.g. for loading indicators). These SWFs may take the form of a spinning wheel, an hourglass etc. When it’s no longer needed, you might disable the loading indicator by making it invisible. If you make an animated SWF invisible, but don’t stop it, then it will continue to consume client CPU while the animation is in progress. One animated SWF won’t slow an application significantly, but a number of animations that are running could account for a few percentage-points of CPU.
Fixing the problem is easy: just call stop() on the relevant views before making them invisible. There’s no reason not to stop invisible animations.
Determining whether you have animations you can’t see is also relatively easy. First, you’ll need the Debugger Version of the Flash Player. This is a browser-plugin, just like the standard Flash Player, and once installed, it will replace the existing player. The debugger player includes an option in the right-click menu to “Show Redraw Regions”. This feature visually identifies which parts of your application are actively getting redrawn (thereby consuming CPU), by highlighting them in red.
I tested this on the current version of Laszlo Webtop, (which you can try on www.gowebtop.com) and noticed a few animations that could easily be removed:
Stopping these animations will reduce CPU load while the application is being used, allowing important actions to execute a little faster.
2 thoughts on “OpenLaszlo Performance Tip: Pause Invisible Animations”