Skip to content

Commit 3f982b5

Browse files
committed
Switch to use only layers for offscreen working range window.
ASDK layout and display calls don't depend on UIView in any way, so this will reduce UIView-specific overhead from heirarchy manipulation.
1 parent 7c78dfd commit 3f982b5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

AsyncDisplayKit/Details/ASRangeHandlerRender.mm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ - (void)node:(ASDisplayNode *)node enteredRangeOfType:(ASLayoutRangeType)rangeTy
3939

4040
[node recursivelySetDisplaySuspended:NO];
4141

42-
// add the node to an off-screen window to force display and preserve its contents
43-
[[self.class workingWindow] addSubnode:node];
42+
// Add the node's layer to an off-screen window to trigger display and mark its contents as non-volatile.
43+
// Use the layer directly to avoid the substantial overhead of UIView heirarchy manipulations.
44+
// Any view-backed nodes will still create their views in order to assemble the layer heirarchy, and they will
45+
// also assemble a view subtree for the node, but we avoid the much more significant expense triggered by a view
46+
// being added or removed from an onscreen window (responder chain setup, will/DidMoveToWindow: recursive calls, etc)
47+
[[[self.class workingWindow] layer] addSublayer:node.layer];
4448
}
4549

4650
- (void)node:(ASDisplayNode *)node exitedRangeOfType:(ASLayoutRangeType)rangeType
@@ -49,7 +53,7 @@ - (void)node:(ASDisplayNode *)node exitedRangeOfType:(ASLayoutRangeType)rangeTyp
4953
ASDisplayNodeAssert(rangeType == ASLayoutRangeTypeRender, @"Render delegate should not handle other ranges");
5054

5155
[node recursivelySetDisplaySuspended:YES];
52-
[node.view removeFromSuperview];
56+
[node.layer removeFromSuperlayer];
5357

5458
[node recursivelyClearContents];
5559
}

0 commit comments

Comments
 (0)