[ Web Proxy ]
URL:
Viewing: https://developer.android.com/topic/performance/appstartup/analysis-optimization [Back]  [Original]

App startup analysis and optimization  |  App quality  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]

App startup analysis and optimization Stay organized with collections Save and categorize content based on your preferences.

During app startup, your app makes the first impression on users. App startup must be quick to load and display information the user needs to use your app. If your app takes too long to start up, users might exit your app because they are waiting too long.

We recommend using the Macrobenchmark library to measure startup. The library provides an overview and detailed system traces to see exactly what's happening during startup.

System traces provide useful information about what's happening on your device, which helps you understand what your app is doing during startup and identify potential areas for optimization.

To analyze your app startup, do the following:

Steps to analyze and optimize startup

Apps often need to load specific resources during startup that are critical to end users. Non-essential resources can wait to load until after startup completes.

To make performance trade-offs, consider the following:

After you fully investigate the operation, you can decide on the trade-off between the time it takes to load and the necessity of including it in app startup. Remember to include the potential for regression or breaking changes when altering the workflow of your app.

Optimize and re-measure until you're satisfied with the startup time for your app. For more information, see Use metrics to detect and diagnose problems.

Measure and analyze time spent in major operations

When you have a complete app startup trace, look at the trace and measure time taken for major operations like bindApplication or activityStart. We recommend using Perfetto or the Android Studio Profilers to analyze these traces.

Look at the overall time spent during app startup to identify any operations that do the following:

Investigate each of these traces further to find performance gaps.

Identify expensive operations on the main thread

It's best practice to keep expensive operations such as file I/O and network access off the main thread. This is equally important during app startup, because expensive operations on the main thread can make the app unresponsive and delay other critical operations. StrictMode.ThreadPolicy can help identify cases where expensive operations are happening on the main thread. It's good practice to enable StrictMode on debug builds to identify problems as early as possible, as shown in the following example:

class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()

        ...
        if (BuildConfig.DEBUG)
            StrictMode.setThreadPolicy(
                StrictMode.ThreadPolicy.Builder()
                    .detectAll()
                    .penaltyDeath()
                    .build()
            )
        ...
    }
}

Using StrictMode.ThreadPolicy enables the thread policy on all debug builds and crashes the app whenever violations of the thread policy are detected, which makes it difficult to miss thread policy violations.

TTID and TTFD

To see the time it takes the app to produce its first frame, measure the time to initial display (TTID). However, this metric doesn't necessarily reflect the time until the user can start interacting with your app. The time to full display (TTFD) metric is more useful in measuring and optimizing the code paths necessary to have a fully usable app state.

For strategies on reporting when the app UI is fully drawn, see Improve startup timing accuracy.

Optimize for both TTID and TTFD, because both are important in their own areas. A short TTID helps the user see that the app is actually launching. Keeping the TTFD short is important to help ensure that the user can start interacting with the app quickly.

Analyze overall thread state

Select the app startup time and look at overall thread slices. The main thread needs to be responsive at all times.

Tools such as the Android Studio Profiler and Perfetto provide a detailed overview of the main thread and how much time is spent in each stage. For more information about visualizing Perfetto traces, see the Perfetto UI documentation.

Identify major chunks of main thread sleeping state

If there's a lot of time spent sleeping, it's likely a result of your app's main thread waiting for work to complete. If you have a multithreaded app, identify the thread that your main thread is waiting on and consider optimizing these operations. It can also be useful to ensure there's no unnecessary lock contention causing delays in your critical path.

Reduce main thread blocking and uninterruptible sleep

Look for every instance of the main thread going into a blocked state. Perfetto and Studio Profiler show this with an orange indicator on the thread state timeline. Identify the operations, explore if these are expected or can be avoided, and optimize where necessary.

I/O-related interruptible sleep can be a really good opportunity for improvement. Other processes doing I/O, even if they're unrelated apps, can contend with the I/O that the top app is doing.

Improve startup time

After you identify an opportunity for optimization, explore possible solutions to help improve startup times:

Analyze UI performance

App startup includes a splash screen and the loading time of your home page. To optimize app startup, inspect traces to understand the time taken for your UI to be drawn.

Limit work on initialization

Certain frames might take more time to load than others. These are considered expensive draws for the app.

To optimize initialization, do the following:

Measure frame data

There are multiple ways to measure frame data. The five main collection methods are as follows:

Check main activity load time

Your app's main activity might contain a large amount of information that is loaded from multiple sources. Check the home Activity UI, and specifically look at the Choreographer#doFrame event.

Consider these possible solutions to optimize main activity load time:

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-07-16 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-07-16 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page