-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[ASDisplayNode] Always return the thread-safe cornerRadius property, even in slow CALayer rounding mode #749
[ASDisplayNode] Always return the thread-safe cornerRadius property, even in slow CALayer rounding mode #749
Conversation
} | ||
|
||
- (void)setCornerRadius:(CGFloat)newCornerRadius | ||
{ | ||
ASDN::MutexLocker l(__instanceLock__); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-updateCornerRoundingWithType:cornerRadius:
acquires the lock itself (here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Looking over this PR and the initial PR I think we could remove the layerCornerRadius
getter / setter now and set the value directly in updateCornerRoundingWithType:cornerRadius:
.
84d114a
to
5b13c16
Compare
…layNode, even in slow CALayer rounding type - Failing to do so will introduce race conditions in which the property was updated on a background thread but main thread has not executed the block that updates the property of the node's layer. During that window, the layer's property is out-of-date and can't be used. - After this change, ASDisplayNode's cornerRadius is the only source of truth and users must always use it instead of CALayer's.
5b13c16
to
af5cc07
Compare
@@ -207,7 +202,6 @@ - (ASCornerRoundingType)cornerRoundingType | |||
|
|||
- (void)setCornerRoundingType:(ASCornerRoundingType)newRoundingType | |||
{ | |||
ASDN::MutexLocker l(__instanceLock__); | |||
[self updateCornerRoundingWithType:newRoundingType cornerRadius:_cornerRadius]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this public? Think we should read self.cornerRadius
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeap, nice catch!
…even in slow CALayer rounding mode (TextureGroup#749) - Failing to do so will introduce race conditions in which the property was updated on a background thread but main thread has not executed the block that updates the property of the node's layer. During that window, the layer's property is out-of-date and can't be used. - After this change, ASDisplayNode's cornerRadius is the only source of truth and users must always use it instead of CALayer's.
cornerRadius
of the node's layer, the layer's property is out-of-date and shouldn't be used.Relevant PR: #465.
Recorded bug here - Pay attention to the "Save" button on the top right corner.