Facebook Open-Sources AsyncDisplayKit, the iOS Tool Behind Paper’s User Interface

By David Cohen 

AsyncDisplayKitDiagram650The iOS tool behind the user interface for Facebook’s Paper iPhone application was open-sourced by the social network Wednesday, iOS engineer Nadine Salter, Instagram iOS engineering manager Scott Goodson and software engineer Andrew Pouliot revealed in a post on the Facebook engineering blog.

Salter, Goodson and Pouliot introduced AsyncDisplayKit as follows:

Have you ever noticed apps stuttering as you scroll and swipe around? Tapped a button and watched the entire interface freeze as it tries to react? iOS is well-known for its user-experience quality bar, but meeting that bar can be difficult, especially on older iPhones and iPads. Polished apps typically use piecemeal performance optimizations to keep their interfaces fluid, treating different sources of slowness as different problems. Today we’re open-sourcing AsyncDisplayKit, a framework that offers a holistic way to keep your app smooth and responsive.

They also offered more details on how and why it works:

iOS user interface functionality — drawing to the screen, responding to touch events, running physics simulations for inertial scrolling and so on — is bottlenecked by the main thread. For an app to maintain the gold standard of 60 frames per second, it can only use the main thread for milliseconds at a time. But main-thread-only UIKit views like UIImageView and UITextView can take tens to hundreds of milliseconds to size and display themselves. And while the main thread is decoding an image or rendering text, it can’t respond to user input or keep up with scrolling.

Since using stock UIKit views can cause slowdowns, performant apps tend to have workarounds for individual UIKit components. Instead of letting UIImageView do expensive work itself, they might manually use Core Graphics to decompress JPEGs and PNGs in the background; instead of using UITextView, they might work with Core Text directly. This approach is effective, but has limitations — individual workarounds tend to behave differently, making it difficult to reason about higher-level improvements and application behavior.

AsyncDisplayKit builds on UIKit and Core Animation to offer a general solution. Its image and text views can be used without blocking the main thread, offering a drop-in solution for this common task. More importantly, it supports asynchronously creating and rendering complex view hierarchies the same way.

iPhone users: Do you use Paper?

Advertisement
Advertisement