ASDisplayNode and several subclasses had previously cleared memory-heavy objects like the backing store and text layout manager when the node's view or layer is removed from a visible heirarchy. This works great in any system that uses a "working range", where exiting the range removes the node from the hierarchy and reclaiming memory at that time is important. However, for standard UIViewController patterns (unused in Paper), this behavior causes highly undesirable thrashing (leading to visible flashes & wasteful re-rendering of content). After this change, node subclasses should implement -reclaimMemory if they need to perform any other cleanup besides backing store destruction when they leave a working range or other scenario where memory reduction is valuable. To trigger this behavior, calling code should use -recursivelyReclaimMemory. r=nadi
AsyncDisplayKit is an iOS framework that keeps even the most complex user interfaces smooth and responsive. It was originally built to make Facebook's Paper possible, and goes hand-in-hand with pop's physics-based animations — but it's just as powerful with UIKit Dynamics and conventional app designs.
Quick start
ASDK is available on CocoaPods. Add the following to your Podfile:
pod 'AsyncDisplayKit', :git => 'git@github.com:facebook/AsyncDisplayKit.git'
Import the framework header, or create an Objective-C bridging header if you're using Swift:
#import <AsyncDisplayKit/AsyncDisplayKit.h>
AsyncDisplayKit Nodes are a thread-safe abstraction layer over UIViews and CALayers:
You can construct entire node hierarchies in parallel, or instantiate and size a single node on a background thread — for example, you could do something like this in a UIViewController:
dispatch_async(_backgroundQueue, ^{
ASTextNode *node = [[ASTextNode alloc] init];
node.attributedString = [[NSAttributedString alloc] initWithString:@"hello!"
attributes:nil];
[node measure:CGSizeMake(screenWidth, FLT_MAX)];
node.frame = (CGRect){ CGPointZero, node.calculatedSize };
// self.view isn't a node, so we can only use it on the main thread
dispatch_sync(dispatch_get_main_queue(), ^{
[self.view addSubview:node.view];
});
});
You can use ASImageNode and ASTextNode as drop-in replacements for
UIImageView and UITextView, or create your own
nodes
to implement node hierarchies or custom drawing. ASTableView is a node-aware
UITableView subclass that can asynchronously preload cell nodes without
blocking the main thread.
Learn more
- Read the Getting Started guide
- Get the sample projects
- Browse the API reference
- Watch the NSLondon talk
Testing
AsyncDisplayKit has extensive unit test coverage. You'll need to run pod install in the root AsyncDisplayKit directory to set up OCMock.
Contributing
See the CONTRIBUTING file for how to help out.
License
AsyncDisplayKit is BSD-licensed. We also provide an additional patent grant.
The files in the /examples directory are licensed under a separate license as specified in each file; documentation is licensed CC-BY-4.0.

