SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
Mobile Performance – Tips & Tricks
      Mihai Corlan | Developer Evangelist | h p://corlan.org




© 2011 Adobe Systems Incorporated.
Agenda

      Focus on AIR development for Android and iOS
      Understanding Mobile Landscape
      CPU vs GPU mode
      Flex “Hero” considerations




© 2011 Adobe Systems Incorporated.
Multiscreen Landscape

      Adobe AIR Runtimes for:
            Desktop
            Mobile & Tablet
            Digital Home (TV, Set-top boxes)


      Hardware:                                  User Expectations:

            CPU from 500MHz to 2GHz dual core;   •    Responsive Apps
             ARM to x86                           •    Beautiful Apps
            GPU from OpenGL ES 1.1 to 2.0
            RAM from 128MB to 1GB+
            Screen Resolution & DPI
             800 x 480 & 254 ppi / 3.7”
             1024 x 600 & 170 ppi / 7”


© 2011 Adobe Systems Incorporated.
Mobile CPU/GPU Differences




                                     m t/s – millions of triangles per second
                                     h p://alienbabeltech.com/main/?p19309
© 2011 Adobe Systems Incorporated.
General Performance Tricks




© 2011 Adobe Systems Incorporated.
Where you can optimize?



                                     Heavy Code                           Rendering




                                                  See Ted Patrick / Sean Christman posts on Elastic Racetrack

© 2011 Adobe Systems Incorporated.
DisplayList – Choosing the Right DisplayObject Type

                                                    Less
                 236
                                     Shape/Bitmap
                Bytes


                                                             DisplayList




                                                    MEMORY
                  414
                                      Sprite
                 Bytes




                  440                 MovieClip
                 Bytes

                                                    More

© 2011 Adobe Systems Incorporated.
General Optimizations Tricks Apply to Mobile

      Keep the DisplayList as simple as possible (BitmapData.copyPixels() and Mark
       & Sweep/Garbage Collection)
      Avoid Memory Leaks (Remove Event Listeners / Weak References)
      Avoid Memory Fragmentation (data models: using a large object instead of
       lots of small objects)
      Pool of Objects (avoid object creation especially for UI)




© 2011 Adobe Systems Incorporated.
Mobile Render Mode




© 2011 Adobe Systems Incorporated.
AIR Pro les




© 2011 Adobe Systems Incorporated.
Mobile Render Mode

      You can choose:
            CPU Mode
            GPU Mode
            Auto Mode ( for now it defaults to CPU Mode)


      In Flash Builder:
       <!– Application Descriptor File -->
       <initialWindow>
              <renderMode>gpu</renderMode>
       </initialWindow>




© 2011 Adobe Systems Incorporated.
Understanding GPU Mode

        ere are two different stages where the GPU can be used for rendering:
      Rasterizing – rendering graphic elements into a pixel buffer
      Scene Composing – arranging pixel buffers


  Today’s AIR Mobile GPU Modes:

       Render                        GPU Type     Rasterizing   Composing     AIR      Mobile
        Mode                                                                Version   Platforms
         CPU                 -                       CPU          CPU         All        All
                                     GPU Blend*      CPU          GPU         2.0       iOS
        GPU
                                     GPU Vector      GPU          GPU         2.5     Android



  * iOS will have GPU Rasterizing support in the future
© 2011 Adobe Systems Incorporated.
GPU Blend vs. GPU Vector

      GPU Blend:
            Rasterizing  CPU
                                     Pixels are copied from the System Memory
            Composing  GPU         to the GPU Memory (expensive operation)


      GPU Vector:
            Rasterizing  GPU       Pixels don’t need to be copied
            Composing  GPU




© 2011 Adobe Systems Incorporated.
Understanding Caching:
                                     cacheAsBitmap & cacheAsBitmapMatrix




© 2011 Adobe Systems Incorporated.
Rendering Cycles

                  Frame x:


                                     DisplayList




© 2011 Adobe Systems Incorporated.
Rendering Cycles

                  Frame x + 1:
                  2 objects moved
                                                        DisplayList




                                     Transformation Matrix Changed
                                     (translation, rotation, scaling,
                                     skewing)



