OKLayoutInflater
Article Summary
OkCredit's Android team was hitting a wall: complex XML layouts were causing frozen frames and ANRs. AndroidX's AsyncLayoutInflater wasn't cutting it.
The OkCredit engineering team built OkLayoutInflater, an open-source library that supercharges Android layout inflation using Kotlin coroutines. They tackled the limitations of AndroidX's single-threaded approach and achieved dramatic performance gains.
Key Takeaways
- Replaced single-threaded inflation with coroutines for parallel processing across CPU cores
- Added lifecycle awareness to prevent crashes from inflation callbacks after screen closes
- Reduced frozen frames by 23% overall and 30% on critical screens
- Cut RecyclerView load times significantly by inflating items asynchronously
- Works seamlessly with MVI architecture by caching render calls until inflation completes
Critical Insight
OkCredit reduced frozen frames by 23% and improved RecyclerView performance by switching from AndroidX AsyncLayoutInflater to their coroutine-based solution.