At its F8 developer conference, Facebook today announced that it is open-sourcing Litho, a declarative framework for building efficient user interfaces on Android. Litho is the same framework Facebook uses internally to build its own Android app, which is currently being used by more than a billion people every month.
The company first talked about this new framework last October. At the time, the company noted that the issue it was trying to solve was mostly about building a more performant framework for displaying the Facebook News Feed, which tends to be more complex than the scrollable lists for which the standard Android tools are optimized. Those lists tend to use Android’s RecyclerView, but in order to get to the 60 frames per second that modern device screens now typically support (and which users expect), the RecyclerView simply isn’t fast enough for more complex applications.
“As UIs become increasingly sophisticated, it gets harder to complete all the rendering work that needs to get done in this time frame,” Facebook’s Pasquale Anatriello and Marco Cova write in today’s announcement. “This proves to be especially challenging with dynamic scrolling surfaces, as new pieces of UI are constantly being introduced on screen.”
Litho’s programmers used some of what Facebook learned from React and built a new system that improves scroll performance up to 35 percent. It does that, in part, by breaking down complex views like the News Feed into smaller components (think text, images and videos) that can then be rendered incrementally. It also can take some of those smaller pieces and recycle them without having to keep multiple copies in memory.
As Facebook engineering manager Lucas Rocha and Facebook engineer Emil Sjolander told me earlier this week, it’s worth noting that while this focus on feeds may solve Facebook’s problems (but isn’t really applicable to other apps), many of the most popular apps today are indeed built around the idea of a feed. Now that it’s open source, other developers outside of Facebook may also be able to implement some of the idea here for other problems, but the team itself is mostly focused on optimizing the product for the use cases Facebook itself sees.