The ViewModel Performance Trap:When State Management Bites Back
summary
Shows that ViewModel construction often blocks the main thread long enough to break rendering — >16 ms causes jank, >500 ms can freeze or ANR — and traces reveal expensive injections like JSON builder and Retrofit setup created eagerly. Recommends measuring with method traces and Perfetto, making heavy deps singletons or warmed-up, avoiding blanket lazying, and supplying an injectable CoroutineScope using IO + supervisor job so init work runs off-main. At scale (close to 100 features, ~1,000 devs) a singleton warm-up + repository-level dispatcher boundaries proved effective.
AI-written summary · about
chapters (13)
- 0:00ViewModel performance issues
- 5:23ViewModel creation slowness
- 10:02Measuring ViewModel traces
- 14:55Architecture solutions for slowness
- 17:47Init blocks problem
- 22:43Dispatcher switching in scope
- 27:45Customizing ViewModel scope
- 29:29Cold vs eager loading
- 33:24Changing dispatchers in architecture
- 36:12ViewModel responsibilities
- 39:21UI model provider
- 40:46Performance checklist
- 43:37Q&A








