Is AIR Hardware Accelerated?
Posted: November 20th, 2007 | Author: Tiago Bilou | Filed under: Adobe AIR | 3 Comments »This question popup up today while playing around with AIR and transparent windows. I wrote a simple actionscript app inside flex builder, that draws some sprites (that move randomly) onto a transparent AIR window.
The first time I ran the app (with only one circle), I was surprised to see my Pentium 4 (3.2 ghz) reach 30% of cpu usage to animate that single sprite. It the window had the transparency turned off the cpu usage would be 0-1%.
The second time I ran the app (with 10 circles), the frame-rate dropped dramatically from 24 to 12-fps, and the cpu usage went up to 50%. At this moment I truly believed that what I wanted to do could not be accomplished. I mean, with only 10 sprites moving around the screen all I get are 12-fps...
Having the AIR runtime installed on my mac (powerPC 1.5 ghz) I tried running the app with the 10 circles to have a laugh at the poor performance. When I saw the app running my jaw dropped... My mac was running the AIR app with the transparent window and the 10 sprites moving around at 24-fps. How could this be... I know for a _fact_ that the flash performance is ALOT worse on my mac than on the PC., so how could the mac be behaving so well... It it because macosx uses the gpu to render the windows? And because AIR is using one of those windows it's being rendered by the gpu instead of the cpu?
I decided to google for a while and found out that Windows uses layered windows to display transparent windows and that AIR is using that. I also read that when using layered windows the drawing of the windows goes into an off-screen buffer (probably inside the graphics card)
So I decided to draw 100 sprites inside the AIR app. Guess what happened? The frame-rate was still at 12-fps and the cpu was still at 50% the same values I got when drawing 10 sprites. At this moment I thought that maybe the frame-rate was so low because I have a very old graphics card.
I used another PC with a similar cpu (Pentium 4 3.4ghz) but with a kick-ass graphical card. The result: 70-fps and 15% cpu usage.
My guess is that because AIR is using transparent windows, the OS is rendering it inside the graphics card (remember the off-screen buffer) instead of the cpu.
Can anyone confirm this?
update: After a short discussion with ivan, I reckon that all flash "stuff" is still done in the flash player and is _not_ hardware accelerated. However, the transparency calculations, are done in the graphics card. If you have a good graphics card you don't need to overload the cpu with those calculations and you can use it for the flash calculations.
Can you post your sprite test project ? I’d be interested to see how my PC fares in comparison
Totaly agree!!! Transparent window takes 40% of my CPU (I have a laptop with a poor graphic card) and the same code on my brother’s PC (video game geed) only 10%.
So I think for respect user capa.. all AIR application using transparent should have an options to turn off this (but I believe its impossible in runtime?).
Such a petty that there is no control panel for AIR means CPU allowed, RAM allowed, Allow transparence? Allow Network access?
Because like that, its impossible to release an AIR application using transparence.
Thanks for your article
[...] and the application became unstable. Wouter Martens (currently doing his internship) stumbled upon this blog post because he also had the CPU issue on his machine. It turns out that the problem is depended on [...]