diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index 4c3909a469..e9e9386ae3 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -448,6 +448,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) _layer.delegate = nil; _layer = nil; + // TODO: Remove this? If supernode isn't already nil, this method isn't dealloc-safe anyway. [self __setSupernode:nil]; _pendingViewState = nil; @@ -3291,12 +3292,12 @@ static const char *ASDisplayNodeDrawingPriorityKey = "ASDrawingPriority"; [result addObject:@{ @"frame" : [NSValue valueWithCGRect:_view.frame] }]; } else if (_layer != nil) { [result addObject:@{ @"frame" : [NSValue valueWithCGRect:_layer.frame] }]; - } else { - [result addObject:@{ @"frame" : [NSValue valueWithCGRect:self.frame] }]; + } else if (_pendingViewState != nil) { + [result addObject:@{ @"frame" : [NSValue valueWithCGRect:_pendingViewState.frame] }]; } // Check supernode so that if we are cell node we don't find self. - ASCellNode *cellNode = ASDisplayNodeFindFirstSupernodeOfClass(self.supernode, [ASCellNode class]); + ASCellNode *cellNode = ASDisplayNodeFindFirstSupernodeOfClass([self _deallocSafeSupernode], [ASCellNode class]); if (cellNode != nil) { [result addObject:@{ @"cellNode" : ASObjectDescriptionMakeTiny(cellNode) }]; } diff --git a/AsyncDisplayKit/Private/ASObjectDescriptionHelpers.h b/AsyncDisplayKit/Private/ASObjectDescriptionHelpers.h index fbda8ccaa7..e8e853e7b1 100644 --- a/AsyncDisplayKit/Private/ASObjectDescriptionHelpers.h +++ b/AsyncDisplayKit/Private/ASObjectDescriptionHelpers.h @@ -36,11 +36,21 @@ NS_ASSUME_NONNULL_BEGIN ASDISPLAYNODE_EXTERN_C_BEGIN -/// Returns e.g. -NSString *ASObjectDescriptionMake(id object, NSArray * _Nullable propertyGroups); +/** + * Returns e.g. + * + * Note: `object` param is autoreleasing so that this function is dealloc-safe. + * No, unsafe_unretained isn't acceptable here – the optimizer may deallocate object early. + */ +NSString *ASObjectDescriptionMake(__autoreleasing id object, NSArray * _Nullable propertyGroups); -/// Returns e.g. -NSString *ASObjectDescriptionMakeTiny(id object); +/** + * Returns e.g. + * + * Note: `object` param is autoreleasing so that this function is dealloc-safe. + * No, unsafe_unretained isn't acceptable here – the optimizer may deallocate object early. + */ +NSString *ASObjectDescriptionMakeTiny(__autoreleasing id object); NSString * _Nullable ASStringWithQuotesIfMultiword(NSString * _Nullable string); diff --git a/AsyncDisplayKit/Private/ASObjectDescriptionHelpers.m b/AsyncDisplayKit/Private/ASObjectDescriptionHelpers.m index dfd0df6fee..261a87d175 100644 --- a/AsyncDisplayKit/Private/ASObjectDescriptionHelpers.m +++ b/AsyncDisplayKit/Private/ASObjectDescriptionHelpers.m @@ -37,7 +37,7 @@ NSString *ASGetDescriptionValueString(id object) { return [object description]; } -NSString *ASObjectDescriptionMake(id object, NSArray *propertyGroups) { +NSString *ASObjectDescriptionMake(__autoreleasing id object, NSArray *propertyGroups) { NSMutableString *str = [NSMutableString stringWithFormat:@"<%@: %p", [object class], object]; NSMutableArray *components = [NSMutableArray array]; @@ -54,7 +54,7 @@ NSString *ASObjectDescriptionMake(id object, NSArray *propertyGr return str; } -NSString *ASObjectDescriptionMakeTiny(id object) { +NSString *ASObjectDescriptionMakeTiny(__autoreleasing id object) { return ASObjectDescriptionMake(object, nil); }