You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2018-07-02-how-to-reduce-cold-startup-time-101.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,28 +14,28 @@ Android developers provides a comprehensive explanation of app startup time [her
14
14
15
15
#### How much is too much?
16
16
17
-
For cold start, anything above 5 seconds is considered excessive.
17
+
For cold start, anything above **5 seconds** is considered excessive.
18
18
19
19
20
20
21
21
#### How do I track the cold start performance of my app?
22
22
23
-
To check how your Android app is performing in comparison to other apps, go to Play Console > your app > Android Vitals > App Startup Time.
23
+
To check how your Android app is performing in comparison to other apps, go to **Play Console > your app > Android Vitals > App Startup Time.**
24
24
25
25
26
26
27
27
#### And how do I get the exact number?
28
28
29
-
In Android 4.4 and higher, logcat includes an output line containing a value called "Displayed". This value represents the amount of time elapsed between launching the process and finishing drawing the corresponding activity on the screen. The reported log line looks similar to the following example:
29
+
In Android 4.4 and higher, logcat includes an output line containing a value called **"Displayed"**. This value represents the amount of time elapsed between launching the process and finishing drawing the corresponding activity on the screen. The reported log line looks similar to the following example:
P.S. if you are tracking the time in Android studio, make sure you disable filters in your logcat view because it is the system server, and not the app, that serves this log.
34
34
35
35
36
36
Don't be confused if the "Displayed" line in the logcat output contains an additional field for "total" time. For example:
Here, the first time measurement is only for the activity that was first drawn and the "total" time measurement begins at the app process start, and could include another activity that was started first but did not display anything to the screen (for example a splash screen). This extra measurement is shown when there is a difference between the single activity and total startup times.
41
41
@@ -53,7 +53,7 @@ Before we delve into the code and start digging it for prospective flaws, let's
53
53
54
54
***Hierarchy Viewer**: Hierarchy Viewer allows you to measure the layout speed for each view in your layout hierarchy. It can help you find performance bottlenecks caused by the structure of your view hierarchy.
55
55
56
-
P.S. If you're using Android Studio 3.1 or later, you should instead use Layout Inspector to inspect your app's view hierarchy at runtime.
56
+
P.S. If you're using Android Studio 3.1 or later, you should instead use **Layout Inspector** to inspect your app's view hierarchy at runtime.
57
57
58
58
***Debug GPU Overdraw tool**: It uses color-coding to show the number of times your app draws each pixel on the screen. The higher this count, the more likely it is that overdraw affects your app's performance.
59
59
@@ -77,7 +77,7 @@ Now that you have analysed your app and zeroed in the problematic areas, let's s
77
77
78
78
***Use Dagger2 for dependency injection**: Dagger is a fully static, compile-time dependency injection framework for both Java and Android. It implements the dependency injection design pattern without the burden of writing the boilerplate and aims to address many of the development and performance issues that have plagued reflection-based solutions.
79
79
80
-
You can refer to [this](https://medium.com/@harivigneshjayapalan/dagger-2-for-android-beginners-dagger-2-part-i-f2de5564ab25) article for a detailed explanation of Dagger 2 and its usage
80
+
You can refer to [this](https://medium.com/@harivigneshjayapalan/dagger-2-for-android-beginners-dagger-2-part-i-f2de5564ab25) article for a detailed explanation of Dagger 2 and its usage.
81
81
82
82
83
83
***Using Handler with delay**: Now this one might sound like a hack but it does wonders to your app startup performance- in cases where there is some piece of lethargic code which you cannot afford to shift from the main thread, you can put in in a Handler and use the postDelayed method, adding an appropriate delay(100 to 200ms should do just fine). This takes the weight off the onCreate and your app launches much quicker than before ,with unnoticeable delay in the execution of the delayed method.
0 commit comments