There are many discussions going on in web, if it’s worth to integrate AsyncDisplayKit or not? Here is our take on this topic.
Ideally, the frame rate on iOS should be maintained at 60fps (source). This gives the UI system 16ms to do all the work related to generate a static frame that users will see on the screen. If during these 16ms the app is unable to do the work necessary to generate the frame then UI will appear unresponsive.
AsyncDisplayKit is letting you to do a tons of heavy computational stuff for laying out a UI in an asynchronous way, which makes UIs with deep, complex layouts a lot more responsive. For more information see this video by creators.
The goal was to refactor the Restaurant listing page (RLP), to reach a smoother performance on devices like iPhone 5s and earlier.
Here are measurements with Instruments tool on iPhone 5.
This screenshot shows RLP performance fps rate varies from 58 to 60 before refactoring.
This is the basic concept of refactoring RLP classes with classes offered by ASDK.
- ASViewController for UIViewController
- ASTableView for UITableView
- ASCellNode for UITableViewCell
- ASTExtNode – UILabel to show texts
- ASNetworkImageNode – SDWebImageView (we are using SDWebImage for remote image downloading) asynchronously download images
The fps rate after the refactoring didn’t change – it stayed at 58-60 fps, neither changed RLP performance visually.
- This is really good for very complex and very rich (text, high-res images) views to be made very performant (background calculations).
- ASDK is an intelligent developed library. It’s worth to take a look at least.
- .xib/storyboard and autolayout are working on the main thread. Hence they are not compatible with ASDK.
- All .xib/storyboard should be written manually including auto layout. ASDK has it’s own autolayout system.
- On older devices (iPhone 5, 5C, 4S) it’s not significantly improving preload time. On newer devices it’s not a big deal to reach 60fps anyway.
- It was built specifically for Paper to get high performance rendering and animations. You’ll have to rely on Facebook support for the library.
In the end we decide to not go with AsyncDisplayKit because our project is highly storyboard and layout dependent. Switching to AsyncDisplayKit means to rewrite all UI “by hand” which seems not worth the effort involved.