Monitoring the performance of your app startup

Monitoring the performance of your app startup

Making sure that your app is as responsive as possible at startup is a concern that all developers share. Fortunately, Embrace.io makes it easy to measure this. The Embrace.io SDK automatically creates a startup app moment and begins an active timer as soon as the SDK is enabled. Stopping the startup timer is extremely simple and can be done by executing the following method call.

Embrace.getInstance().endAppStartup();

While it’s tempting to simply append this line at the end of your Activity.onResume() callback, we highly recommend giving some thought into finding the optimal place to end the app’s startup sequence. Ideally, the startup performance should represent the time required for the application to be useable from a cold launch. In practice, however, accurately defining this can be tricky, especially for complex applications with many different UI flows. Generally speaking, we’ve found that most successful integrations tend to follow these guidelines.

App moments should not be affected by user input

App moments are meant to tell you how your application is performing, not what your users are doing. One of the most common mistakes we’ve seen developers make is to wrap an app moment around a section of code that requires user interaction. For example, it’s common for some applications to display a login activity on startup. Ending the startup sequence after the user has successfully authenticated themselves in the app would capture the time required to initialize the application as well as the time it took for the user to enter their login credentials. Ultimately this skews the data towards reporting longer startup times. A better approach would be to split this into two moments. The startup moment could be defined as the time it takes to display the login UI while another moment might measure the time between the user initiating the login request to showing their personalized content.

All reachable flows must be terminated

Another common problem when defining an app moment is not terminating it at all reachable paths from the moment’s start. This is especially prevalent during startup because different triggers may cause the user to enter the application using different user flows. For instance, the user might be shown a different activity depending on whether the app was started via the launcher or in response to a notification broadcast. When a moment is not terminated, this results in a large number of stalled moment issues which usually indicates a serious problem since we expect that all moments eventually terminate. If you suspect that there is a flow that is not accounted for, we recommend checking out the screenshots associated with the moment. A screenshot will only be taken if the moment duration exceeds 5 seconds.