You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Improve Handling of Rasterized Node Interface & Hierarchy States (#2731)
* Improve handling of rasterize node interface states and testing
* Fix harder
* Finish fixes and move rasterization flag into beta header
* Re-enable rasterization in ASDKgram
* Re-enable working test
* Only do it in debug
// Don't call self.supernode here because that will retain/autorelease the supernode. This method -_removeSupernode: is often called while tearing down a node hierarchy, and the supernode in question might be in the middle of its -dealloc. The supernode is never messaged, only compared by value, so this is safe.
2230
2237
// The particular issue that triggers this edge case is when a node calls -removeFromSupernode on a subnode from within its own -dealloc method.
2231
-
if (!subnode || [subnode_deallocSafeSupernode] != self) {
// Clear supernode's reference to us before removing the view from the hierarchy, as _ASDisplayView
2261
2266
// will trigger us to clear our _supernode pointer in willMoveToSuperview:nil.
2262
2267
// This may result in removing the last strong reference, triggering deallocation after this method.
2263
2268
[supernode _removeSubnode:self];
2264
2269
2265
-
if (isNodeLoaded && (supernode == nil || supernode.isNodeLoaded)) {
2266
-
ASPerformBlockOnMainThread(^{
2267
-
if (layerBacked || supernode.layerBacked) {
2268
-
[layer removeFromSuperlayer];
2269
-
} else {
2270
-
[view removeFromSuperview];
2271
-
}
2272
-
});
2270
+
if (view != nil) {
2271
+
[view removeFromSuperview];
2272
+
} elseif (layer != nil) {
2273
+
[layer removeFromSuperlayer];
2273
2274
}
2274
2275
}
2275
2276
@@ -2328,12 +2329,10 @@ - (void)__enterHierarchy
2328
2329
if (!_flags.isInHierarchy && !_flags.visibilityNotificationsDisabled && ![self__selfOrParentHasVisibilityNotificationsDisabled]) {
2329
2330
_flags.isEnteringHierarchy = YES;
2330
2331
_flags.isInHierarchy = YES;
2331
-
2332
-
if (_flags.shouldRasterizeDescendants) {
2333
-
// Nodes that are descendants of a rasterized container do not have views or layers, and so cannot receive visibility notifications directly via orderIn/orderOut CALayer actions. Manually send visibility notifications to rasterized descendants.
2334
-
[self_recursiveWillEnterHierarchy];
2335
-
} else {
2336
-
[selfwillEnterHierarchy];
2332
+
2333
+
[selfwillEnterHierarchy];
2334
+
for (ASDisplayNode *subnode in self.subnodes) {
2335
+
[subnode __enterHierarchy];
2337
2336
}
2338
2337
_flags.isEnteringHierarchy = NO;
2339
2338
@@ -2369,13 +2368,10 @@ - (void)__exitHierarchy
2369
2368
2370
2369
[self.asyncLayer cancelAsyncDisplay];
2371
2370
2372
-
if (_flags.shouldRasterizeDescendants) {
2373
-
// Nodes that are descendants of a rasterized container do not have views or layers, and so cannot receive visibility notifications directly via orderIn/orderOut CALayer actions. Manually send visibility notifications to rasterized descendants.
2374
-
[self_recursiveDidExitHierarchy];
2375
-
} else {
2376
-
[selfdidExitHierarchy];
2371
+
[selfdidExitHierarchy];
2372
+
for (ASDisplayNode *subnode in self.subnodes) {
2373
+
[subnode __exitHierarchy];
2377
2374
}
2378
-
2379
2375
_flags.isExitingHierarchy = NO;
2380
2376
}
2381
2377
}
@@ -2416,19 +2412,13 @@ - (NSArray *)subnodes
2416
2412
return ([_subnodes copy] ?: @[]);
2417
2413
}
2418
2414
2415
+
// NOTE: This method must be dealloc-safe (should not retain self).
2419
2416
- (ASDisplayNode *)supernode
2420
2417
{
2421
2418
ASDN::MutexLocker l(__instanceLock__);
2422
2419
return _supernode;
2423
2420
}
2424
2421
2425
-
// This is a thread-method to return the supernode without causing it to be retained autoreleased. See -_removeSubnode: for details.
0 commit comments