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 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)

  1. tomsamson wrote:

    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).

    Wednesday, September 10, 2008 at 2:28 pm #
  2. Thibault Imbert wrote:

    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

    Wednesday, September 10, 2008 at 3:07 pm #
  3. tomsamson wrote:

    nice, yeah :)
    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 ;) ). 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?

    Wednesday, September 10, 2008 at 5:08 pm #
  4. Thibault Imbert wrote:

    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

    Wednesday, September 10, 2008 at 5:24 pm #
  5. tomsamson wrote:

    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

    Wednesday, September 10, 2008 at 6:03 pm #
  6. Would the new book (along with these additional chapters) be in English?

    Thursday, September 11, 2008 at 3:20 pm #
  7. Thibault Imbert wrote:

    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

    Friday, September 12, 2008 at 2:08 am #
  8. off topic !! what plugin you used to highlight your actionscript code ?

    Saturday, September 13, 2008 at 11:14 pm #
  9. Thibault Imbert wrote:

    Hi Saeed,

    I use SyntaxHighlighter, it works very nicely :

    http://wordpress.org/extend/plugins/syntaxhighlighter/

    best,

    Thibault

    Sunday, September 14, 2008 at 2:09 pm #
  10. Rzer wrote:

    How can I compile swf with GPU acceleration? SWFExplorer always detect NONE.

    Thursday, September 18, 2008 at 11:19 am #
  11. Thibault Imbert wrote:

    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.

    Thursday, September 18, 2008 at 10:16 pm #
  12. promethe wrote:

    And what is the command line to activate hardware acceleration with the Flex 4 compiler ? :D

    Friday, November 21, 2008 at 8:23 am #
  13. promethe wrote:

    … s’il te plait! :D

    Sunday, November 30, 2008 at 2:49 am #
  14. Bagus Budiarto wrote:

    wow nice job, is it posible to disable flash player hardware acceleration at runtime using actionscript?

    Monday, January 12, 2009 at 1:13 pm #
  15. colin wrote:

    @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

    Friday, May 22, 2009 at 12:02 am #
  16. Soledad wrote:

    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

    Monday, January 11, 2010 at 4:44 pm #

Trackbacks/Pingbacks (2)

  1. L’actu Flash/Flex/AIR - lab3109 on Monday, September 15, 2008 at 4:43 pm

    [...] 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 [...]

     
  2. [...] 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.” [...]