04 November 2010

FlashPlayer 10.1 Throttling Problems

While the idea to throttle SWFs in inactive or minimised tabs/windows down to 2fps to reduce CPU usage is a good thing, it can cause havoc with SWFs that use both time-based and frame-based timing.

The frames will tick at 500ms, yet any time based event will still fire after TIMER_COMPLETE or after setTimeout(). You cannot rely on sequencing between the two, which is not a good idea anyway, but potential problems are made worse by the throttling.

If possible, do not mix frame and time based sequencing (which is good practice), but if you need to know when the SWF is minimised you can listen for:

Event.ACTIVATE
Event.DEACTIVATE


Now, this works on FF 3.5.15 with FP 10.1, it may behave differently between browsers and FlashPlayer versions, so it could be fairly unreliable.

In another experiment, I played a silent audio track while it was minimised, this kept the movie running at 8fps, which gave better resolution which was just enough to prevent some of the timer / frame sync issues, but again wasn't 100% reliable.

In short: don't mix your timers, try and keep it frame based. Until Adobe roll out an event we can use to detect throttling, we're stabbing in the dark.

No comments: