Fix Case Where Node Is Deallocated While Visible (#2171)

* Attempt to reproduce supplementary crash

* Get closer with supplementary issue testing

* Alright! We have a repro!

* The investigation continues

* Fixed!
This commit is contained in:
Adlai Holler
2016-08-31 15:50:39 -07:00
committed by GitHub
parent 68d6d6f5b4
commit 284975ecec
4 changed files with 83 additions and 11 deletions

View File

@@ -1941,4 +1941,27 @@ static bool stringContainsPointer(NSString *description, id p) {
XCTAssertEqual(contentsAfterRedisplay, node.contents);
}
// Underlying issue for: https://github.com/facebook/AsyncDisplayKit/issues/2011
- (void)testThatLayerBackedSubnodesAreMarkedInvisibleBeforeDeallocWhenSupernodesViewIsRemovedFromHierarchyWhileBeingRetained
{
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
NS_VALID_UNTIL_END_OF_SCOPE UIView *nodeView = nil;
{
NS_VALID_UNTIL_END_OF_SCOPE ASDisplayNode *node = [[ASDisplayNode alloc] init];
nodeView = node.view;
node.name = @"Node";
NS_VALID_UNTIL_END_OF_SCOPE ASDisplayNode *subnode = [[ASDisplayNode alloc] init];
subnode.layerBacked = YES;
[node addSubnode:subnode];
subnode.name = @"Subnode";
[window addSubview:nodeView];
}
// nodeView must continue to be retained across this call, but the nodes must not.
XCTAssertNoThrow([nodeView removeFromSuperview]);
}
@end