Post Update: Be sure to check out the blog post Writing well-behaved, efficient, AIR applications by Arno Gourdol that provides more details on some of the tips suggested below.
—
As more Adobe AIR applications are being built, one piece of feedback that we hear from developers is that the idle CPU for basic AIR applications on the Mac is too high. Today, Flash developer Grant Skinner wrote a blog post sharing his concerns around the excessive CPU usage of Adobe AIR and Flash Player applications on the Mac — particular in the case of a simple application.
First, I want to thank Grant for not only sharing his concerns, but also for directing developers to use the open Flash Player bug database to report their issues. When the developer community votes on bugs that have the biggest impact, this helps send valuable data back to our development teams on what the community believes to be the most important issues. Though Adobe AIR does not have a public database yet, we request that you use our feedback form to report bugs and feature requests. These issues come directly to our team and we do our best to reproduce every bug that comes in.
Second, I also want to be clear that reducing CPU usage on the Mac is an area that we are making investments in the next version of Adobe AIR and Flash Player. This is an important issue for us to address and we are focused on making improvements in this area (we hear you Grant and we’re already working on it :).
Finally, as we talk to developers building Adobe AIR applications, we have come up with a few tips that can help improve the performance of your applications:
- Try to use the smallest "frameRate" possible in your application. To do this, set stage.frameRate or mx:WindowedApplication attribute of your application. This will help reduce the overall amount of CPU usage for applications.
- When your application is in the background, set "stage.frameRate = 1;" as it will reduce CPU usage to < 1% 2.To be notified when an Adobe AIR application goes into the background: "this.addEventListener(AIREvent.APPLICATION_DEACTIVATE, appDeactivate);" Grant has put together a simple class that does this for you.
- Use Timer whenever possible instead of enterFrame handlers. The later are expensive and are called often.
- If you are building a Flex-based application, use the Flex Builder profiler to identify optimizations that can be made in your code. By doing so, you might find that you are, for example, invoking network calls more frequently than you need to.
If you have other tips, please feel free to share. We are planning to create a more comprehensive FAQ that provides guidelines on how to improve the performance of your applications.
Also, be sure to check out the following links for other tips and tricks: