-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Execute cancel block in the _URLRequestQueue #10280
Conversation
By analyzing the blame information on this pull request, we identified @skatpgusskat and @javache to be potential reviewers. |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
@javache this seems roughly right -- we want the cancellation block, or at least parts of it, to run on the URL request queue. I'm not sure this specific solution is the best way to go about things, though, since the cancellation block modified in this PR is sometimes wrapped in other cancellation blocks that we might want to run on the URL request queue too. With this PR: other methods' cancellation blocks invoke What I'm thinking: other methods' (specifically public methods) cancellation blocks dispatch to the URL request queue and invoke |
@ide In some cases (https://github.com/facebook/react-native/blob/master/Libraries/Image/RCTImageLoader.m#L342) we must not call cancellation block returned by _loadImageOrDataWithURLRequest on the URL request queue. So, i think that _loadImageOrDataWithURLRequest is responsible for dispatching cancellation block to the appropriate queue. |
Does this commit possible address the issue? |
@christopherdro maybe someone else can confirm this, but I've actually been able to still reliably trigger the error even on current master including the commit you mentioned. More precisely, after 1a62b66 I was still able to trigger the bug, but I noticed it was a bit harder to trigger. So my guess is this commit was incomplete on covering all breaking cases. After applying this PR I can't anymore trigger the bug, so thanks to @sooth-sayer. |
cancelLoad = nil; | ||
} | ||
OSAtomicOr32Barrier(1, &cancelled); | ||
dispatch_async(_URLRequestQueue, ^{ |
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.
Looks reasonable but could you structure it like this? Also, you'll need to use weakSelf / strongSelf to access _URLRequestQueue
? Right now this will retain self.
return ^{
typeof(self) strongSelf = weakSelf;
if (strongSelf && !cancelled) {
dispatch_async(strongSelf->_URLRequestQueue, ^{
if (cancelLoad) {
cancelLoad();
cancelLoad = nil;
}
});
OSAtomicOr32Barrier(1, &cancelled);
};
Even better would be to put this dispatch inside the block that does the actual cancelling. |
@sooth-sayer updated the pull request - view changes |
@javache Do you mean that we should put dispatch inside
? |
I've got a fix up for this internally which includes your changes. I'll try land it later today, thanks! |
@javache Ok, 👍 |
@javache Are you able to estimate when a version will be released that includes this fix? Is that what you meant by "land it later today" above? |
@avilyn if it lands today or in the next few days it will go out with 0.37 (ETA 4 weeks) and we would probably cherry pick it back into 0.36 (ETA 2 weeks, currently in RC so you can use it now). |
Summary: Fix suggested by sooth-sayer (#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
@ide Perfect, thank you. |
Landed in 26be005 I'll ask for it to be picked 0.36 too. |
Summary: Fix suggested by sooth-sayer (facebook#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
Summary: Fix suggested by sooth-sayer (#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
Summary: Fix suggested by sooth-sayer (facebook#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
Summary: Fix suggested by sooth-sayer (facebook#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
Summary: Fix suggested by sooth-sayer (facebook#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
Summary: Fix suggested by sooth-sayer (facebook#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
Summary: Fix suggested by sooth-sayer (facebook#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
Summary: Fix suggested by sooth-sayer (facebook#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76 (cherry picked from commit 64dd140)
Summary: Fix suggested by sooth-sayer (facebook#10280) Reviewed By: mmmulani Differential Revision: D4001618 fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
Fixes #10274