Mobile App Performance
Optimize mobile app performance: startup time, list scrolling, memory management, battery usage, and frame rate with platform profiling tools.
Mobile app performance directly impacts ratings, retention, and revenue. A 1-second delay in load time reduces conversions by 20%. 60fps scrolling is expected; 30fps feels broken. Systematic performance work requires profiling tools, not intuition.
Measure first, optimize second. Set performance budgets: <2s cold start, 60fps scrolling, <100MB baseline memory. Profile with platform tools (Instruments, Android Profiler), not third-party abstractions. Test on low-end devices - flagship performance doesn't predict real-world user experience.
Workflow
- Optimize app startup timeCold start >3s causes 53% of users to abandon. Every 100ms of startup time matters.
- Achieve smooth 60fps scrollingDropped frames are the most visible performance issue - users immediately feel them as "jank."
- Manage memory pressureiOS terminates apps that use too much memory (EXC_RESOURCE), often with no crash log. Android also kills background apps.
- Optimize battery usageHigh battery drain shows up in App Store reviews and leads to uninstalls.
- Optimize network and image loadingNetwork latency is the dominant slow path in most data-driven apps.
Output Format
Startup time <2s measured with Instruments, 60fps scrolling verified, memory baseline <100MB, battery profile clean, image loading optimized with caching.
Examples
Background decode: `DispatchQueue.global(qos: .userInitiated).async { let decodedImage = UIImage(data: imageData); DispatchQueue.main.async { cell.imageView.image = decodedImage } }`Memory warning: `override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning(); imageCache.removeAllObjects(); backgroundData = nil }`NSCache: `let cache = NSCache<NSString, UIImage>(); cache.countLimit = 100; cache.totalCostLimit = 50 * 1024 * 1024 // 50MB`Edge Cases & Gotchas
- Thermal throttling: sustained CPU usage causes the device to throttle - test with Instruments thermal state; structure heavy work as short bursts rather than sustained load
- Off-screen rendering triggers: `cornerRadius` + `masksToBounds`, shadows, and certain blend modes cause off-screen rendering; use `layer.shadowPath` and opaque layers
- iOS 60Hz vs 120Hz ProMotion: don't hard-code 60fps thresholds; use `CADisplayLink.preferredFrameRateRange` for adaptive frame rates on ProMotion displays
When to Break These Rules
- For rarely-used utility screens (settings, about), achieving 60fps is lower ROI than focusing performance work on the main feed or checkout flow.
Reference Files
Instruments guide: https://developer.apple.com/tutorials/data/documentation/xcode/instrumentsAndroid Profiler: https://developer.android.com/studio/profileWWDC 2023 App startup: https://developer.apple.com/videos/play/wwdc2023/10161/Image format comparison: https://web.dev/articles/choose-the-right-image-format