A friend of mine was reviewing a new chapter I have been writing for the Flash Player 10 and asked me if it was possible to detect at runtime if GPU acceleration was set in a current SWF. In fact, there is no native API in the Flash Player 10 which allows you to know that.
You can detect that information with some JavaScript and retrieve the wmode being used for the player running in your browser, but with the following method you will also be able to retrieve this information for the external and standalone player.
I updated the SWFExplorer library so that you can check if any hardware acceleration has been set in the current SWF and handle that (show any specific message to inform or alert the user).
Here is how to detect the current hardware acceleration mode in your future Flash Player 10 SWF's with SWFExplorer 0.4 :
// create the SWFExplorer object var explorer:SWFExplorer = new SWFExplorer(); // pass the current SWF bytes and specify that you want to discover the current GPU mode // you would pass SWFExplorer.CLASSES to discover the linked classes explorer.parse( loaderInfo.bytes, SWFExplorer.ACCELERATION ); // affiche : true trace( explorer.acceleration == SWFExplorer.GPU ); // affiche : false trace( explorer.acceleration == SWFExplorer.DIRECT ); // affiche : false trace( explorer.acceleration == SWFExplorer.NONE );
Download this new version here.
Comments (16)
Nice, but isn´t your post title a bit misleading?
to me this looks more like a way to get if hardware acceleration was set in the swf. This would be more interesting for swf content publishers to see if the developer has set hardware acceleration, for example if they actually want to block that for let´s say flash advertisement banners.
It is not any useful for seeing whether the content actually runs hardware accelerated as it should ( = if the user running the flash content has the right hardware setup to make it work).
Hi tomsamson,
Exactly, in fact this feature is only intereresting for the standalone and external player.
You are right, I updated the post title
The idea is just to give the ability for a developer to check which GPU mode has been set in the current SWF, when it runs inside the Flash CS4 IDE or inside the standalone player. This way a developer could change some settings, do some specific optimizations or even add a GPU hardware check to show a warning message if a developer has recompiled the project with some unappropriate hardware acceleration.
cheers,
Thibault
nice, yeah
). So yeah, i don´t know yet, how can one actually detect whether the user has the required hardware and the content really runs gpu accelerated for him?
i haven´t played much with the gpu acceleration side after an early beta (since i didn´t get it running as i wanted back then i thought i´d wait till the next beta
Hi,
Yes I see what you mean. By retrieving the wmode by JavaScript, this will not tell you if the player found the required hardware and is currently using hardware acceleration. There is no API for that and it is missing.
Thibault
I see, yeah, i wondered if it meanwhile had been added

Well, i hope it gets added sometime soon then, would be very useful
Anyway,
cheers,
tomsamson
Would the new book (along with these additional chapters) be in English?
Hi William,
Not for the moment. Pearson will first edit the book in French, then see if they translate it
The good news is that the current online version is being translated. I will announce its availibility on the blog.
best,
Thibault
off topic !! what plugin you used to highlight your actionscript code ?
Hi Saeed,
I use SyntaxHighlighter, it works very nicely :
http://wordpress.org/extend/plugins/syntaxhighlighter/
best,
Thibault
How can I compile swf with GPU acceleration? SWFExplorer always detect NONE.
Hi Rzer,
You will be able to set that with Flash CS4, you can also set that through some command line with the Flex 4 (Gumbo) compiler.
And what is the command line to activate hardware acceleration with the Flex 4 compiler ?
… s’il te plait!
wow nice job, is it posible to disable flash player hardware acceleration at runtime using actionscript?
@promethe i’m afraid you can’t enable gpu hardware acceleration with the flex 4 compiler. you can set the wmode in your html if you are embedding the .swf in a web page, but you can’t set the .swf tag for use in the standalone player. the issue has been reported to adobe. please see: http://www.moock.org/blog/archives/000291.html
hello everybody
is flash player when we disable hardware acceleration change a value or more in registry ??
I need this so much
please help me
Trackbacks/Pingbacks (2)
[...] Detect hardware acceleration at runtime in Flash Player 10 standalone A friend of mine was reviewing a new chapter I have been writing for the Flash Player 10 and asked [...]
[...] Thibault Imbert: “A friend of mine was reviewing a new chapter I have been writing for the Flash Player 10 and asked me if it was possible to detect at runtime if GPU acceleration was set in a current SWF. In fact, there is no native API in the Flash Player 10 which allows you to know that.” [...]