© 2011 Adobe Systems Incorporated.
Rendering Cycles

                  Frame x + 1:

                                     Flash Player calculates
                                     the dirty region which in turns        DisplayList
                                     will trigger a re-rasterizing of the
                                     affected display objects




© 2011 Adobe Systems Incorporated.
Rendering Cycles

                  Frame x + 2:

                                     In our case all 4 objects will be
                                     rasterized again and bli ed on      DisplayList
                                     the screen




© 2011 Adobe Systems Incorporated.
Understanding cacheAsBitmap

      Rasterizing process can be expensive (even in GPU Vector mode)
      Solution?  DisplayObject.cachAsBitmap = true;
            Objects are rasterized in an offscreen buffer
              e offscreen buffer is bli ed to the main screen buffer when translations are
             applied



       Pitfall:                      DisplayObject.cachAsBitmap = true;

                                                                            Offscreen Buffer




               One Children is changed  all 3 objects
               will be re-rasterized

© 2011 Adobe Systems Incorporated.
Understanding cacheAsBitmap and cacheAsBitmapMatrix


     DisplayObject.cachAsBitmapMatrix = new Matrix();
     (reuse the same Matrix instance across display objects)

                                     Translate   Scale   Rotate    visible=false     Platforms
   cacheAsBitmap                       Yes         -       -             -           FP + AIR
   cacheAsBitmap +
                                       Yes       Yes      Yes          Yes         AIR 2.0 Mobile
   cacheAsBitmapMatrix
   2.5D shapes                         Yes       Yes      Yes            -         AIR 2.0 Mobile



          •  2.5D properties deactivate cacheAsBitmap & cacheBitmapMatrix
          •  Manipulate the regular 2D properties if you don’t want to invalidate the cache




© 2011 Adobe Systems Incorporated.
Caching: Pros & Cons

      Pros:
            If content is expensive to be rasterized (eg. complex vector) caching can help
            GPU Blend usually essential – usually you get be er performances
            CPU & GPU Vector can be a big win


      Cons:
            Increased memory usage  especially caching bitmaps in CPU and GPU Vector
            Depending on the GPU quality (remember devices don’t have the same GPU)




© 2011 Adobe Systems Incorporated.
Different devices – different performances for the same code

      Task: scaling 10 rotating vectors (some red rectangles)



                                               CPU Mode                                   GPU Mode
        Device
                                      cABM                 No cABM                cABM               No cABM
   Droid X                             15fps                 38fps                32fps                45fps
   Nexus One                           27fps                 39fps                39fps                30fps



       cABM means cacheAsBitmapMatrix




                           h p://renaun.com/blog/2010/10/gpu-rendermode-for-air-mobile-pro le-and-caching-clari cation/
© 2011 Adobe Systems Incorporated.
Ge ing Good Performances

      Try your application on the actual device!!!
      FPS (frames per second) is an excellent indicator (24FPS is great)
            h ps://github.com/mrdoob/Hi-ReS-Stats
      Initialization/Rendering stats – log endTime - startTime for different parts of
       your app
      Flash Builder Pro ler
            Memory Consumption
            Methods Performances
             ink early at optimization (as opposed to desktop development)
            Iterate a lot to catch issues early – easier to nd the issues when the application is
             not that big




© 2011 Adobe Systems Incorporated.
Possible Bo leneck Areas

      Object Creation & Destroying:
            Use Pool Objects
            Try avoid using lots objects if reusing/copyPixels is possible



      Rendering :
            Incorrect bitmap caching (cacheAsBitmap & cacheAsBitmapMatrix)
            Filters/Blends/Alpha can heart performance especially for GPU mode (at least for
             now) -> they are applied using CPU


      Heavy ActionScript code execution:
            Break longer tasks across multiple frames



© 2011 Adobe Systems Incorporated.
Flex “Hero” Considerations

  Note:                 ese apply to MAX Flex “Hero” preview release.


      List scrolling not as smooth as the native ones
      Big dataProviders shouldn’t slowdown the app
      Creating skins for the mobile components using MXML Graphics hurts
       performance
      Try using FXG or bitmaps instead of MXML Graphics
      Using transparent lists can heart the performance
      Se ing up renderMode=“gpu” seems to decrease performance




