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

Fix capturing self in the block while loading image in ASNetworkImageNode #777

Conversation

morozkin
Copy link
Contributor

No description provided.

Copy link
Member

@Adlai-Holler Adlai-Holler left a 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!

if (strongSelf == nil) {
return;
}

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks.

@Adlai-Holler
Copy link
Member

@morozkin If you'll add an entry to the changelog, we'll be ready to merge this.

Copy link
Member

@Adlai-Holler Adlai-Holler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Adlai-Holler Adlai-Holler merged commit 511bec6 into TextureGroup:master Jan 31, 2018
Adlai-Holler pushed a commit that referenced this pull request Jan 31, 2018
…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
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
…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
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

Successfully merging this pull request may close these issues.

2 participants