Thursday, August 18, 2005

Performance traps in Flash Player 8

No question, everyone is excited about this release of the Flash Player. The new features definitely offer something which has never been seen before on the web. But, as with any new technology it can be overused. There are reasons why the Flash Player did not offer these advanced feature in earlier releases. One of them was the lack of client machines out there being able to handle the CPU load some of these new features will require. I am scheduled to write two articles about this for DevNet to point out the limitations. You will almost certainly run into these also. Here is quick summary:

  • The On2 VP6 codec roughly uses about twice the resources than Sorenson Spark codec. This includes CPU usage and memory usage. Better quality simply means more complexity on the decoding side. At least The On2 VP6 codec is still running on slower machines compared to the QuickTime 7 H.264 codec (which really has outrageous hardware requirements).

  • Alpha channel video is very complex. One of the most common mistakes which will be made is that users will make the assumption that fully transparent areas will not impact on CPU usage. This is not the case, the codec has no clue which areas are transparent, still needs to decode them AND compose them. There is a strong need to clip out as much of the transparent areas as possible. Even our marketing team ran into this when they put together the Studio Experience. Some of the alpha channel videos were something like 640x350 pixels large, although it does not look like it. This is way too large for older Macs to handle. There are some tricks you can use to get around some of these problems, but they are difficult to author.

    Overall alpha channel video is about 4 times more complex than decoding video without alpha channel (That also means that alpha channel video is about 6-8 times slower than Sorenson Spark video overall). Why is that? The Flash Player, in addition to decoding the normal video needs to decode a separate alpha channel and then needs to do compositing against the background. Especially the latter step is extremely expensive, despite the fact that we use MMX and AltiVec for this. If there is no alpha channel we can decode directly into the bitmap buffer which is not possible when an alpha channel is present.

  • The blur filter, drop shadow, bevel and glow filters are mostly limited by memory bandwidth as are many other filters. Like I explained in the previous post there is nothing more we can do performance wise in this release. Keep this in mind and make sure you test your content on the slowest machine you want to have your content working. I usually use an old black PowerBook G3 to test since these are the slowest machines which are mostly likely to be still in use. Even better, why not author your Flash files on that machine? Cumbersome, but at least you'll see the problems instantly. Too many times I have seen emails from angry customers authoring their content on their lastest and fastest Pentium 4 and then wondering why the performance sucks on an old machine. Gimme a break... Doom 3 won't run on a Pentium I 90Mhz either.

  • There is a new feature called 'Show redraw regions' in the Flash Player which will allow you to see which areas of your movie are refreshed every frame. Use it extensively to keep the areas as small as possible.


Be smart when you employ filters, effects and video. It's good to spice up content with them, but usually a more subtle use of them is better than overloading your animations with bling bling. We really do not need another 'Skip Intro' era do we? :-)

8 Comments:

Blogger alemieux3 said...

Very interesting. It seems like software development is still ahead of hardware and OS development and the demand for future technologies is being bottlenecked. I'm glad Macromedia keeps pushing the envelope though. And BTW, I too use a black PowerBook G3, so I can empathize with your pain in that regard. Its still a great machine though.

Friday, August 19, 2005 8:29:00 AM  
Blogger backbaychef said...

My question is, is there a way to publish in the new codec but not take the hit of the alpha channels.

Meaning, I am interested in have a smaller size for my media, but won't be using the alpha channel.

Will I still take the hit?

Friday, August 19, 2005 11:29:00 AM  
Blogger Mario Pizzinini said...

...new feature called 'Show redraw regions'...

Wow, I haven't heard about that. It could easily become my favourite feature. :)

Mario

Monday, August 22, 2005 4:17:00 AM  
Blogger Mario Pizzinini said...

...new feature called 'Show redraw regions'...

Wow, I haven't heard about that. It could easily become my favourite feature. :)

Mario

Monday, August 22, 2005 4:38:00 AM  
Anonymous Neb Kragic said...

I looked the Macromedia Flash 8 Video Encoder and I do not see how to create a video with an alpha channel. How do I do this?

Thursday, August 25, 2005 8:23:00 AM  
Anonymous Andrew said...

I'm just curious. Does alpha video in a SWF use up any more or less CPU power than an FLV with an alpha channel?

Saturday, December 31, 2005 8:58:00 PM  
Anonymous Anonymous said...

I can't pretend to have a lot of understanding of how the Flash player works / differs on different O/S, so I'm not sure if it already does, and I'm sure it's been looked at, but rather than using Altivec to do your compositing, would there be any benefit in using CoreImage / CoreVideo (which in turn would give you the benefits of GPU hardware acceleration on more modern machines)?

It would almost certainly be worse on any G3 and most pre-2004 G4 machines, but going forward you'd be able to benefit from whatever underlying changes are made in OS/X.

My understanding is that Vista will also offer a similar compositing API.

I guess the risk with both is that they may be slower than your custom code, but I wonder how much that may be offset by farming work out to the GPU.

Saturday, February 04, 2006 10:06:00 AM  
Blogger britbikegirl said...

Somehow my life has come back around to using flash again. It would seem we've hit some of the performance bear traps. We're seeing loads of performance problems with things that I wouldn't expect to be problematic, such as using a movie clip animation on a mouseover state.

Also problematic is an animating logo...which is a rotating vector movieclip.
Obviously the code has changed greatly since I worked on it back on version 4...I keep wondering if I'm somehow missing something obvious.
Does flash just not handle these types of thing well anymore? This is comsuming all of the cpu, as in 100% on a PIII 930mhz 512MB, and 80%-98% on a P4 3.0mhz with 2.49GB with Hyperthreading on.
We removed all the animations and made these all static and the problem went away. Another thing we noticed is that rapid mouseOver over a button menu uses a lot of the cpu as well.
It seems like once the player has rendered it, it shouldn't have to render it over and over. Is this not the case?

Is this a known issue? I'm not finding a great deal of help on performance improvement on the macromedia site. I read the bitmap caching article but that didn't seem to have much to offer for our particular animations.

Also using flash and a java app on the same page seems to make for an unhappy cpu, not that java isn't a cpu hog... but it works out poorly and we'd like it if we could get it to play nice.

If it is useful I can send you the movies or get you access to our staged site with the java app.

Is there other info somewhere about performance bugs and workarounds?

Any tips would be greatly appreciated.

-raven

Wednesday, February 08, 2006 1:20:00 PM  

Post a Comment

<< Home