Profiling Flash Player Rendering

When developing Flash content, profiling the VM or custom code called can be done through the profiler bundled in Flash Builder or through the Flash Player configuration file (mm.cfg). Those give you low level details about the VM but does not give you an overview of what is happening behind the scenes concerning the rendering steps for instance. In the team, we are thinking about a way to give you some more details concerning the rendering engine.

What is really being called ? And the time it took for it.

This would allow us to provide you a rendering profiler perfect for fine tuning. It could generate a heat map of the rendering operations to see which operation internally is costing too much CPU cycles. A perfect way to detect also some side-effects which were not supposed to be there but where finally injected through the development of the application. A filter, some nested bitmap caching, or some blend mode or even a transparent bitmap used where it should not.

To get those infos you can use Shark on MacOS or VTune on Windows and Linux. The idea is simple, you run it, start collecting samples and start your SWF.  Once you are done, you stop collecting and it gives you an output. Without the Flash Player with the debug symbols you will not see anything relevant, just symbol adresses but nothing humanly readable. Like the following image :

No Debug Symbols

You can already see that some processes are costing more time than others. With the debug symbols (included to a special version of the debugging player), you can see all the internals. So let's say I use a BitmapData object to paint pixels in my application. The following output, shows me clearly that almost 18% of the processing time was taken by the BitmapData.setPixel32 which calls internally the AddDirtyRect API from SurfaceImage and the internal core BitmapDataObject class and its setPixel32 API :


By the way, you can see that the AVM spend some time leveraging SSE2 instructions through the AVMCore class. Same thing, let's say you have to audit a SWF to see if some bad practices are used there. In the following SWF, we see a PixelBlitThread which is the API used for bitmap caching, so there is a lot of chances that you would take a look at the code of this SWF to see if the bitmap caching is used properly and if memory is ok :

Bitmap Caching

Pure jewel for advanced optimizations. We are thinking about approaches to make this available (not in this raw-technical format) to every Flash developer. Do not hesitate to share ideas.

Comments (15)

  1. grapefrukt wrote:

    Anything to profile rendering would be immensely useful. Most of the games I make are completely render-bound speedwise and anything I can do to speed up that would be most appreciated.

    Thursday, May 27, 2010 at 11:01 am #
  2. Wow those are some deep insights in to how Flash draws stuff.
    Do I understand correctly that you are intending to release some kind of tool to see that kind of information?

    Thursday, May 27, 2010 at 11:05 am #
  3. fr wrote:

    Oh yes, yes yes, please do.

    And please, make this available also for AS1-2 code, cause hardcore developers in AS3 already know how to use shark, but ad-makers, designers, are still asked for AS1-2 banners aimed to flPlayer8 and would need to see that !

    Thursday, May 27, 2010 at 11:25 am #
  4. canab wrote:

    I was trying to use VTune for get profiling data. But I was unable to see all the internals with debag version of flash player. What means “special version of the debugging player”?

    Thursday, May 27, 2010 at 2:19 pm #
  5. Jason MacDonald wrote:

    It sounds great, but I’d caution that it needs to be usable by the average flex dev, and not someone who is already intimately knowledge about the underlying Flash Player API’s.

    I have the same opinion with the Profiler, it’s amazing and I love it, but most developers I talk with don’t use it because they don’t understand how to use it properly. There’s very few good articles on using the Profiler, and most are just general feature overviews.

    Thursday, May 27, 2010 at 3:39 pm #
  6. Thibault Imbert wrote:

    Hi wonderwhy-er,

    Yes we are thinking about ways to make that possible through some tools. Could be in Flash Builder for instance.

    Hi fr,

    Yes, this is woking for AS1/AS2 code also. We would make it easier to understand and do not make it raw like this. We have other plans for Ads, I will cover that in a future post.

    Hi canab,

    Yes, you will not be able to see the internals without a version of the debugger player containing the debug symbols. We do not provide such a version for now.

    Hi Jason,

    Yes, the plan is to make it easy to understand and quickly see the bottlenecks without being an expert in the Flash Player internals. The profiler is a great tool we could improve by adding rendering profiling.



    Thursday, May 27, 2010 at 8:09 pm #
  7. Ben Garney wrote:

    Why can’t you just release the debug symbols? Many other vendors do this for their binaries (for instance, Microsoft has binaries for all the directx runtime libraries). I guess it does make finding security holes easier. Perhaps an NDA for those who get the symbols would be appropriate.

    If symbols aren’t an option, then exposing gross renderer blocks in the flash.sampler API would help tremendously. Just having it for major sub-operations (dirty rects, rasterization) would be incredibly helpful.

    Thursday, May 27, 2010 at 9:07 pm #
  8. Thibault Imbert wrote:

    Hi Ben,

    Yes, releasing the symbols has been brought to the table multiple times and I think it would be valuable to do it. We need to make sure to hide some API’s that we do not want to expose for security reasons. But those are not related to rendering so we could hide them. That is a good idea for the flash.sampler API :)



    Thursday, May 27, 2010 at 10:18 pm #
  9. Hi Thibault,
    This week we were looking for such a tool to use with
    Can’t wait to have it!

    Thursday, May 27, 2010 at 11:45 pm #
  10. jpauclair wrote:

    That would be SO great…
    If you do any pre-release, beta, trial, testing, whatever! please include me in these developpement!

    I already have experience with VTune, and (as you may have noticed) I’m a optimization maniac ;)

    I realy like where you guys are going… more power to the advanced programmers. And maybe a gaming platform that is incredibly hard to beat.


    Friday, May 28, 2010 at 4:39 am #
  11. jpauclair wrote:

    (you wrote mms.cfg instead of mm.cfg)wrong file ;)

    Friday, May 28, 2010 at 4:40 am #
  12. Thibault Imbert wrote:

    Hi Jean-Philippe,

    We will definitely ask for feedbacks. I will think about you for sure :)

    Oops, thanks for the typo!



    Friday, May 28, 2010 at 8:02 am #
  13. Kodiak wrote:

    Hi Thibault!

    Would it be possible to have the same thing for AIR? A debug+symbols Adobe AIR.dll?…

    Monday, May 31, 2010 at 2:55 pm #
  14. Bart wrote:

    It would be great if any method that can give a more detailed view of the rendering performance comes available.

    Like grapefrukt a lot of games we make will have a very large portion of the performance in rendering. Any info we can get on that large block and then reduce will probably have more effect than optimizing the other logic.

    Sign me up for the beta!

    Monday, May 31, 2010 at 8:19 pm #
  15. sebas wrote:

    man, I really need this version that includes the symbols. How did you manage to get one? Can I have one without pissing off anybody?

    Saturday, September 4, 2010 at 1:45 pm #

Trackbacks/Pingbacks (2)

  1. Free Tutorials & Photo Search Online | Download Zone on Thursday, May 27, 2010 at 10:11 am

    [...] Profiling Flash Player Rendering <font size='1'>[ by Thibault … [...]

  2. [...] Profiling Flash Player Rendering <font size='1'>[ by Thibault … [...]