Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Image handling in Android

1,176 views

Published on

How to stop images from crashing your Android app
Talk given at Devoxx London, June 13, 2014.

Published in: Technology, Art & Photos

Image handling in Android

  1. 1. @tyronen#facebook Image handling in Android Tyrone Nicholas @tyronen tnicholas@fb.com
  2. 2. @tyronen#facebook •~1/10 device RAM •480 x 800 = 1.5 MB
  3. 3. @tyronen#facebook GC
  4. 4. java.lang.OutOfMemoryError
  5. 5. @tyronen#facebook Android heaps Dalvik •JDK •Limited •Slow •Safe Other •Certain system calls •Like native Native •NDK •Unlimited •Fast •Unsafe
  6. 6. @tyronen#facebook What to do with images?
  7. 7. @tyronen#facebook An image pipeline WebP BMP BMP JPG JPG JPG UI thread Non-UI threads
  8. 8. @tyronen#facebook Copying heap to heap
  9. 9. @tyronen#facebook Using native heap from Java
  10. 10. @tyronen#facebook Bitmaps
  11. 11. @tyronen#facebook Ashmem • create • pin • unpin
  12. 12. @tyronen#facebook Purgeable bitmaps DrawDraw DecodeDecode PinPin Stop drawing Stop drawing UnpinUnpin
  13. 13. @tyronen#facebook Using Purgeable Bitmaps
  14. 14. @tyronen#facebook Er, wait a minute…
  15. 15. @tyronen#facebook Solution #3 – Bitmap Pooling
  16. 16. @tyronen#facebook Hang on…
  17. 17. @YourTwitterHandle#DVXFR14{session hashtag} @tyronen#facebook Facebook ’s solution
  18. 18. @tyronen#facebook From the Android NDK
  19. 19. @tyronen#facebook Create a new method…
  20. 20. @tyronen#facebook …and use it
  21. 21. @tyronen#facebook But afterwards…
  22. 22. @YourTwitterHandle#DVXFR14{session hashtag} @tyronen#facebook Q & A tnicholas@fb.com @tyronen

×