To write Paper, Facebook developed a wide variety of proprietary libraries, and it’s slowly making some of them available to outside developers. Earlier this year, for example, Facebook open sourced the Pop animation engine, which powers much of the user interface of the app, Shimmer for adding a shimmering effect to apps and a couple of other libraries it developed for Paper. Today, it is making the AsyncDisplayKit library available to developers, too.
That’s a bit of an unwieldy name, but it’s the technology that allows an app with lots of complex animations like Paper to run at 60 frames per second. It’s essentially a drop-in replacement for some of Apple’s own technologies. Apple’s own UIKit views for working with text and images can often take tens to hundreds of milliseconds to render. That makes it very hard — and sometimes impossible — to still render smooth animations in an app.
Over time, developers have found ways around this by hacking their own solutions, but as Facebook notes, these “individual workarounds tend to behave differently, making it difficult to reason about higher-level improvements and application behavior.”
That’s where AsyncDisplayKit comes in. It builds on Apple’s own technologies, but while Apple’s standard technology runs in an application’s main thread and hence blocks the application from responding to user input, Facebook’s solution doesn’t block the main thread.
Unsurprisingly, AsyncDisplayKit works very well in combination with the Pop animation engine, but there is no requirement to also use Pop. Indeed, as Facebook notes, “it’s just as powerful with UIKit Dynamics and conventional app designs”
The code is now available on GitHub.