-
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
Fix capturing self in the block while loading image in ASNetworkImageNode #777
Fix capturing self in the block while loading image in ASNetworkImageNode #777
Conversation
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.
Very good catch @morozkin thank you!
Source/ASNetworkImageNode.mm
Outdated
if (strongSelf == nil) { | ||
return; | ||
} | ||
|
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.
I believe this code should stay – we want to "re-strongify" when we reach the main thread.
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.
I can't understand you intention for doing such thing because strongSelf
is already captured and can't pass away
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.
strongSelf
will be released at the end of the ASPerformBlockOnBackgroundThread block, which may happen before the main thread services our ASPerformBlockOnMainThread call.
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.
So its imporrant that the main thread block not capture strongSelf, and instead capture weakSelf and then attempt to retain it
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.
Thanks for explanation. I’ve understood your intention. I supposed that it isn’t critical to capture strongSelf in this case because there are only delegate calls inside the block. I will revert my change
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.
Cool, thanks.
@morozkin If you'll add an entry to the changelog, we'll be ready to merge this. |
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.
Thanks!
…Node (#777) * Fix capturing self in the block while loading image in ASNetworkImageNode * Restore re-strongify while switching on the main thread * Update CHANGELOG.md
…Node (TextureGroup#777) * Fix capturing self in the block while loading image in ASNetworkImageNode * Restore re-strongify while switching on the main thread * Update CHANGELOG.md
No description provided.