Fun with code (since 2006)

Asynchronous bitmap decoding in the Adobe Flash runtimes


03.25.11 Posted in Actionscript 3, AIR, Flash Player, Inside the Flash Player by

I just wanted to show you one little improvement we added in Adobe AIR 2.6 (also coming in a future release of the Adobe Flash Player) to improve responsiveness of your applications. For many years when loading big images, your UI could be impacted during the image decoding. As the decoding could be intensive and done on the UI thread, it would generally lock your application and impact the overall responsiveness and make your animations not smooth. We now decode images in a separate thread.

Here is how you would specify this in ActionScript 3 :

// create a LoaderContext
var loaderContext:LoaderContext = new LoaderContext();
// specify async decoding
loaderContext.imageDecodingPolicy = ImageDecodingPolicy.ON_LOAD;
// create a Loader
var loader:Loader = new Loader();
// inform the Loader
loader.load( new URLRequest("http://dl.dropbox.com/u/7009356/IMG_1398.jpg"), loaderContext );

Note that this feature also work with the Loader.loadBytes() API. Find below a little demo of the value of this new feature that we are also bringing to the Flash Player. I am playing a little animation and loading a big image in the background. Note how the animation is locked for a few ms when not using the async decoding :

While we are working more generally on the concurrency topic, we are also working at the same time on other little improvements like this, to keep improving the responsiveness of your application with very little effort.

As always, thanks Chris for the beautiful asset ;)



24 Responses to “Asynchronous bitmap decoding in the Adobe Flash runtimes”

  1. Hey Thibault. This is great! I really hope to see not only this improvements, but also the support for multi-threading in Flash Player in a very near future. ;)

  2. Thibault Imbert says:

    Yep Joao,

    We are working on this at the same time :)

    Thibault

  3. Héctor says:

    I love to see some improvement from AIR will be brought to the native FP.

    Thibault, could you give some insight if cacheAsBitmapMaptrix will have the same fate? or are you waiting for some other new improved caching features? you know, like the ones submitted to the Adobe JIRA by yourself time ago.

  4. focus says:

    Thats really giving a hope, Thibault, thank you. And it’s nice to see you as assignee for the FP-1631. Some good news in one day!)

  5. pete shand says:

    awesome little improvement! nice work adobe

  6. [...] http://www.bytearray.org/?p=2931 KategorienNews Tags: Air, AS3, Framework Kommentare (0) Trackbacks (0) Einen Kommentar schreiben Trackback [...]

     
  7. Y.Boy says:

    That’s good, but not best. I write a post about decoding bitmap.
    Hope you can see:
    http://riaoo.com/?p=2132

  8. Great news!
    But when can we see all the new features in Flash CS5?.. as an update?

    Cheers

  9. Héctor says:

    @Jorge Dourado,

    You can target AIR 2.6 with CS5:

    http://forums.adobe.com/thread/826939

  10. nimrod sion says:

    This is great, I am waiting 8 years for that, no more work arounds for animations, full multitread will put Flash tech in the next level of frameworks. Hope to see it happen soon :-)

  11. _equ says:

    There is a chance that “Query Graphics Data”* will be available in the forthcoming version of flash player?

    * feature request: https://bugs.adobe.com/jira/browse/FP-605

  12. Hey Thibault,

    what about having AMF/SOAP deserialization in a separate thread?

    As suggested here:

    http://bugs.adobe.com/jira/browse/ASL-23

    ;)

    João Saleiro

  13. Engin says:

    Hi Thibault,
    Is there any though about applying this to BitmapData’s draw method? Or should we wait for the worker threads?

  14. MSFX says:

    This is great news, which player will this become available within? :)

  15. Thibault Imbert says:

    Hi João,

    This is on our radar for AMF but requires a lot of work. We are tracking it, but I cannot commit to anything for now.

    Thibault

  16. [...] Async bitmap decoding — http://www.bytearray.org/?p=2931 [...]

     
  17. [...] Async bitmap decoding — http://www.bytearray.org/?p=2931 [...]

     
  18. [...] Async bitmap decoding — http://www.bytearray.org/?p=2931 [...]

     
  19. [...] Adobe has also been working on putting other Flash processes on a separate thread. Example they put bitmap decoding on a separate thread. This was added to Adobe AIR in version 2.6 and added to the Flash Player in the 10.3 [...]

     
  20. Henry says:

    I’d love to use this on my photo gallery, but having a bit of trouble implementing this in the browser. Is it available in FP11 Beta 2 (Mac Debug version)? When I try to set the imageDecodingPolicy property I get the following error

    ReferenceError: Error #1056: Cannot create property imageDecodingPolicy on flash.system.LoaderContext.

    I’m in 11.0.1.98.

  21. Henry says:

    Sorry Thibault, can you remove my email from my name the last post. Autofill error!

  22. Henry says:

    Found the solution to my problem. My SWF was targeting version 13, but it was being loaded in by a preloader that targeted version 10, so async wasn’t available.

    I have another question though – Is it possible to publish for FP 9 or FP 10, and still get access to async if the user has FP 11 installed? Or will that only be accessible if you publish to FP 11?

    Below is some code I hoped might allow me access to async even when published to FP 9 or 10.

    var async_available = ApplicationDomain.currentDomain.hasDefinition( “flash.system.ImageDecodingPolicy” )

    if(async_available){
    context['imageDecodingPolicy'] = ‘onLoad’
    }

Leave a Reply

Open Sort Options

Sort comments by:
  • * Applied after refresh

ByteArray.org
Fun with code since 2006.