2

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

epic
  • 1,333
  • 1
  • 13
  • 27

2 Answers2

2

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

epic
  • 1,333
  • 1
  • 13
  • 27
0

When you add Firebase to your app, it merges in a ContentProvider that automatically loads and initializes Firebase so that the APIs are ready for use as soon as your code is invoked. You're paying the cost of that. But that doesn't necessarily explain everything, since we can't see exactly what else your app might be doing, or how your measure the startup time.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • As mentioned, i am searching the "Displayed" keyword in Logcat under "No Filters" to compare the cold start times between the app and other apps on my cellphone and the code is at the link bellow. There is nothing in it besides the firebase implementations. 1.2s is a lot for such an empty app, i am not sure it make sense. – epic Apr 17 '20 at 20:53