In this episode of Fragmented, Donn and Kaushik start off by discussing the tips and tricks available for efficiently loading images in an Android app. Good image libraries make use of these techniques and perform all the heavy lifting in the background. So they then discuss the different image library options available for Android developers.
Show Notes
Techniques/tips on effective image rendering in Android:
Bitmap sizes and allocation:
- Displaying bitmaps efficiently [developer.android.com]
- RGB_565, ARGB_888 and other different bitmap configurations [developer.android.com]
- Android Camera2 apis [developer.android.com]
- Chet Haase DevByte : Bitmap allocation [youtube.com] (bitmaps managed in Dalvik heap post 3.0; so large bitmaps implies large heap implies GC could happen more often)
Reuse bitmaps:
- inBitmap option for Android 3.0 and later [developer.android.com]
- before Android 4.4 only equal sized bitmaps with inSampleSize 1 supported [developer.android.com]
- Reusing bitmap objects on Android[booking.com]
Downsample bitmaps
- Load a scaled down version into memory [developer.android.com]
- see code for calculateInSampleSize
Caching
- Cache Algorithms – see LruCache [wikipedia.org]
- LruCache object in Android [developer.android.com]
- JakeWharton DiskLruCache [github.com]
- Don’t use Soft or Weak References for your Caches [developer.android.com]
- Android Performance Pattern DevByte – why 60fps [youtube.com]
Image libraries for Android:
- Picasso by Square [github.com]
- fetch introduced in V 2.5.0 (Changelog) [github.com]
- Picasso doesn’t do bitmap recycling
- Jake Wharton’s thoughts on Picasso not having a bitmap pool [github.com]
- Glide [github.com]
- Ion
- DeepZoom with Ion [youtube.com]
- Uses BitmapRegionDecoder to implement DeepZoom [developer.android.com]
- Volley
- Ficus Kirkpatrick introduces Volley in Google.IO [youtube.com]
- Doesn’t come with an image caching mechansim out of the box [stackoverflow.com]
- Fresco
- Introducing Fresco [code.facebook.com]
- Romain Guy concern over native api call [twitter.com]
- Other noteworthies that we did not discuss:
- Universal Image Loader Library comparisons by others:
- Picasso vs Glide [inthecheesefactory.com]
Image library comparisons:
- JesseWilson on Picasso vs Fresco :P [twitter.com]
- JesseWilson Picasso:Glide :: Coke:Pepsi [twitter.com]
- Image comparisons by Koushik Dutta [plus.google.com]
- Volley vs Picasso [bignerdranch.com]
Awesome picks:
- Donn
- KG:
Contact
Donn Felker
- @donnfelker [twitter.com]
- donnfelker.com
Kaushik Gopal
- @kaushikgopal [twitter.com]
- kaush.co