Consumer app at scale
Fewer freezes and crashes in an Android app used by millions
A consumer app at scale kept freezing on the main thread, so we traced the stalls and moved the blocking work off it.
The situation
The app had millions of daily users. Google Play Console showed a bad-behavior warning for ANRs, and the team could see it in store ranking and in support tickets.
Nobody had a single cause. SDKs started up synchronously when the app launched. Database queries ran on the UI thread. Memory crashes spiked on weaker phones. Each looked small on its own, but at this scale they added up.
The common thread was the main thread, which every one of these problems ran through.
What we did
- 01
Traced the main thread
We profiled the app with Perfetto and Systrace on real devices. The traces showed where the main thread was blocked, including binder calls and disk reads.
- 02
Moved SDK startup off the critical path
Analytics and ad SDKs no longer initialized synchronously at launch. We moved them to lazy background workers so the first screen did not wait on them.
- 03
Took database and disk work off the UI thread
Room and SQLite queries that blocked the UI thread moved to background coroutines, so screens stopped stalling while data loaded.
- 04
Fixed the memory crash patterns
We found where bitmaps were held longer than needed and tied background work to the lifecycle of the screen that started it.
- 05
Checked the result in the field
We compared Play Console vitals before and after the release to confirm the change held in the field.
What changed
- ANR events dropped clearly in Play Console after the fix shipped.
- Memory crashes fell across device tiers.
- The app started faster because less work ran before the first screen.
- Scrolling and checkout felt smoother at peak load.
- Handled 4M+ peak DAU on a production consumer app
- -46% Google Play ANR events on the Android vitals engagement
- -55% crashes on the same engagement
Stack
- Android
- Kotlin coroutines
- Room / SQLite
- Perfetto
- Systrace
- Google Play Console vitals
If you are in the same spot
Mobile App ANR Audits
Production traces and Perfetto profiling to find main-thread stalls on Android, plus tested fixes and checks that keep them away.
See the serviceApp Size Optimization Service
A size breakdown, code and asset trimming, per-device delivery and a CI budget for Android and iOS apps.
See the service