-
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
Location Services: don't reset desiredAccuracy on every update/error #23209
Conversation
See #7680. On iOS the RCTLocationObserver delegate is overriding the intended `desiredAccuracy` every time CLLocationManager calls `didUpdateLocations` or `didFailWitError`. `desiredAccuracy` is set to `RCT_DEFAULT_LOCATION_ACCURACY` (100 meters) This effectively makes it impossible for a react-native app to use any location accuracy other than the default. This commit simply removes the code which resets the desired accuracy, as there seems to be no rationale for doing so. The reset code was added as part of [a large general change](705a8e0) so the original intention is unclear from the history.
Well, this is an unlikely coincidence – since I started working on this PR a few hours ago a very similar one has been opened (#23207). Happy to unify if it makes sense to do so, although I'm not sure if there is 100% overlap. |
That one is not yet merged, so I think it's fine to continue working on this one for the time being. |
Did you observe the issue mentioned in the comment, "otherwise update accuracy will force triggering didUpdateLocations, watchPosition would keeping receiving location updates, even there's no location changes." in your fork? |
@hramos there's quite a lot to unpick here, so bear with me! This issue is absolutely critical for us (our users are often in mountainous back country, so precise GPS user location is critical for safety as well as usability) which is why we've been maintaining our fork for 11 months.
I dispute that this is a bug that needed fixing here, so much as an application issue. When setting It gets more complicated however, as the comment you mentioned was added in this commit which just adds this check:
to me this check alone makes absolutely zero sense. "If However, the actual code that I dispute –
– is added previously in this commit where the comment is simply 'Reset location accuracy'. I don't understand this either – when requesting a high accuracy position from the device, the device sends the first position with high accuracy (which will often be cached from earlier), and then this code resets the accuracy to 100m again, so all future positional updates will be wildly inaccurate! My interpretation of this is that it has been added in error. If I am missing something then I'd love to know what it is, because as it stands |
Thanks for the explanation! I agree this should be handled in product code. |
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.
@hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
Retrying because we had an import tooling issue. |
Reviewed By: @nicklockwood Differential Revision: D2519624 fb-gh-sync-id: 7366c5ac9e06082448b9fbba3c616aaf8e4183f9
…acebook#23209) Summary: See facebook#7680. On iOS the RCTLocationObserver delegate is overriding `desiredAccuracy` every time CLLocationManager calls `didUpdateLocations` or `didFailWithError`. `desiredAccuracy` is reset to `RCT_DEFAULT_LOCATION_ACCURACY` (100 meters) This effectively makes it impossible for a react-native app to use any location accuracy other than the default. This commit simply removes the code which resets the desired accuracy, as there seems to be no rationale for doing so. The reset code was added as part of [a large general change](facebook@705a8e0) so the original intention is unclear from the history. If somebody can explain it to me, I'm happy to rework this PR accordingly. Changelog: ---------- [iOS] [Fixed] - Location Services accuracy constantly reset to default of 100 meters. Pull Request resolved: facebook#23209 Differential Revision: D13879497 Pulled By: cpojer fbshipit-source-id: f3c6c9c5ef698b23b99c407fd764ac990d69bf8c
See #7680.
On iOS the RCTLocationObserver delegate is overriding
desiredAccuracy
every time CLLocationManager callsdidUpdateLocations
ordidFailWithError
.desiredAccuracy
is reset toRCT_DEFAULT_LOCATION_ACCURACY
(100 meters) This effectively makes it impossible for a react-native app to use any location accuracy other than the default.This commit simply removes the code which resets the desired accuracy, as there seems to be no rationale for doing so. The reset code was added as part of a large general
change so the original intention is unclear from the history. If somebody can explain it to me, I'm happy to rework this PR accordingly.
Changelog:
[iOS] [Fixed] - Location Services accuracy constantly reset to default of 100 meters.
Test Plan:
We've been using this in production at FATMAP for nearly a year in a fork of React Native. It works. I'm unclear on how to actually test this in code, so would appreciate any tips.