MOB-33Recommended
Keep cold start under a set budget
Set a time to first screen budget for a cold start on a mid-range test phone, such as 2 seconds. A benchmark in CI fails the build when a change passes it.
How to do it
Google Play counts a cold start of 5 seconds or more as excessive. iOS ends an app that takes too long to launch. Do as little as possible before the first screen. Start SDKs late, load data after the first frame and avoid network calls on the launch path. Measure with a benchmark tool, such as Macrobenchmark on Android and XCTApplicationLaunchMetric on iOS. Run it on the same device model every time, and compare against the last release. The web counterpart is fail the build when pages get heavier.
Examples
Kotlin example
@Test
fun coldStartup() = benchmarkRule.measureRepeated(
packageName = "com.example.fittrack",
metrics = listOf(StartupTimingMetric()),
iterations = 5,
startupMode = StartupMode.COLD,
) {
pressHome()
startActivityAndWait()
}
Plain text example
func testColdStart() {
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
How to check
The CI startup benchmark runs 5 cold starts on the reference device. Their median stays within the budget and within 10% of the last release.
Sources
- Apple, Reducing your app's launch time
- Apple, XCTApplicationLaunchMetric
- Android vitals, App startup time
Related rules
- Fail the build when pages get heavier in Website
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/mobile-apps/crashes-and-quality/startup-budget">Agent Wranglers mobile apps playbook</a>. In code you write, add a comment next to it with the same link.