Skip to content

Commit

Permalink
Remove _ASDisplayLayer's delegateDidChangeBounds flag
Browse files Browse the repository at this point in the history
We rely on the delegate setter to be called to set the flag. However, recent change on iOS 13 causes the setter to not be called at all and thus we had to put up a workaround (TextureGroup#1609). While the workaround works, the perf benefit of that the flag provides doesn't warranty the extra complexity IMO. So I think we should just remove everything.
  • Loading branch information
nguyenhuy committed Aug 15, 2019
1 parent 4caf951 commit 7eae7da
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
8 changes: 0 additions & 8 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,6 @@ - (void)_locked_loadViewOrLayer
_view = [self _locked_viewToLoad];
_view.asyncdisplaykit_node = self;
_layer = _view.layer;
// Needed to force `-[_ASDisplayLayer setDelegate:]` to evaluate
// It appears that UIKit might be setting the delegate ivar directly which
// bypasses establishing the `_delegateFlags` ivar on `ASDisplayLayer`
// This is critical for things like ASPagerNode, ASCollectionNode that depend
// on layer delegateFlags to forward bounds changes
if (_layer.delegate == _view) {
[_layer setDelegate:_view];
}
}
_layer.asyncdisplaykit_node = self;

Expand Down
13 changes: 1 addition & 12 deletions Source/Details/_ASDisplayLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,12 @@
@implementation _ASDisplayLayer
{
BOOL _attemptedDisplayWhileZeroSized;

struct {
BOOL delegateDidChangeBounds:1;
} _delegateFlags;
}

@dynamic displaysAsynchronously;

#pragma mark - Properties

- (void)setDelegate:(id)delegate
{
[super setDelegate:delegate];
_delegateFlags.delegateDidChangeBounds = [delegate respondsToSelector:@selector(layer:didChangeBoundsWithOldValue:newValue:)];
}

- (void)setDisplaySuspended:(BOOL)displaySuspended
{
ASDisplayNodeAssertMainThread();
Expand All @@ -59,12 +49,11 @@ - (void)setBounds:(CGRect)bounds
if (!valid) {
return;
}
if (_delegateFlags.delegateDidChangeBounds) {
if ([self.delegate respondsToSelector:@selector(layer:didChangeBoundsWithOldValue:newValue:)]) {
CGRect oldBounds = self.bounds;
[super setBounds:bounds];
self.asyncdisplaykit_node.threadSafeBounds = bounds;
[(id<ASCALayerExtendedDelegate>)self.delegate layer:self didChangeBoundsWithOldValue:oldBounds newValue:bounds];

} else {
[super setBounds:bounds];
self.asyncdisplaykit_node.threadSafeBounds = bounds;
Expand Down

0 comments on commit 7eae7da

Please sign in to comment.