© 2011 Adobe Systems Incorporated.
ank You!

      Renaun Erickson
            h p://tv.adobe.com/watch/max-2010-develop/developing-wellbehaved-mobile-
             applications-for-adobe-air-/
            h p://renaun.com/blog/
      Christian Cantrell - h p://blogs.adobe.com/cantrell/
      Ben Stucki’s MAX Session:
            h p://2010.max.adobe.com/online/2010/MAX126_1288126140366VDFJ

      Adobe Developer Center:
            h p://www.adobe.com/devnet/

                                                                       My Contact Info:
                                                                 mihai.corlan@adobe.com
                                                                        h p://corlan.org

© 2011 Adobe Systems Incorporated.
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential.
Adobe, the Adobe logo, Adobe AIR, the Adobe AIR logo, the Adobe PDF logo, AIR, ColdFusion, ColdFusion Builder, Flash, Flash Builder, the Flash logo, Flex, LiveCycle, and Reader are eithe
                        registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. All other trademarks are the property of their respective owners.
                        © 2010 Adobe Systems Incorporated. All rights reserved. Printed in the USA. 9102xxxx 3/10


Adobe, the Adobe logo, Adobe AIR, the Adobe AIR logo, ActionScript, AIR, Flash, Flash Builder, Flash Catalyst, the Flash logo, Flex, and LiveCycle are either registered trademarks or trademarks of Adobe
Systems Incorporated in the United States and/or other countries. Microso and Windows are either registered trademarks or trademarks of Microso Corporation in the United States and/or other
countries. Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Printed in the USA. 91023957 3/10

© 2011 Adobe Systems Incorporated.

Weitere ähnliche Inhalte

Andere mochten auch

Osvrt Na Adobe Max 2009
Osvrt Na Adobe Max 2009Osvrt Na Adobe Max 2009
Osvrt Na Adobe Max 2009Ivan Ilijasic
 
Adobe Flex Don't Style It, Skin it!
Adobe Flex Don't Style It, Skin it!Adobe Flex Don't Style It, Skin it!
Adobe Flex Don't Style It, Skin it!DevelopmentArc LLC
 
Creating Custom Spark Components in Flex 4
Creating Custom Spark Components in Flex 4Creating Custom Spark Components in Flex 4
Creating Custom Spark Components in Flex 4Dan Orlando
 
David Coletta Architecting A Shared Codebase For Browser And Desktop Final
David Coletta Architecting A Shared Codebase For Browser And Desktop FinalDavid Coletta Architecting A Shared Codebase For Browser And Desktop Final
David Coletta Architecting A Shared Codebase For Browser And Desktop Finaldcoletta
 
P2P vs Sockets: Communication on the Flash Platform
P2P vs Sockets: Communication on the Flash PlatformP2P vs Sockets: Communication on the Flash Platform
P2P vs Sockets: Communication on the Flash Platformboushley
 

Andere mochten auch (6)

Osvrt Na Adobe Max 2009
Osvrt Na Adobe Max 2009Osvrt Na Adobe Max 2009
Osvrt Na Adobe Max 2009
 
Adobe Flex Don't Style It, Skin it!
Adobe Flex Don't Style It, Skin it!Adobe Flex Don't Style It, Skin it!
Adobe Flex Don't Style It, Skin it!
 
Migrating fx3tofx4
Migrating fx3tofx4Migrating fx3tofx4
Migrating fx3tofx4
 
Creating Custom Spark Components in Flex 4
Creating Custom Spark Components in Flex 4Creating Custom Spark Components in Flex 4
Creating Custom Spark Components in Flex 4
 
David Coletta Architecting A Shared Codebase For Browser And Desktop Final
David Coletta Architecting A Shared Codebase For Browser And Desktop FinalDavid Coletta Architecting A Shared Codebase For Browser And Desktop Final
David Coletta Architecting A Shared Codebase For Browser And Desktop Final
 
