Flash Iphone Fitc 2010


Published on

Published in: Technology, News & Politics
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Flash Iphone Fitc 2010

  1. 1. Building High Performance iPhone Applications with Flash CS5 Mike Chambers Principal Product Manager Developer Relations Flash Platform
  2. 2. Flash Pro CS5 Adobe Flash CS5 will include support for packaging stand-alone apps for the Apple iPhone
  3. 3. Flash Player 10.1 Smartphone enabled Multitouch, accelerometer, screen orientation Optimized memory, power, hardware acceleration RAW Microphone Access Global Error Handler Public Beta on Labs Now! Announcement #2 : Flash Player 10.1 - Browser, Desktop (via Adobe AIR 2.0), and smart phones
  4. 4. New APIs • MultiTouch • Screen Orientation • MediaLibrary NEW ! • Accelerometer • Geo-location • Cut / Copy / Paste • Native TextInput • tel:, mailto:, maps:, video: Not necessarily iPhone specific APIs.
  5. 5. Flash Player 10.1 will be available across both browsers, desktops and devices. This includes in Adobe AIR 2.0, as well as Flash Player for Palm Pre, Android and Windows Mobile devices.
  6. 6. No Flash Player for Safari Mobile on iPhone Basically, we need apple’s help with this. However, as the Palm Pre and Android Flash Player demos have shown, Flash content can perform well on this class of devices.
  7. 7. Already a number of iphone applications created with Flash on the itunes app store.
  8. 8. demo
  9. 9. How does it work?
  10. 10. LLVM Low Level Virtual Machine Open source compiler infrastructure designed for optimizing programs written in arbitrary programming languages Capable of generating machine code for various targets including x86 and ARM processors Used in Alchemy http://www.llvm.org
  11. 11. Front End Compilation / Optimization Back End SWF / x86 ABC C ARM C++ LLVM PPC Java Spark ... ... Adobe built a SWF / ABC front-end for LLVM
  12. 12. Develop Publish Package Deploy Certificate SWF app.xml PFI .ipa Flash Pro CS5 app:/resources Publishing workflow
  13. 13. AOT Compilation • Ahead of Time (AOT) compilation • iPhone License Restricts interpreters • Cant JIT code • No Interpreter • Compiles ABC bytecode from SWF • LLVM Base compile toolchain
  14. 14. PFI Certificate .app SWF AOT “swf.exe” .ipa Sign / app.xml .plist gen info.plist Signed Package .app resources app:/resources ADT input and output
  15. 15. AOT Compilation Flash CS5 .swf AOT swf.exe swf AS3 ABC1 ABC Compiler ABC1 SHA1 AS3 ABC2 ABC1 SHA2 SWC LLVM Bytecode timeline timeline timeline assets assets LLVM assets Codegen ARM Flash Runtime Flash Runtime Library Library AOT Compilation. Notice that there is a library form of the Flash Player runtime included in the application. ABC bytecode is compiled to native arm code.
  16. 16. Developing Content
  17. 17. APIs Flash Player 10.1 Adobe AIR 2.0 APIs set available is based on Flash Player 10.1 and Adobe AIR 2.0
  18. 18. Development Workflow Flash CS5 Test SWF Test and Deploy Desktop .ipa iTunes Device
  19. 19. In order to deploy an ipa / app to the device, you must be part of the Apple developer program, and have the appropriate certificates and provisioning profiles setup.
  20. 20. Demo
  21. 21. Performance Tips and Tricks • Most will improve performance / memory usage on desktop • General ActionScript performance techniques also apply to device
  22. 22. != iPhone development is mobile development. It has a significantly slower processor that what you are used to on your desktop.
  23. 23. Screen Size UI Interactions Performance != This affects Screen Size, UI Interactions and most importantly performance. We will focus on performance.
  24. 24. Test and Profile Code Profile External Application Profile external SWFs from Flash / Flex Builder. Profile Prospective > Profile > Profile External Application
  25. 25. AS3 Performance Testing Harness Grant Skinner bit.ly/as3performance Make sure to test optimization results.
  26. 26. Remote Device Debugging from Flash CS5 Debug > Begin Remote Debug Session > ActionScript 3
  27. 27. Mac Only
  28. 28. Instruments Mac Only
  29. 29. Shark Mac Only
  30. 30. Simple Game Framework github.com/mikechambers
  31. 31. Rendering • Hardware Composition is available for DisplayObjects • Can greatly improve performance • Uses OpenGL ES-1 • APIs will be available on additional platforms
  32. 32. Software Rendering Software rendering renders entire display (including composition) via software. CPU intensive.
  33. 33. GPU Compositing CPU Composition. Individual elements rendered via software, but are then composited / put together in hardware. Can be very fast.
  34. 34. GPU Pipeline with Cached Surfaces GPU Pipeline with cached surfaces Flash renderer (RAM) Textures (GPU) Individual elements can be cached and then composited in hardware.
  35. 35. Using GPU Composition • cacheAsBitmap:Boolean NEW ! • cacheAsBitmapMatrix:Matrix • Using 2.5D Apis • Such as setting z property cacheAsSurface new API. Transforms on a display object does not cause it to be re-rendered via software.
  36. 36. cacheAsBitmap cacheAsBitmap cacheAsBitmapMatrix • Geometric Translations • Geometric Dilation • Changes in X / Y • Rotation • Tweens • Scaling
  37. 37. • Can set cacheAsBitmap in IDE or Code • Have to subclass DisplayObject to set cacheAsBitmapMatrix (can’t set in IDE) • SGF : CachedSprite.as
  38. 38. Debugging HWA CTTextureUploadTracking
  39. 39. Use GPU!!! • Hardware accelerate everything • Except for items that re-draw often • Break up display objects to minimize re- draws • Don’t cache clips that have children that move / change • Keep display list shallow
  40. 40. Prevent Redraws • Items moving over non-cached DisplayObjects • Visual content changes • Drawing API • Children moving / changing • ColorTransformations • Removing from display list
  41. 41. Minimize Instance Allocations • Reuse object instances • Memory Allocation very expensive • Reduces Garbage collection • Reduces CPU / Initialization costs
  42. 42. Object Pooling • Reuses Object instances • Avoid constant initialization and garbage collection • Particularly useful for DisplayObjects composited by GPU
  43. 43. Pooling DisplayObjects • Re-use cached DisplayObjects • Keep on stage (off screen) • Can give major performance boosts • PewPew
  44. 44. GameObjectPool.as SoundManager.as
  45. 45. Time Management • In General, ENTER_FRAME performs better than Timer • Use single listener, and then dispatch • SGF : TickManager.as
  46. 46. Event Dispatching • Can be very expensive • Requires several memory allocations • Consider using callbacks in CPU intensive areas • Consider Reusing Event instances
  47. 47. Event Propagation • Can be very expensive, especially on display list instances. • Event.stopPropagation(); • Event.stopImmediatePropagation();
  48. 48. Mouse / Touch Events • Can disable with • mouseEnabled • mouseChildren • Don’t use MouseEvent.MOUSE_MOVE • Check Mouse position at interval • Example
  49. 49. Can listen for MOUSE_UP MOUSE_DOWN events to toggle
  50. 50. Optimizing Mobile Content for the Adobe Flash Platform Thibault Imbert bytearray.org/?p=1363
  51. 51. Mike Chambers www.mikechambers.com twitter.com/mesh mesh@adobe.com All links at : http://www.mikechambers.com/blog/2009/10/17/resources-for-learning- more-about-flash-to-iphone/
  52. 52. Baby Crying http://www.flickr.com/photos/bbaunach/1055569383/ Photo credit.