Detecting a startup performance issue
This tutorial guides you through identifying a performance issue related to your app startup time using the Kotzilla Platform.
Issue context
Startup performance issues occur when the app takes too long to initialize, delaying the appearance of the first usable screen. This is often due to heavy operations or blocking tasks running on the main thread during startup.
Why it matters?
Slow startup times frustrate users and increase the likelihood of app abandonment. A faster, smoother startup enhances user experience and retention.
Suggested user resolution actions
- Identify and optimize: Use the Kotzilla Platform to monitor startup tasks, flagging any operation on the main thread that exceeds a 10 ms threshold.
- Offload heavy tasks: Move resource-intensive operations to background threads or use lazy loading for non-essential features.
- Reduce execution times: Refactor inefficient code and simplify initialization logic to speed up startup.
Prerequisites
In this tutorial, we will be using the NowInAndroid app as an example. Before you begin, ensure you've completed the first two steps of the Get started with Kotzilla Platform
Step 1 - Simulate a blockage on the main thread
To observe the effects of on the app startup time when blocking the main thread, we’ll simulate a 1-second delay in NiaApplication
class.
Here’s the code to introduce a 1-second delay after onCreate()
, just after the Koin setup:
class NiaApplication : Application(), ImageLoaderFactory {
val imageLoader: ImageLoader by inject()
val profileVerifierLogger: ProfileVerifierLogger by inject()
override fun onCreate() {
super.onCreate()
// Start Kotzilla SDK
KotzillaSDK.setup(this)
// Start Koin with Kotzilla Analytics
startKoin {
androidContext(this@NiaApplication)
analyticsLogger(AndroidLogger(DEBUG))
modules(appModule)
workManagerFactory()
}
// Simulate a blockage on the main thread
Thread.sleep(1000)
...
}
Step 2- Create user sessions to capture app execution data.
With the simulated delay added, create a user session that will allow Kotzilla to capture and display the issue.
Follow the navigation steps detailed in this guide to simulate a repeatable sequence of interactions. Repeat this three times to create consistent data on Kotzilla Platform.
Step 3- Analyze results in Kotzilla Platform
3.1 Observing impact on user sessions
After completing these actions, log in to the Kotzilla Platform click on the Dashboard button next to your app to access the app Dashboard View.
Then click on the Sessions View to visualise the list of recorded user sessions. You should see the three sessions created. Notice that the Max Event Duration column for these sessions does not reflect the 1-second delay introduced in NiaApplication
because this delay occurs during the app's initialization phase, specifically before the first screen is loaded or any user interaction is recorded.
Although the timeline shows no direct impact on screen states, you can clearly observe a 1-second delay between the Koin Modules Load and the first Koin Resolution event. This delay ultimately causes the 1-second app startup delay before loading the first screen of your app.
3.2 Investigating the sequence of events
This sequence demonstrates how blocking the main thread during startup affects the application's ability to transition smoothly into its first usable state. Even before any user interaction is recorded, this delay directly impacts the perceived startup time.
Key takeaways
By simulating a 1-second delay in the NiaApplication
class, we demonstrated the effect of blocking the main thread during the app's initialization phase. The Kotzilla Platform allowed us to accurately pinpoint this bottleneck and understand how it affects app startup time.