P2P vs Sockets: Communication on the Flash Platform
P2P vs Sockets: Communication on the Flash PlatformP2P vs Sockets: Communication on the Flash Platform
P2P vs Sockets: Communication on the Flash Platform
 

Ähnlich wie Adobe AIR - Mobile Performance – Tips & Tricks

Well Behaved Mobile Apps on AIR - Performance Related
Well Behaved Mobile Apps on AIR - Performance RelatedWell Behaved Mobile Apps on AIR - Performance Related
Well Behaved Mobile Apps on AIR - Performance RelatedRenaun Erickson
 
Starling基于stage3 d开发gpu加速的2d游戏
Starling基于stage3 d开发gpu加速的2d游戏Starling基于stage3 d开发gpu加速的2d游戏
Starling基于stage3 d开发gpu加速的2d游戏359121504
 
Qualcomm Snapdragon Processors: A Super Gaming Platform
Qualcomm Snapdragon Processors: A Super Gaming Platform Qualcomm Snapdragon Processors: A Super Gaming Platform
Qualcomm Snapdragon Processors: A Super Gaming Platform Qualcomm Developer Network
 
UplinQ - qualcomm® snapdragon™ processors a super gaming platform
UplinQ - qualcomm® snapdragon™ processors a super gaming platformUplinQ - qualcomm® snapdragon™ processors a super gaming platform
UplinQ - qualcomm® snapdragon™ processors a super gaming platformSatya Harish
 
CMP208_Unleash Your Graphics Solutions with the Flexibility of Elastic GPUs
CMP208_Unleash Your Graphics Solutions with the Flexibility of Elastic GPUsCMP208_Unleash Your Graphics Solutions with the Flexibility of Elastic GPUs
CMP208_Unleash Your Graphics Solutions with the Flexibility of Elastic GPUsAmazon Web Services
 
Xebia adobe flash mobile applications
Xebia adobe flash mobile applicationsXebia adobe flash mobile applications
Xebia adobe flash mobile applicationsMichael Chaize
 
CMP213_GPU(G3) Applications in Media and Entertainment Workloads
CMP213_GPU(G3) Applications in Media and Entertainment WorkloadsCMP213_GPU(G3) Applications in Media and Entertainment Workloads
CMP213_GPU(G3) Applications in Media and Entertainment WorkloadsAmazon Web Services
 
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019 Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019 Amazon Web Services
 
Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...
Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...
Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...Intel® Software
 
Wp7 performance challenges
Wp7 performance challengesWp7 performance challenges
Wp7 performance challengesGergely Orosz
 
Siggraph 2016 - Vulkan and nvidia : the essentials
Siggraph 2016 - Vulkan and nvidia : the essentialsSiggraph 2016 - Vulkan and nvidia : the essentials
Siggraph 2016 - Vulkan and nvidia : the essentialsTristan Lorach
 
Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlightrsnarayanan
 
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...Intel® Software
 
Distributed Model Training using MXNet with Horovod
Distributed Model Training using MXNet with HorovodDistributed Model Training using MXNet with Horovod
Distributed Model Training using MXNet with HorovodLin Yuan
 

Ähnlich wie Adobe AIR - Mobile Performance – Tips & Tricks (20)

Well Behaved Mobile Apps on AIR - Performance Related
Well Behaved Mobile Apps on AIR - Performance RelatedWell Behaved Mobile Apps on AIR - Performance Related
Well Behaved Mobile Apps on AIR - Performance Related
 
Starling基于stage3 d开发gpu加速的2d游戏
Starling基于stage3 d开发gpu加速的2d游戏Starling基于stage3 d开发gpu加速的2d游戏
Starling基于stage3 d开发gpu加速的2d游戏
 
Qualcomm Snapdragon Processors: A Super Gaming Platform
Qualcomm Snapdragon Processors: A Super Gaming Platform Qualcomm Snapdragon Processors: A Super Gaming Platform
Qualcomm Snapdragon Processors: A Super Gaming Platform
 
UplinQ - qualcomm® snapdragon™ processors a super gaming platform
UplinQ - qualcomm® snapdragon™ processors a super gaming platformUplinQ - qualcomm® snapdragon™ processors a super gaming platform
UplinQ - qualcomm® snapdragon™ processors a super gaming platform
 
CMP208_Unleash Your Graphics Solutions with the Flexibility of Elastic GPUs
CMP208_Unleash Your Graphics Solutions with the Flexibility of Elastic GPUsCMP208_Unleash Your Graphics Solutions with the Flexibility of Elastic GPUs
CMP208_Unleash Your Graphics Solutions with the Flexibility of Elastic GPUs
 
Xebia adobe flash mobile applications
Xebia adobe flash mobile applicationsXebia adobe flash mobile applications
Xebia adobe flash mobile applications
 
CMP213_GPU(G3) Applications in Media and Entertainment Workloads
CMP213_GPU(G3) Applications in Media and Entertainment WorkloadsCMP213_GPU(G3) Applications in Media and Entertainment Workloads
CMP213_GPU(G3) Applications in Media and Entertainment Workloads
 
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019 Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
 
Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...
Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...
Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...
 
Wp7 performance challenges
Wp7 performance challengesWp7 performance challenges
Wp7 performance challenges
 
Siggraph 2016 - Vulkan and nvidia : the essentials
Siggraph 2016 - Vulkan and nvidia : the essentialsSiggraph 2016 - Vulkan and nvidia : the essentials
Siggraph 2016 - Vulkan and nvidia : the essentials
 
Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlight
 
Adobe Salon Linux
Adobe Salon LinuxAdobe Salon Linux
Adobe Salon Linux
 
Flex User Group breton
Flex User Group bretonFlex User Group breton
Flex User Group breton
 
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
 
Distributed Model Training using MXNet with Horovod
Distributed Model Training using MXNet with HorovodDistributed Model Training using MXNet with Horovod
Distributed Model Training using MXNet with Horovod
 
Adobe MAX Recap
Adobe MAX RecapAdobe MAX Recap
Adobe MAX Recap
 
BSC LMS DDL
BSC LMS DDL BSC LMS DDL
BSC LMS DDL
 
air
airair
air
 
PPT Example
PPT ExamplePPT Example
PPT Example
 

Mehr von Mihai Corlan

PhoneGap Session at Multi-Mania.be 2013
PhoneGap Session at Multi-Mania.be 2013PhoneGap Session at Multi-Mania.be 2013
PhoneGap Session at Multi-Mania.be 2013Mihai Corlan
 
Adobe Shadow - Amsterdam Adobe Camp
Adobe Shadow - Amsterdam Adobe CampAdobe Shadow - Amsterdam Adobe Camp
Adobe Shadow - Amsterdam Adobe CampMihai Corlan
 
PhoneGap/PhoneGap Build - Amsterdam Adobe Camp
PhoneGap/PhoneGap Build - Amsterdam Adobe CampPhoneGap/PhoneGap Build - Amsterdam Adobe Camp
PhoneGap/PhoneGap Build - Amsterdam Adobe CampMihai Corlan
 
Introduction to Adobe Brackets
Introduction to Adobe BracketsIntroduction to Adobe Brackets
Introduction to Adobe BracketsMihai Corlan
 
Getting started with PhoneGap
Getting started with PhoneGapGetting started with PhoneGap
Getting started with PhoneGapMihai Corlan
 
Introduction to Adobe Shadow
Introduction to Adobe ShadowIntroduction to Adobe Shadow
Introduction to Adobe ShadowMihai Corlan
 
Starting mobile development
Starting mobile developmentStarting mobile development
Starting mobile developmentMihai Corlan
 
Debugging mobile websites and web apps
Debugging mobile websites and web appsDebugging mobile websites and web apps
Debugging mobile websites and web appsMihai Corlan
 
Mobile Development With Flash Platform
Mobile Development With Flash PlatformMobile Development With Flash Platform
Mobile Development With Flash PlatformMihai Corlan
 
Getting started with flash mobile development
Getting started with flash mobile developmentGetting started with flash mobile development
Getting started with flash mobile developmentMihai Corlan
 
Flash Builder for PHP and Mobile development
Flash Builder for PHP and Mobile developmentFlash Builder for PHP and Mobile development
Flash Builder for PHP and Mobile developmentMihai Corlan
 
Android Development with Flash Platform
Android Development with Flash PlatformAndroid Development with Flash Platform
Android Development with Flash PlatformMihai Corlan
 
Adobe AIR Mobile development for Android and PlayBook
Adobe AIR Mobile development for Android and PlayBookAdobe AIR Mobile development for Android and PlayBook
Adobe AIR Mobile development for Android and PlayBookMihai Corlan
 

Mehr von Mihai Corlan (14)

PhoneGap Session at Multi-Mania.be 2013
PhoneGap Session at Multi-Mania.be 2013PhoneGap Session at Multi-Mania.be 2013
PhoneGap Session at Multi-Mania.be 2013
 
Adobe Shadow - Amsterdam Adobe Camp
Adobe Shadow - Amsterdam Adobe CampAdobe Shadow - Amsterdam Adobe Camp
Adobe Shadow - Amsterdam Adobe Camp
 
PhoneGap/PhoneGap Build - Amsterdam Adobe Camp
PhoneGap/PhoneGap Build - Amsterdam Adobe CampPhoneGap/PhoneGap Build - Amsterdam Adobe Camp
PhoneGap/PhoneGap Build - Amsterdam Adobe Camp
 
Introduction to Adobe Brackets
Introduction to Adobe BracketsIntroduction to Adobe Brackets
Introduction to Adobe Brackets
 
Getting started with PhoneGap
Getting started with PhoneGapGetting started with PhoneGap
Getting started with PhoneGap
 
PhoneGap/Cordova
PhoneGap/CordovaPhoneGap/Cordova
PhoneGap/Cordova
 
Introduction to Adobe Shadow
Introduction to Adobe ShadowIntroduction to Adobe Shadow
Introduction to Adobe Shadow
 
Starting mobile development
Starting mobile developmentStarting mobile development
Starting mobile development
 
Debugging mobile websites and web apps
Debugging mobile websites and web appsDebugging mobile websites and web apps
Debugging mobile websites and web apps
 
Mobile Development With Flash Platform
Mobile Development With Flash PlatformMobile Development With Flash Platform
Mobile Development With Flash Platform
 
Getting started with flash mobile development
Getting started with flash mobile developmentGetting started with flash mobile development
Getting started with flash mobile development
 
Flash Builder for PHP and Mobile development
Flash Builder for PHP and Mobile developmentFlash Builder for PHP and Mobile development
Flash Builder for PHP and Mobile development
 
Android Development with Flash Platform
Android Development with Flash PlatformAndroid Development with Flash Platform
Android Development with Flash Platform
 
Adobe AIR Mobile development for Android and PlayBook
Adobe AIR Mobile development for Android and PlayBookAdobe AIR Mobile development for Android and PlayBook
Adobe AIR Mobile development for Android and PlayBook
 

Adobe AIR - Mobile Performance – Tips & Tricks

  • 1. Mobile Performance – Tips & Tricks Mihai Corlan | Developer Evangelist | h p://corlan.org © 2011 Adobe Systems Incorporated.
  • 2. Agenda   Focus on AIR development for Android and iOS   Understanding Mobile Landscape   CPU vs GPU mode   Flex “Hero” considerations © 2011 Adobe Systems Incorporated.
  • 3. Multiscreen Landscape   Adobe AIR Runtimes for:   Desktop   Mobile & Tablet   Digital Home (TV, Set-top boxes)   Hardware: User Expectations:   CPU from 500MHz to 2GHz dual core; •  Responsive Apps ARM to x86 •  Beautiful Apps   GPU from OpenGL ES 1.1 to 2.0   RAM from 128MB to 1GB+   Screen Resolution & DPI 800 x 480 & 254 ppi / 3.7” 1024 x 600 & 170 ppi / 7” © 2011 Adobe Systems Incorporated.
  • 4. Mobile CPU/GPU Differences m t/s – millions of triangles per second h p://alienbabeltech.com/main/?p19309 © 2011 Adobe Systems Incorporated.
  • 5. General Performance Tricks © 2011 Adobe Systems Incorporated.
  • 6. Where you can optimize? Heavy Code Rendering See Ted Patrick / Sean Christman posts on Elastic Racetrack © 2011 Adobe Systems Incorporated.
  • 7. DisplayList – Choosing the Right DisplayObject Type Less 236 Shape/Bitmap Bytes DisplayList MEMORY 414 Sprite Bytes 440 MovieClip Bytes More © 2011 Adobe Systems Incorporated.
  • 8. General Optimizations Tricks Apply to Mobile   Keep the DisplayList as simple as possible (BitmapData.copyPixels() and Mark & Sweep/Garbage Collection)   Avoid Memory Leaks (Remove Event Listeners / Weak References)   Avoid Memory Fragmentation (data models: using a large object instead of lots of small objects)   Pool of Objects (avoid object creation especially for UI) © 2011 Adobe Systems Incorporated.
  • 9. Mobile Render Mode © 2011 Adobe Systems Incorporated.
  • 10. AIR Pro les © 2011 Adobe Systems Incorporated.
  • 11. Mobile Render Mode   You can choose:   CPU Mode   GPU Mode   Auto Mode ( for now it defaults to CPU Mode)   In Flash Builder: <!– Application Descriptor File --> <initialWindow> <renderMode>gpu</renderMode> </initialWindow> © 2011 Adobe Systems Incorporated.
  • 12. Understanding GPU Mode ere are two different stages where the GPU can be used for rendering:   Rasterizing – rendering graphic elements into a pixel buffer   Scene Composing – arranging pixel buffers Today’s AIR Mobile GPU Modes: Render GPU Type Rasterizing Composing AIR Mobile Mode Version Platforms CPU - CPU CPU All All GPU Blend* CPU GPU 2.0 iOS GPU GPU Vector GPU GPU 2.5 Android * iOS will have GPU Rasterizing support in the future © 2011 Adobe Systems Incorporated.
  • 13. GPU Blend vs. GPU Vector   GPU Blend:   Rasterizing  CPU Pixels are copied from the System Memory   Composing  GPU to the GPU Memory (expensive operation)   GPU Vector:   Rasterizing  GPU Pixels don’t need to be copied   Composing  GPU © 2011 Adobe Systems Incorporated.
  • 14. Understanding Caching: cacheAsBitmap & cacheAsBitmapMatrix © 2011 Adobe Systems Incorporated.
  • 15. Rendering Cycles Frame x: DisplayList © 2011 Adobe Systems Incorporated.
  • 16. Rendering Cycles Frame x + 1: 2 objects moved DisplayList Transformation Matrix Changed (translation, rotation, scaling, skewing) © 2011 Adobe Systems Incorporated.
  • 17. Rendering Cycles Frame x + 1: Flash Player calculates the dirty region which in turns DisplayList will trigger a re-rasterizing of the affected display objects © 2011 Adobe Systems Incorporated.
  • 18. Rendering Cycles Frame x + 2: In our case all 4 objects will be rasterized again and bli ed on DisplayList the screen © 2011 Adobe Systems Incorporated.
  • 19. Understanding cacheAsBitmap   Rasterizing process can be expensive (even in GPU Vector mode)   Solution?  DisplayObject.cachAsBitmap = true;   Objects are rasterized in an offscreen buffer   e offscreen buffer is bli ed to the main screen buffer when translations are applied Pitfall: DisplayObject.cachAsBitmap = true; Offscreen Buffer One Children is changed  all 3 objects will be re-rasterized © 2011 Adobe Systems Incorporated.
  • 20. Understanding cacheAsBitmap and cacheAsBitmapMatrix DisplayObject.cachAsBitmapMatrix = new Matrix(); (reuse the same Matrix instance across display objects) Translate Scale Rotate visible=false Platforms cacheAsBitmap Yes - - - FP + AIR cacheAsBitmap + Yes Yes Yes Yes AIR 2.0 Mobile cacheAsBitmapMatrix 2.5D shapes Yes Yes Yes - AIR 2.0 Mobile •  2.5D properties deactivate cacheAsBitmap & cacheBitmapMatrix •  Manipulate the regular 2D properties if you don’t want to invalidate the cache © 2011 Adobe Systems Incorporated.
  • 21. Caching: Pros & Cons   Pros:   If content is expensive to be rasterized (eg. complex vector) caching can help   GPU Blend usually essential – usually you get be er performances   CPU & GPU Vector can be a big win   Cons:   Increased memory usage  especially caching bitmaps in CPU and GPU Vector   Depending on the GPU quality (remember devices don’t have the same GPU) © 2011 Adobe Systems Incorporated.
  • 22. Different devices – different performances for the same code   Task: scaling 10 rotating vectors (some red rectangles) CPU Mode GPU Mode Device cABM No cABM cABM No cABM Droid X 15fps 38fps 32fps 45fps Nexus One 27fps 39fps 39fps 30fps cABM means cacheAsBitmapMatrix h p://renaun.com/blog/2010/10/gpu-rendermode-for-air-mobile-pro le-and-caching-clari cation/ © 2011 Adobe Systems Incorporated.
  • 23. Ge ing Good Performances   Try your application on the actual device!!!   FPS (frames per second) is an excellent indicator (24FPS is great)   h ps://github.com/mrdoob/Hi-ReS-Stats   Initialization/Rendering stats – log endTime - startTime for different parts of your app   Flash Builder Pro ler   Memory Consumption   Methods Performances   ink early at optimization (as opposed to desktop development)   Iterate a lot to catch issues early – easier to nd the issues when the application is not that big © 2011 Adobe Systems Incorporated.
  • 24. Possible Bo leneck Areas   Object Creation & Destroying:   Use Pool Objects   Try avoid using lots objects if reusing/copyPixels is possible   Rendering :   Incorrect bitmap caching (cacheAsBitmap & cacheAsBitmapMatrix)   Filters/Blends/Alpha can heart performance especially for GPU mode (at least for now) -> they are applied using CPU   Heavy ActionScript code execution:   Break longer tasks across multiple frames © 2011 Adobe Systems Incorporated.
  • 25. Flex “Hero” Considerations Note: ese apply to MAX Flex “Hero” preview release.   List scrolling not as smooth as the native ones   Big dataProviders shouldn’t slowdown the app   Creating skins for the mobile components using MXML Graphics hurts performance   Try using FXG or bitmaps instead of MXML Graphics   Using transparent lists can heart the performance   Se ing up renderMode=“gpu” seems to decrease performance © 2011 Adobe Systems Incorporated.
  • 26. ank You!   Renaun Erickson   h p://tv.adobe.com/watch/max-2010-develop/developing-wellbehaved-mobile- applications-for-adobe-air-/   h p://renaun.com/blog/   Christian Cantrell - h p://blogs.adobe.com/cantrell/   Ben Stucki’s MAX Session:   h p://2010.max.adobe.com/online/2010/MAX126_1288126140366VDFJ   Adobe Developer Center:   h p://www.adobe.com/devnet/ My Contact Info: mihai.corlan@adobe.com h p://corlan.org © 2011 Adobe Systems Incorporated.
  • 27. © 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential.
  • 28. Adobe, the Adobe logo, Adobe AIR, the Adobe AIR logo, the Adobe PDF logo, AIR, ColdFusion, ColdFusion Builder, Flash, Flash Builder, the Flash logo, Flex, LiveCycle, and Reader are eithe registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. All other trademarks are the property of their respective owners. © 2010 Adobe Systems Incorporated. All rights reserved. Printed in the USA. 9102xxxx 3/10 Adobe, the Adobe logo, Adobe AIR, the Adobe AIR logo, ActionScript, AIR, Flash, Flash Builder, Flash Catalyst, the Flash logo, Flex, and LiveCycle are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. Microso and Windows are either registered trademarks or trademarks of Microso Corporation in the United States and/or other countries. Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries. All other trademarks are the property of their respective owners. Printed in the USA. 91023957 3/10 © 2011 Adobe Systems Incorporated.