File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments