Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on node deallocation when using cornerRoundingType == .clipping #1020

Closed
yxztj opened this issue Jul 11, 2018 · 0 comments
Closed

Crash on node deallocation when using cornerRoundingType == .clipping #1020

yxztj opened this issue Jul 11, 2018 · 0 comments
Assignees

Comments

@yxztj
Copy link
Contributor

yxztj commented Jul 11, 2018

Sample code is just a few lines, creating a plain ASDisplayNode, setting cornerRadius/ cornerRoundingType, and adding it to a view:
https://github.com/yxztj/cornerRoundingCrash

If you run the code directly, it would hit the assert in ASDisplayNode(CALayerDelegate) method "actionForLayer:forKey", as mentioned in #910. This looks strange because the 4 _clipCornerLayers are setting "self" as layerDelegate, but the delegate method needs self to be isLayerBacked == true(sometimes we need subnodes to receive touch events so we can't set isLayerBacked). Seems this delegate method isn't for the clipping layers?

And if I try to comment out the assert code(same effect as release build), or just return nil in the delegate method(shouldn't affect because the node is not layerBacked), the app crashes when we remove the node from parent view.

Call stack:
screen shot 2018-07-11 at 5 58 06 pm

Turning on Zombie Objects in build scheme and we get:

2018-07-11 17:49:13.871070+0800 cornerClippingCrash[19362:291616] *** -[ASDisplayNode isKindOfClass:]: message sent to deallocated instance 0x7fe735c05c40

Looks like UIKit is calling the clippingLayer's delegate(aka the node) for some work, but the node has already been deallocated in [ASDisplayView didMoveToSuperView:]
If we don't set the node as clippingLayer's delegate, the issue is gone. Is it possible not to set the delegate?
@nguyenhuy @appleguy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants