How we improved our Android app start time by 20%

Bhavin Vala
Mindful Engineering
5 min readMay 19, 2023

--

At Bhoj (Food delivery app), we have served several active customers in the biggest 4 cities in Nepal. Our biggest goal is to match you with the most amazing food available, in the minimum amount of time, in a hassle-free way.

Approx 0.1 Million users downloaded our app. So we need to ensure speedy deliveries with a seamless app experience.

Speed is an essential part of app performance. Users tend to become impatient when they are hungry and the application is sluggish. How fast your app launches can set very important first impressions with your users and go a long way to retaining them.

Users expect apps to be responsive and fast to load. An app with a slow start time doesn’t meet this expectation and can be disappointing to users.

How we optimize our app and speed up the launch time:

To analyze our overheads, we employed a simple rule. Our technical team evaluated ideas based on their investment and the amount of effort they required. We embarked on a three-month optimization and enhancement journey due to this.

1. Scale down the app launch time
One of the first things that users will experience when using your application is its launch time. You need your app to launch and start as quickly as possible to avoid user frustration.

As per Google, 70% of mobile app users abandon an app if it takes too long to load. 25% of users abandon apps after one use due to poor performance.

Image Credit

We identified a bunch of things that could help to improve the start time.

  • Initialized only those objects that are immediately needed. For example, rather than creating global static objects, move to a singleton pattern, where the app initializes the object for the first time it accesses them.
  • The initialization of third-party libraries has been moved to a background thread.
  • To reduce memory footprint, we have converted PNG images to WebP.
  • Tried to avoid using unnecessary UI elements for the first launch.

Perfetto is a system profiling and app tracing tool by Google. It helps analyze the app performance traces. After tracing the app, we found some issues like third-party (3P) libraries taking a significant amount of time, high inflation time, etc. This helps us to reduce the app startup time by 20%.

2. Improve Memory usage

Android Profiler is a powerful tool introduced in Android Studio 3.0 that replaces Android Monitor. It provides real-time data about your app, such as CPU, memory, network, and energy usage, as well as data on event profiling.

It allows us to verify which parts of the code are adding extra time to the startup process. Using the method tracing, it is possible to see which methods are taking too long to execute and what they are doing.

Memory Profiler helps you debug crashes, applications not responding (ANRs), and freezes due to memory leaks in your application. Ideally, Android System takes care of garbage collection automatically by removing the objects created that are not in use.

However, sometimes due to memory leaks, memory taken up by these objects cannot be released back to the heap, which leads to garbage collection events and thereby slowing down or even killing the application.

To avoid memory leaks and solve them we use the Android profiler to find the leaks in our application.

We accomplished a tremendous 30% reduction in out-of-memory issues.

3. Enabling StrictMode

StrictMode is a developer tool that detects things you might be doing by accident and brings them to your attention so you can fix them.

Performing any kind of long blocking operations or disk IO operations on the Android Main thread can cause ANR issues. (Application Not Responding). You may not even realize that you have a potential ANR until it is too late and is already in your user’s hands.

For this we enabled StrictMode. It is a special class for verifying that your Android application is not doing things like disk I/O, Network access from the UI thread.

The best practice in Android says “keeping the disk and network operations off from the main thread makes applications much smoother and more responsive”.

At Bhoj, we are always ready to explore new ways to improve the experience for our customers. So, we keep creating a faster and smoother app experience for you and aspire to be the most popular and well-liked meal delivery service.

4. Use Android profiler

Android Studio offers Profiler, a potent tool for monitoring memory utilization, CPU activity, and trace analysis similar to Perfetto. In contrast to Perfetto, which mostly concentrates on the overall picture, Profiler allows us to examine the app’s operation in great detail. We discovered some inefficiencies in the way our views used memory, so we worked to make the caching system better while reusing the views as much as we could. This allowed us to drastically reduce out-of-memory concerns by 60%.

Quick Advice

  • Coroutines take a long time to initialize, so avoid using them while the program is just starting up. Instead, because the Zygote process already initializes it with minimal overhead, one may utilize ExecutorService to manage background activities.
  • Always look through the combined manifest file to identify any content providers that are not needed during startup.
  1. Performance improvements that enabled us to improve the client experience.
  2. Decreasing jank and UI enhancements.
  3. A 20% increase in customers visiting a homepage that is completely loaded and functional. At Bhoj, this flow is a crucial business statistic.

Clap 👏 If this article helps you.

Happy coding, Happy reading ✨

--

--