Careful with that framerate, son
Posted in Flash on June 16th, 2009 by Alexander – Be the first to commentA few weeks ago there was some heated discussion (started by Grant Skinner here) pointing out how badly AIR and the Flash player are at consuming CPU while idle. Adobe responded with some performance tips, and Grant created a FramerateThrottler class in order to work around the problem. Basically, it would seem that using high framerates is the culprit for most CPU usage problems, even if the application is inactive. Today I found an example that illustrates the same problem but in a different context: here is a Box2D based library with a framerate independant motion mode. Try the demo with Activity Monitor open, and you’ll see a huge difference in CPU usage when changing framerates: with Firefox/Mac, I get 40% at 12fps, and 90% at 60fps.
I found this quite interesting, since after so many years working with Flash I never questioned the basic concept of a god-like framerate. But if you think about it, why should the player try and update the display if nothing is happening? In theory, using UpdateAfterEvent or similar, we should be able to refresh the display as needed. Something to look into…
addition: I read this older post from Tinic Uro discussing Flash player performance, and thought I should point out a related performance problem that results from the use of WMODE. In his words:
If you use WMODE the Flash Player has no way of knowing if it is hidden or not and will continue to do a full render. Do not use WMODE.
