Search code examples
androidfirebasefirebase-performance

How does Firebase app start time profiling work on Android?


I noticed that Firebase Performance Monitoring does provide some automatic traces out of the box. In particular I was looking at the cold app start time trace which is exactly what I need to do right now. Unfortunately I need to do have more granular data, so I was thinking I could do it on my own, but so far I failed to come up with a reasonable how to measure a true cold start time of an Android app (think time between tapping an icon in launcher and seeing the UI of given Activity).

The docs says, that Firebase starts the trace when FirebasePerfProvider.onCreate callback gets called. As far as I know this should happen very soon after the application process starts, so that's good, but it also means that it gets called even when the app just receives a notification (or some broadcast in general) and at that point the process might not be terminated by the time the user actually opens the app. That means it'd measure the duration wrong.

Given the SDK is not (yet?) open sourced, I could not find a better description of how this works.

Does anybody know more?


Solution

  • If the Android process is launched via a Service or BroadcastReceiver, no trace is started. So, if and when an Activity is actually started in that process, there will be no problems with an app start trace that could appear to be very long. The app start trace only happens if the process is invoked by an Activity.

    I've updated the documentation to include this fact, and that change should be published soon.