-
Notifications
You must be signed in to change notification settings - Fork 24.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
Add fix for refresh control state's race condition. #21763
Add fix for refresh control state's race condition. #21763
Conversation
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. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
|
can you add an e2e test? also release notes like |
|
Ping @matthargett: could you provide a quick guide for writing an e2e test for this PR? |
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 see in the originating issues that this doesn’t repro in a simulator, only on a real device. As such, never mind the e2e test ask.
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.
Alright, I'll land it. One thing to keep in mind here is because it is using local client time, changing the device time could break this behavior, no?
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Fails internally with:
Could you fix this up? @matthargett do you know if there is a way to enable the same error on React Native GitHub? This seems to come up frequently. |
Yes, I've got idea later that could be done by logical clock instead. |
Done. |
Thank you so much for the changes! @matthargett could you do a second review of this given that it is now using a slightly different approach? Thank you. |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
f76b815
to
786c7fc
Compare
- (void)setCurrentRefreshingState:(BOOL)refreshing | ||
{ | ||
_currentRefreshingState = refreshing; | ||
_currentRefreshingStateTimestamp = _currentRefreshingStateClock++; |
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.
currentRefreshingStateClock is never decremented. Was this meant to track/prevent other potential races where it could go above 1 or 2?
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.
@matthargett no, it shouldn't because I used logical clock. Every time refreshSetCurrentRefreshingState
is called i need unique timestamp. This time stamp is used in animation window which starts on
https://github.com/facebook/react-native/pull/21763/files#diff-cfafa8d7e42ab87ab863f917e187a4aeR56
and ends on
https://github.com/facebook/react-native/pull/21763/files#diff-cfafa8d7e42ab87ab863f917e187a4aeR70
and if timestamp is still the same, then state can be safely set, otherwise it should be thrown away due something else changed state and increased clock timestamp.
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've just changed that due i used local date time before, and as @cpojer has noted changing os date time can have impact on that logic. But in real life it wouldn't harm logic at all because chance that somebody changes os date time, and in that moment will trigger race condition described above, is astronomically low. But to prevent confusion, I've rid of that logic and replaced local date time with logical clock.
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@rostislav-simonik merged commit 95d399b into |
Fixes #21762
Test Plan:
Release Notes:
[BUGFIX][iOS][RefreshControl] Fix race condition that would overwrite state changes