Swiggy Sarabjeet Singh Nov 14, 2023

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

Critical Insight

Swiggy achieved significant scroll performance improvements by replacing traditional Android views with Litho's declarative component system and background layout calculations.

The article includes a complete code walkthrough for building GroupSections, plus the author promises a follow-up on implementing missing components like ViewPagers and handling animations.

About This Article

Problem

Swiggy's mobile team had issues with scroll performance when RecyclerViews contained complex content of different types. This directly affected app metrics and how users experienced the app.

Solution

Sarabjeet Singh's team switched to Facebook's Litho framework. They used its Sections API with DataDiffSection to run DiffUtil calculations on background threads, and ComponentRenderInfo to handle rendering multiple view types.

Impact

Litho's asynchronous layout engine and fine-grained recycling system improved performance significantly. Swiggy could now render complex lists with multiple content types while keeping scrolling smooth at 60fps without blocking the UI thread.