Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PERFMATTERS for Android

Hasan Hosgel
November 06, 2015

PERFMATTERS for Android

The slogan '#PERFMATTERS' by Colt McAnlis is one of the most important statements, which an Android developer should follow. A well performing application makes the difference between a nice looking application and one, which gets successful. You, as an Android developer, have the responsibility to delight your users, so they don't feel how much work your application has to burden to fulfill the user's needs. This session will show you some easy optimizations and how to avoid glitches in the application. A lot of developers would shout, that this is premature optimization. In contrary it is preventive. With a small amount of work while developing you can avoid a lot of pitfalls. You will hopefully have a better understanding of the underlying system afterwards. During the session some tools and frameworks will be presented for helping you to fulfill your mission.

Hasan Hosgel

November 06, 2015
Tweet

More Decks by Hasan Hosgel

Other Decks in Technology

Transcript

  1. Why we are developers? GDG DevFest Hamburg 6th November 2015

    #PERFMATTERS for Android – Hasan Hosgel
  2. Why we are developers? ESPECIALLY ANDROID GDG DevFest Hamburg 6th

    November 2015 #PERFMATTERS for Android – Hasan Hosgel
  3. We have Passion GDG DevFest Hamburg Photo by Sujaki-F 6th

    November 2015 #PERFMATTERS for Android – Hasan Hosgel
  4. User Expectations •  Mobile App Users are impatient on applications

    Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  5. User Expectations •  Mobile App Users are impatient •  61%

    app start < 4 s on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  6. User Expectations •  Mobile App Users are impatient •  61%

    app start < 4 s •  49% app start < 2 s on applications GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  7. User Expectations •  Mobile App Users are impatient •  61%

    app start < 4 s •  49% app start < 2 s •  Users are intolerant of issues and are quick to uninstall mobile apps on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  8. User Expectations •  Mobile App Users are impatient •  61%

    app start < 4 s •  49% app start < 2 s •  Users are intolerant of issues and are quick to uninstall mobile apps •  80% three attempts or less on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  9. User Expectations •  Mobile App Users are impatient •  61%

    app start < 4 s •  49% app start < 2 s •  Users are intolerant of issues and are quick to uninstall mobile apps •  80% three attempts or less •  53% apps with severe issues like crashes, freezes or errors on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  10. User Expectations •  Mobile App Users are impatient •  61%

    app start < 4 s •  49% app start < 2 s •  Users are intolerant of issues and are quick to uninstall mobile apps •  80% three attempts or less •  53% apps with severe issues like crashes, freezes or errors •  36% heavy battery usage on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  11. User Expectations •  Mobile App Users are impatient •  61%

    app start < 4 s •  49% app start < 2 s •  Users are intolerant of issues and are quick to uninstall mobile apps •  80% three attempts or less •  53% apps with severe issues like crashes, freezes or errors •  36% heavy battery usage •  Users blame the app and the company who made it on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  12. User Expectations •  Mobile App Users are impatient •  61%

    app start < 4 s •  49% app start < 2 s •  Users are intolerant of issues and are quick to uninstall mobile apps •  80% three attempts or less •  53% apps with severe issues like crashes, freezes or errors •  36% heavy battery usage •  Users blame the app and the company who made it •  55% app is responsible for performance issues on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  13. User Expectations •  Mobile App Users are impatient •  61%

    app start < 4 s •  49% app start < 2 s •  Users are intolerant of issues and are quick to uninstall mobile apps •  80% three attempts or less •  53% apps with severe issues like crashes, freezes or errors •  36% heavy battery usage •  Users blame the app and the company who made it •  55% app is responsible for performance issues •  37% Stated that app crashes or errors make them think less of a company’s brand on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  14. Performance Impacts •  500 ms delay •  bounce rate -4.7%

    •  conversion rate -1.9% Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  15. Performance Impacts •  500 ms delay •  bounce rate -4.7%

    •  conversion rate -1.9% •  1,000 ms delay •  bounce rate -8.3% •  Conversion rate -3.5% Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  16. Performance Impacts •  500 ms delay •  bounce rate -4.7%

    •  conversion rate -1.9% •  1,000 ms delay •  bounce rate -8.3% •  Conversion rate -3.5% •  100ms delay mean for Amazon -1% revenue Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  17. Performance Impacts •  500 ms delay •  bounce rate -4.7%

    •  conversion rate -1.9% •  1,000 ms delay •  bounce rate -8.3% •  Conversion rate -3.5% •  100ms delay mean for Amazon -1% revenue •  11% scream at there device Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  18. Performance Impacts •  500 ms delay •  bounce rate -4.7%

    •  conversion rate -1.9% •  1,000 ms delay •  bounce rate -8.3% •  Conversion rate -3.5% •  100ms delay mean for Amazon -1% revenue •  11% scream at there device •  4 % throw their phones Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg https://www.flickr.com/photos/9009139@N08/1263954439 GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  19. Possible improvements CPU Memory I/O GDG DevFest Hamburg 6th November

    2015 #PERFMATTERS for Android – Hasan Hosgel
  20. Possible improvements CPU Memory I/O •  Keep the work of

    the main thread à ANR GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  21. Possible improvements CPU Memory I/O •  Keep the work of

    the main thread à ANR •  Avoid GPU overdrawings •  https://www.youtube.com/watch?v=T52v50r-JfE GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  22. Possible improvements CPU Memory I/O •  Keep the work of

    the main thread à ANR •  Avoid GPU overdrawings •  https://www.youtube.com/watch?v=T52v50r-JfE •  Avoid nested multi-pass layouts •  http://goo.gl/Q5te24 GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  23. Possible improvements CPU Memory I/O •  Keep the work of

    the main thread à ANR •  Avoid GPU overdrawings •  https://www.youtube.com/watch?v=T52v50r-JfE •  Avoid nested multi-pass layouts •  http://goo.gl/Q5te24 •  Consider RenderScript for performance critical code GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  24. Possible improvements CPU Memory I/O •  Do not allocate memory

    inside onDraw() GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  25. Possible improvements CPU Memory I/O •  Do not allocate memory

    inside onDraw() •  Check for leaks •  LeakCanary à https://github.com/square/leakcanary GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  26. Use Your Debug Build Normally GDG DevFest Hamburg 6th November

    2015 #PERFMATTERS for Android – Hasan Hosgel
  27. Possible improvements CPU Memory I/O •  Do not allocate memory

    inside onDraw() •  Check for leaks •  LeakCanary à https://github.com/square/leakcanary GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  28. Possible improvements CPU Memory I/O •  Do not allocate memory

    inside onDraw() •  Check for leaks •  LeakCanary à https://github.com/square/leakcanary •  Avoid listener à EventBus GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  29. Possible improvements CPU Memory I/O •  Do not allocate memory

    inside onDraw() •  Check for leaks •  LeakCanary à https://github.com/square/leakcanary •  Avoid listener à EventBus •  Use SparseArray* family instead of JDK Collections/ Maps GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  30. Possible improvements CPU Memory I/O •  Do not allocate memory

    inside onDraw() •  Check for leaks •  LeakCanary à https://github.com/square/leakcanary •  Avoid listener à EventBus •  Use SparseArray* family instead of JDK Collections/ Maps •  Be aware that enums need more resource, but use them, if it will make sense for you GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  31. Possible improvements CPU Memory I/O •  Activate gzip compression on

    incoming and outgoing network traffic or FlatBuffer à  FlatBuffer: https://www.youtube.com/watch?v=iQTxMkSJ1dQ GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  32. Possible improvements CPU Memory I/O •  Activate gzip compression on

    incoming and outgoing network traffic or FlatBuffer à FlatBuffer: https://www.youtube.com/watch?v=iQTxMkSJ1dQ •  Cache data on disk (image, http responses) with reasonable TTL •  Reasonable TTL •  Server side cache headers like ETag & Last-Modified GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  33. Second Start With Caching GDG DevFest Hamburg 6th November 2015

    #PERFMATTERS for Android – Hasan Hosgel
  34. Possible improvements CPU Memory I/O •  Activate gzip compression on

    incoming and outgoing network traffic or FlatBuffer à FlatBuffer: https://www.youtube.com/watch?v=iQTxMkSJ1dQ •  Cache data on disk (image, http responses) with reasonable TTL •  Reasonable TTL •  Server side cache headers like ETag & Last-Modified •  Use JobScheduler API to batch across system or better use push notifications for updateinformation GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  35. Optimize Moar – The Loop GDG DevFest Hamburg 6th November

    2015 #PERFMATTERS for Android – Hasan Hosgel
  36. Optimize Moar – The Loop GDG DevFest Hamburg 6th November

    2015 #PERFMATTERS for Android – Hasan Hosgel
  37. Optimize Moar – The Loop GDG DevFest Hamburg 6th November

    2015 #PERFMATTERS for Android – Hasan Hosgel
  38. Optimize Moar – The Loop GDG DevFest Hamburg 6th November

    2015 #PERFMATTERS for Android – Hasan Hosgel
  39. GDG DevFest Hamburg https://speakerdeck.com/alosdev/perfmatters-for-android Contact: +HasanHosgel alosdev Thanks for your

    Attention! We are hiring: http://www.kitchenstories.de/#jobs 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel
  40. GDG DevFest Hamburg https://speakerdeck.com/alosdev/perfmatters-for-android Contact: +HasanHosgel alosdev Thanks for your

    Attention! We are hiring: http://www.kitchenstories.de/#jobs 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel