Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AsyncDisplayKit/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,9 @@ - (void)dealloc
- (void)__unloadNode
{
ASDisplayNodeAssertThreadAffinity(self);
ASDisplayNodeAssert([self isNodeLoaded], @"Implementation shouldn't call __unloadNode if not loaded: %@", self);
ASDN::MutexLocker l(_propertyLock);

if (_flags.layerBacked)
_pendingViewState = [_ASPendingState pendingViewStateFromLayer:_layer];
else
Expand Down
7 changes: 5 additions & 2 deletions AsyncDisplayKit/Details/_ASDisplayView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ - (void)didMoveToSuperview
needsSupernodeRemoval = YES;
}
} else {
// If supernode is loaded but our superview is nil, the user manually removed us, so disconnect supernode.
needsSupernodeRemoval = supernodeLoaded;
// If supernode is loaded but our superview is nil, the user likely manually removed us, so disconnect supernode.
// The unlikely alternative: we are in __unloadNode, with shouldRasterizeSubnodes just having been turned on.
// In the latter case, we don't want to disassemble the node hierarchy because all views are intentionally being destroyed.
BOOL nodeIsRasterized = ((_node.hierarchyState & ASHierarchyStateRasterized) == ASHierarchyStateRasterized);
needsSupernodeRemoval = (supernodeLoaded && !nodeIsRasterized);
}

if (needsSupernodeRemoval) {
Expand Down
10 changes: 10 additions & 0 deletions AsyncDisplayKit/Private/_ASPendingState.m
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,13 @@ - (void)applyToView:(UIView *)view
view.accessibilityIdentifier = accessibilityIdentifier;
}

// FIXME: Make this more efficient by tracking which properties are set rather than reading everything.
+ (_ASPendingState *)pendingViewStateFromLayer:(CALayer *)layer
{
if (!layer) {
return nil;
}

_ASPendingState *pendingState = [[_ASPendingState alloc] init];

pendingState.anchorPoint = layer.anchorPoint;
Expand Down Expand Up @@ -877,8 +882,13 @@ + (_ASPendingState *)pendingViewStateFromLayer:(CALayer *)layer
return pendingState;
}

// FIXME: Make this more efficient by tracking which properties are set rather than reading everything.
+ (_ASPendingState *)pendingViewStateFromView:(UIView *)view
{
if (!view) {
return nil;
}

_ASPendingState *pendingState = [[_ASPendingState alloc] init];

CALayer *layer = view.layer;
Expand Down
14 changes: 14 additions & 0 deletions examples/SocialAppLayout/Sample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,18 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
return _socialAppDataSource.count;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PostNode *postNode = (PostNode *)[_tableView nodeForRowAtIndexPath:indexPath];
Post *post = _socialAppDataSource[indexPath.row];

BOOL shouldRasterize = postNode.shouldRasterizeDescendants;
shouldRasterize = !shouldRasterize;
postNode.shouldRasterizeDescendants = shouldRasterize;

NSLog(@"%@ rasterization for %@'s post: %@", shouldRasterize ? @"Enabling" : @"Disabling", post.name, postNode);

[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end