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

Rev Up Your App: Mastering Android Startup Time...

Rev Up Your App: Mastering Android Startup Time Optimization

In this talk, we will explore what makes an app launch slower, how to find and fix those issues, and why faster startup times are important for both users and app success. Using practical tips and examples, we’ll explore strategies that can make a real difference in delivering a smoother, quicker experience from the first tap.

Dimitris Konomis

December 06, 2024
Tweet

Other Decks in Programming

Transcript

  1. • Identify bottlenecks that may cause delays during startup WHAT

    • Measure before and after • We need benchmarks androidx.benchmark:benchmark-macro-junit4:x.x.x
  2. • Always run benchmarks tests on a physical device using

    a production build. This ensures accurate results and prevents false positives caused by debug-only tools or emulators ADDITIONAL TIP
  3. HOW

  4. • Be aware of hidden costs: Libraries may auto-initialise on

    app start LAZY LOAD EXTERNAL LIBRARIES • Search merged manifest for added initialisers • Disable initialisers through manifest
  5. • Not all external libraries can be lazy-loaded to improve

    startup time. Some cannot be disabled due to internal or obfuscated code • Always check the libraryʼs initialization process to decide if it can be safely deferred without affecting essential functionality ADDITIONAL TIP
  6. • Avoid creating multiple classes at once OPTIMISE DEPENDENCY INJECTION

    • Limit injections in custom Application and Launcher activity classes • Use Lazy Injection instead. Create dependencies when they're needed
  7. • Classes that arenʼt critical for initial user experience but

    will be needed at a later point (after launch) could be lazy injected and created in IO thread, in order to avoid the added overhead. ADDITIONAL TIP • Lazy injection adds a small overhead. Evaluate if lazy injection is suitable. Consider if the dependency is needed immediately or later
  8. • Simple txt files that contains code paths and gets

    included in app build BASELINE PROFILES • Uses AOT Ahead-Of-Time) compilation during installation or update • Reduces the need for JIT Just-In-Time) compilation during execution
  9. • Baseline profiles can be created for all critical user

    paths. Not just startup ADDITIONAL TIP • Maintenance is required. Regularly regenerate baseline profiles
  10. • Re-running the initial benchmark tests should show major improvements

    RESULTS • Up to 30% faster startup times even without baseline profiles.
  11. • Better UX, increases satisfaction and retention WHY • Increased

    satisfaction can lead to better reviews and ratings • Improves Android Vitals, boosting appʼs ranking and organic growth