Optimizing Performance for the Adobe Flash Platform

Flash Player 10.1 on Google NexusPaul Robertson and I just finished writing a paper about optimization for producing optimized content with the Flash Player 10.1. This whitepaper (87 pages) covers best practices for applications running inside a browser, but these best practices also apply to Adobe AIR or even the iPhone packager available in Flash CS5. It also covers some technical details behind some of the new features in Flash Player 10.1 through 9 chapters. From simple memory optimizations, to more complex rendering tips, you'll see that a single line of code can have a high impact on memory or CPU usage. Here are the chapters :

  1. Introduction
  2. Conserving memory
  3. Minimizing CPU usage
  4. ActionScript 3.0 performance
  5. Rendering performance
  6. Optimizing network interaction
  7. Working with media
  8. SQL Database performance
  9. Benchmarking and deploying

For the past few months, I have been playing with the Flash Player 10.1 on the Palm Pre, Windows Mobile. I just saw it running now on the Google Nexus, and I am really excited about it, it just feels good seeing a SWF running in a mobile browser ;) I hope you guys will enjoy the paper, you can browse the beta (some tiny modifications will be added to the document during the week) whitepaper online here, or just download everything packed as a PDF to always have it with you. :)

Download here!

Comments (25)

  1. Jeff wrote:

    Niceone, very good info. I also liek the way it says ‘Prerelease – 02/12/2010 – ADOBE CONFIDENTIAL’, feel like an insider allready :p

    Monday, February 15, 2010 at 11:14 am #
  2. Thibault Imbert wrote:

    Hi Jeff,

    Happy to hear that you like it! :)

    Aha yes about the insider, it is still in prerelease for a few days :) It is 99% final, but a few things will be added and a few typo will be fixed tomorrow. It should be in final shape on Wednesday.

    best,

    Thibault

    Monday, February 15, 2010 at 12:00 pm #
  3. Downloading the pdf right now. 10.1 offers a lot of great scope for developers. Thanks a lot for the work.

    E

    Monday, February 15, 2010 at 12:06 pm #
  4. Jloa wrote:

    They haven’t released the 10.1 yet but u’ve made a guide for optimizing mobile apps. Nice. I’ll take my time and prepare for the release version of fp ^_^

    Monday, February 15, 2010 at 12:25 pm #
  5. Tronster wrote:

    Great Whitepaper. Am I right in that there is no way to determine when your application enters “sleep mode” (Ch 3.)?

    Not a fan of Stage.frameRate lying when it goes into 4fps and need some way to know when this mode kicks in; most of my code is tick driven through a timer not ENTER_FRAME.

    Monday, February 15, 2010 at 3:32 pm #
  6. Thibault Imbert wrote:

    Hi Tronster,

    Yes, I would have loved an appropriate event for that. Maybe for a future release, that’d be nice. Same surprise for the Stage.frameRate, we cannot rely on it to bypass the non-existing event.

    best,

    Thibault

    Monday, February 15, 2010 at 6:07 pm #
  7. ickydime wrote:

    Excellent resource, thanks for the help Thibault!

    Tuesday, February 16, 2010 at 12:12 am #
  8. Jon wrote:

    Wouldn’t a possible hack for not knowing about “sleep mode” be to have a timer in ENTER_FRAME that uses getTimer() and checks if it is (roughly) running at 4 fps? If you have a relatively stable program and you suddenly hit a 250ms gap between them (or 2+ frames in a row with the gap) then you could set a state that you are in sleep mode until that time goes up again. Obviously you would have to fine tune it for your own application, it is tough to tell false positives (ie. slowdowns from loading/initialization, etc) from a real sleep mode. It should at least work, even though it is far from ideal.

    The most interesting part of the document for me was the mention of the getSize() function which led me to look into the flash.sampler.* class. I had no idea it existed! It seems like no one has really written a good profiler (other than FlashBuilder) with it.

    Tuesday, February 16, 2010 at 1:53 am #
  9. bubu wrote:

    Thanks. this are a great document.

    Tuesday, February 16, 2010 at 2:37 am #
  10. Great info Thibault! Can you clarify one thing: the 32bit to 16bit reduction of “opaque images” – does that include bitmapData? And I guess that transparent images are not affected then?

    Tuesday, February 16, 2010 at 12:33 pm #
  11. Thibault Imbert wrote:

    Hi Mario!

    Good question, yes transparent images are not affected and this feature is only true for embedded bitmaps (Embed tag or Flash library) or runtime loaded images (PNG, JPG, GIF).

    I will add this info to the document.

    Thibault

    Tuesday, February 16, 2010 at 1:30 pm #
  12. Tronster wrote:

    Thibault, thanks for your thoughts, and again, fantastic document; I’ve read it from start to end.

    Jon, what a great idea, sampling ENTER_FRAME should be sufficient for determining sleep mode (as long as I don’t tank the frame rate myself.)

    Tuesday, February 16, 2010 at 1:50 pm #
  13. Thibault Imbert wrote:

    Hi Jon and Tronster,

    Yep, good idea. Using getTimer() this way should do the trick ;)

    Really happy you liked the document! :)

    Thibault

    Tuesday, February 16, 2010 at 1:57 pm #
  14. Yakov Fain wrote:

    Good read! The following phrase has to be re-written – it gives an impression that AMF lowers the speed of transmission:

    “Using AMF reduces the size of the data and the speed of transmission.”

    Tuesday, February 16, 2010 at 4:36 pm #
  15. Thibault Imbert wrote:

    Hi Yakov,

    Nice one! Thanks for noticing this. We will fix that in the document ;)

    Thanks again,

    Thibault

    Tuesday, February 16, 2010 at 4:59 pm #
  16. Thank you Thibault, spent the train journey from work engulfed in this, good stuff.

    Wednesday, February 17, 2010 at 5:23 pm #
  17. Paul wrote:

    Thank you for your writing, Thibault. I think I can try to use it and spread the word for other developer in Thailand by use your document as the major reference. Good job!

    Saturday, February 20, 2010 at 11:28 am #
  18. Thibault Imbert wrote:

    Hi Tyrone and Paul,

    I am happy you liked the document ! Do not hesitate to spread it around to developers.

    cheers,

    Thibault

    Sunday, February 21, 2010 at 4:45 pm #
  19. ferber wrote:

    Excelent, great work !
    is there a way, to unregister all event attached to a sprite without unload hit ?
    And other question : when is released the filter array of sprite ?
    Did the afectaction of null to filter realeased it ?

    Saturday, February 27, 2010 at 4:21 pm #
  20. MSFX wrote:

    wouldn’t it be faster to use bitwise math opposed to calling the math class?

    http://gskinner.com/talks/quick/#48

    Wednesday, March 24, 2010 at 9:06 pm #
  21. Thibault Imbert wrote:

    Hi MSFX,

    Yes, I cover that quickly in the “Reusing Objects” section.

    In some cases like for instance with Math.floor where you can just cast as an int which is much faster. But casting and then adding 1 does not work in all the cases (negative numbers) so you cannot totally forget Math.ceil().

    Inlining is covered in the “Miscellaneous section” and is a good way to bypass the usage of the Math class which is slow to call.

    Bitwise are great but always converts to unsigned or signed integers.

    best,

    Thibault

    Wednesday, March 24, 2010 at 11:39 pm #
  22. eco_bach wrote:

    Great article!
    Noticed I think one error on page 58.
    bitmapApple.alpha = Math.random();
    bitmapApple = holderVector[i];

    These 2 lines must be reversed to run properly.

    Wednesday, April 21, 2010 at 2:57 am #
  23. Thibault Imbert wrote:

    Hi eco_bach,

    Thanks for the catch! I will fix this in the next draft :)

    best,

    Thibault

    Wednesday, April 21, 2010 at 9:32 am #
  24. Raju Arora wrote:

    Thanks for the information shared here. that was an interesting and informative. I had a good experience by participating in the Adobe Summit in 2009 which features the latest developments on the Adobe Flash Platform that is of utmost importance to both developers, as well as designers.. I learnt lot of new technologies in Adobe. And I am planning to attend 2010 edition as well. I found the information about the conference from adobesummit.com

    Friday, July 23, 2010 at 2:14 pm #
  25. Will you be updating this paper for Flash Player 11 by any chance?

    Wednesday, October 5, 2011 at 12:08 am #

