Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Flash so hard on the CPU?

Tags:

flash

Recently I hear Steve Jobs citing this as a main reason to not have Flash on IPADS

like image 495
Srikar Doddi Avatar asked Apr 05 '10 01:04

Srikar Doddi


3 Answers

In the general case, Flash isn't hard on the CPU, Flash contents are hard on the CPU. People don't usually use Flash to display static text and bitmaps, they use it for vector animations and video and RIAs with custom-skinned components, and compositing all those vectors and gradients and alpha channels takes CPU - regardless of whether you use Flash or HTML5 or Silverlight or JavaFX or whatever. Feel free to go check out the demos at this animation comparison, and see how the CPU usage of the HTML5 version stacks up against the Flash version. Results vary a lot by OS and browser, but for me (winXP/firefox), the Flash version uses roughly the same CPU as the canvas version (~50%), while giving a little more than double the FPS.

The second answer concerns video specifically, and the answer is this: no matter what technology you use to display video, only two things really affect the CPU usage: the codec, and whether or not it's hardware accelerated. You can test H264 video across browsers and OSs and Flash/HTML5 (and people have done so), and what you find is that CPU is low when video is hardware accelerated, and it's high when it's not, both inside Flash and out. So there's no issue of whether Flash video is hard on the CPU, the only question is whether Flash video is using HWA or not. Check the link for full details, but basically unless you're using OSX/Safari, Flash video uses the same CPU or less than other options.

Incidentally, if you were also wondering why Flash has historically used more CPU on macs than on PCs, even for non-video contents, see here for a lot of details - both on why it's been worse in the past and why it's improving with Flash 10.1. The quick version is that Apple has added newer and better ways for plugins to draw into the browser.

like image 53
fenomas Avatar answered Nov 19 '22 21:11

fenomas


If you look at processor utilization of Flash, it's significantly higher on the mac than the PC. The next release of the flash player (10.1) will make it much better, but not the same as the PC.

I read somewhere that part of the reason is the video. On Windows, applications have access to hardware acceleration to speed things along, on OS X, the necessary API's aren't available for flash to use. Also, flash can't easily utilize multiple processors so it's limited in that sense too.

like image 42
ablerman Avatar answered Nov 19 '22 22:11

ablerman


I would say that the main reason is doing animation and other graphic calculations, like alpha compositing, graphical filters and such, using the CPU instead of the GPU. Flash applications that don't animate are not very heavy on the CPU.

The same thing can be seen in many of the HTML5/canvas demos of late, like http://9elements.com/io/projects/html5/canvas/ or animation intensive stuff at http://www.chromeexperiments.com/ that are very hard on the CPU. So I would say it is not Flash Player as such that is heavy on the CPU, it's the stuff that Flash is often used for that is.

As for the reasons why Flash is not on iPads, I can of course only speculate, but one thing people tend to forget is that no browser plug-ins are allowed on the iPhone/iPad. So stuff like Unity and Silverlight is also out, not only Flash. Java is not on there either.

like image 41
Lars Blåsjö Avatar answered Nov 19 '22 21:11

Lars Blåsjö