diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index d340108403..27c08e8e58 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -284,7 +284,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) _defaultLayoutTransitionOptions = UIViewAnimationOptionBeginFromCurrentState; _flags.canClearContentsOfLayer = YES; - _flags.canCallNeedsDisplayOfLayer = NO; + _flags.canCallSetNeedsDisplayOfLayer = YES; } - (instancetype)init @@ -454,12 +454,9 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) } // Update flags related to special handling of UIImageView layers. More details on the flags - if (_flags.synchronous) { - if ([view isKindOfClass:[UIImageView class]]) { - _flags.canClearContentsOfLayer = NO; - } else { - _flags.canCallNeedsDisplayOfLayer = YES; - } + if (_flags.synchronous && [_viewClass isSubclassOfClass:[UIImageView class]]) { + _flags.canClearContentsOfLayer = NO; + _flags.canCallSetNeedsDisplayOfLayer = NO; } return view; @@ -2056,11 +2053,11 @@ static NSInteger incrementIfFound(NSInteger i) { _flags.implementsInstanceDrawRect || _flags.implementsInstanceImageDisplay; } -// Helper method to determine if it's save to call setNeedsDisplay on a layer without throwing away the content. -// For details look at the comment on the canCallNeedsDisplayOfLayer flag -- (BOOL)__canCallNeedsDisplayOfLayer +// Helper method to determine if it's safe to call setNeedsDisplay on a layer without throwing away the content. +// For details look at the comment on the canCallSetNeedsDisplayOfLayer flag +- (BOOL)__canCallSetNeedsDisplayOfLayer { - return _flags.canCallNeedsDisplayOfLayer; + return _flags.canCallSetNeedsDisplayOfLayer; } - (BOOL)placeholderShouldPersist @@ -2111,9 +2108,10 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) ASDisplayNode *node = [layer asyncdisplaykit_node]; - if ([node __canCallNeedsDisplayOfLayer]) { - // Layers for UIKit components that are wrapped wtihin a node needs to be set to be displayed as the contents of - // the layer get's cleared and would not be recreated otherwise + if (node.isSynchronous && [node __canCallSetNeedsDisplayOfLayer]) { + // Layers for UIKit components that are wrapped within a node needs to be set to be displayed as the contents of + // the layer get's cleared and would not be recreated otherwise. + // We do not call this for _ASDisplayLayer as an optimization. [layer setNeedsDisplay]; } diff --git a/AsyncDisplayKit/Private/ASDisplayNodeInternal.h b/AsyncDisplayKit/Private/ASDisplayNodeInternal.h index c1d09979f4..3e9bc3985b 100644 --- a/AsyncDisplayKit/Private/ASDisplayNodeInternal.h +++ b/AsyncDisplayKit/Private/ASDisplayNodeInternal.h @@ -83,10 +83,10 @@ FOUNDATION_EXPORT NSString * const ASRenderingEngineDidDisplayNodesScheduledBefo // Prevent calling setNeedsDisplay on a layer that backs a UIImageView. Usually calling setNeedsDisplay on a CALayer // triggers a recreation of the contents of layer unfortunately calling it on a CALayer that backs a UIImageView - // it goes trough the normal flow to assign the contents to a layer via the CALayerDelegate methods. Unfortunately + // it goes through the normal flow to assign the contents to a layer via the CALayerDelegate methods. Unfortunately // UIImageView does not do recreate the layer contents the usual way, it actually does not implement some of the // methods at all instead it throws away the contents of the layer and nothing will show up. - unsigned canCallNeedsDisplayOfLayer:1; + unsigned canCallSetNeedsDisplayOfLayer:1; // whether custom drawing is enabled unsigned implementsInstanceDrawRect:1;