Search code examples
androidfirebasecold-start

Android slow cold start with firebase


I felt my application cold start is slow and was more sure when Firebase Performance mentioned that.

I used logcat Displayed to make an initial compare which displayed at my Samsung galaxy S8:

/.list.MainActivity: +2s81ms

This is replicated by pressing the play button at Android Studio >> closing the app from my cellphone >> opening it again in my phone (i.e. not with android studio)

Comparing to known applications the fast applications at about 400ms and the slower (such as Whatsapp and facebook) are 1s, so 2 seconds is a lot!

I spent almost 2 days and ended up finding the following,

If i am making a simple Hello World application, the cold start time is about 0.660s, which is a lot for an application doing nothing and compared to released applications with as little as 0.350s

And if i am adding the next 4 lines in gradle (without any extra code!)

implementation 'com.google.firebase:firebase-firestore:21.4.2'
implementation 'com.firebaseui:firebase-ui-auth:6.2.0'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.firebaseui:firebase-ui-firestore:6.2.0'

The cold start increased to about 1.2s which is even more than Whatsapp and Facebook

How is it that the cold start for such a simple code is so slow? Am i missing any settings in Android studio? Perhaps the manifest or gradle? What can i do to improve that?

Hello world with firebase gradle implementation


Solution

  • It turns our there is a very big different between debug and release versions. After i created a release version for alpha testers on google play with the minifyEnabled, shrinkResources, debuggable set to false etc. the app cold start is now about 700ms.

    Also, i am not sure, if there is a difference between an app just installed and one installed and cold started after several times (not to be confused by warm start of course)

    That does not completely explain all the things i experienced and i am still a bit confused about, but i am guessing there is much about the android system (and firebase) unknown to me which can affect the cold start time