Asynchronous bitmap decoding in the Adobe Flash runtimes by Thibault Imbert

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

Comments (18)

  1. João Saleiro wrote::

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

    Friday, March 25, 2011 at 1:12 am #
  2. Thibault Imbert wrote::

    Yep Joao,

    We are working on this at the same time :)

    Thibault

    Friday, March 25, 2011 at 1:13 am #
  3. Héctor wrote::

    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.

    Friday, March 25, 2011 at 9:26 am #
  4. focus wrote::

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

    Friday, March 25, 2011 at 9:28 am #
  5. pete shand wrote::

    awesome little improvement! nice work adobe

    Friday, March 25, 2011 at 10:31 am #
  6. oxmo456 wrote::

    Génial ! :)

    Friday, March 25, 2011 at 10:39 am #
  7. Y.Boy wrote::

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

    Friday, March 25, 2011 at 1:40 pm #
  8. Jorge Dourado wrote::

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

    Cheers

    Friday, March 25, 2011 at 3:38 pm #
  9. Héctor wrote::

    @Jorge Dourado,

    You can target AIR 2.6 with CS5:

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

    Saturday, March 26, 2011 at 4:55 pm #
  10. nimrod sion wrote::

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

    Sunday, March 27, 2011 at 1:07 am #
  11. _equ wrote::

    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

    Monday, March 28, 2011 at 5:10 pm #
  12. João Saleiro wrote::

    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

    Wednesday, April 6, 2011 at 7:20 pm #
  13. Engin wrote::

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

    Wednesday, April 13, 2011 at 4:15 pm #
  14. MSFX wrote::

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

    Sunday, April 17, 2011 at 1:25 pm #
  15. Thibault Imbert wrote::

    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

    Monday, April 18, 2011 at 1:24 am #
  16. Henry wrote::

    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.

    Sunday, September 4, 2011 at 6:27 am #
  17. Henry wrote::

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

    Sunday, September 4, 2011 at 6:29 am #
  18. Henry wrote::

    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’
    }

    Thursday, September 29, 2011 at 4:50 am #

Trackbacks/Pingbacks (6)

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

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

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

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

     
  5. Multithreading in Flash update - Matthew Fabb’s blog on Friday, September 2, 2011 at 7:37 pm

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

     
  6. Static Variablen im Worker SWF - Flashforum on Friday, May 3, 2013 at 7:30 am

    [...] [...]