Optimising Scrolling Performance with Litho
Article Summary
Swiggy's Android team was hitting scroll performance walls with traditional RecyclerViews. Their solution? Facebook's Litho framework, which delivered massive performance gains.
Sarabjeet Singh from Swiggy's mobile team shares a detailed technical guide on implementing Litho, a declarative UI framework that uses FlexBox layouts and asynchronous rendering. This is a practical walkthrough with real code examples.
Key Takeaways
- Litho enables fine-grained recycling: individual text and images recycle separately, not entire views
- Asynchronous layout calculations happen off the UI thread, eliminating scroll jank
- FlexBox-based Yoga engine creates flatter view hierarchies with fewer ViewGroups
- Sections API handles RecyclerView complexity with automatic DiffUtil on background threads
- Code examples cover everything from Hello World to complex horizontal and grid lists
Critical Insight
Swiggy achieved significant scroll performance improvements by replacing traditional Android views with Litho's declarative component system and background layout calculations.