Trackbacks/Pingbacks (14)

  1. [...] Optimizing Mobile Content for the Adobe Flash Platform [ by Thibault Imbert ] [...]

     
  2. [...] Thibault Imbert (Adobe, Systems Engineer) has authored a 70 page document covering optimizing mobile content for the Adobe Flash Platform. [...]

     
  3. Optimisation du contenu pour Flash | Derwin Studio on Wednesday, March 3, 2010 at 1:18 am

    [...] Optimizing Mobile Content for the Adobe Flash Platform contient de nombreuses informations pour optimiser l’utilisation mémoire, CPU/GPU, échanges serveur,… Des concepts à la fois valables pour le développement Web et la programmation en général. [...]

     
  4. Optimisation du contenu du player Flash « Blog de Fennecös on Thursday, March 4, 2010 at 12:32 pm

    [...] livre est disponible en anglais ici : Optimizing Mobile Content for the Adobe Flash Platform Il nous apprend comment optimiser au mieux l'utilisation de la mémoire dans le player Flash grâce [...]

     
  5. Flex 4 Optimize those Item Renderers | Tyrone Neill on Saturday, March 6, 2010 at 12:39 am

    [...] Mobile Content: http://www.bytearray.org/?p=1363 This is by far the greatest white paper I have found so far about generally optimizing AS3.  Do [...]

     
  6. That’s just my way « electronslibres.ca on Tuesday, March 9, 2010 at 5:01 am

    [...] must Read : Thibault Imbert's white paper on Optimizing Mobile Content for the Adobe Flash Platform which contains usefull information on optimization for mobile phones, and desktop apps as [...]

     
  7. [...] Optimizing Mobile Content for the Adobe Flash Platform(モバイルコンテンツ向けの最適化に関して、Adobeからダウンロード可能なドキュメントが用意されています。必読) [...]

     
  8. Flash optimization on mobile | RIAgora on Friday, April 16, 2010 at 11:20 am

    [...] how to optimize your flash code, the reference is the white paper written by Thibault Imbert (http://www.bytearray.org/?p=1363). I figured out, reading this public book, that the main issues are coming from the rendering [...]

     
  9. HTML5 Flash ActionScript3 JavaScript « blog on Tuesday, April 20, 2010 at 2:43 am

    [...] (white papers) [...]

     
  10. The Pixels Explode. Explode! | unFocus Projects on Thursday, June 24, 2010 at 6:22 am

    [...] down on object instantiation – and followed a lot of the other tips in a conveniently timed ByteArray post. Doing that really helped – I cut the memory use about in half – and on the initial [...]

     
  11. [...] gist of the presentation boiled down a 92-page white-paper by Thibault Imbert and Paul Robertson (Optimizing Performance for the Adobe Flash Platform) as well as some practical tips by others in the [...]

     
  12. Flash to iOS FAQ | Paul Trani on Monday, January 24, 2011 at 1:02 am

    [...] ones · See Thibault Imbert is the Flash Player manager and has written about performance here: http://www.bytearray.org/?p=1363 He is the authority when it comes to [...]

     
  13. FITC, day two « aloft on Thursday, March 10, 2011 at 10:57 pm

    [...] it can be found too on Thibault’s blog and other places. So much reading to [...]

     
  14. Flash to iOS FAQ – Paul Trani on Friday, January 27, 2012 at 9:38 pm

    [...] Imbert is the Flash Player manager and has written about performance here: http://www.bytearray.org/?p=1363. He is the authority when it comes to performance, if you ask [...]