This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
Refine geolocation params to (try to) avoid bugs #1087
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Pass an explicit
maximumAge
parameter to thegetCurrentPosition
call made in direction form, to allow the browser to reuse a "recent" position if it currently has one in cache.(Also use
enableHighAccuracy
, which seems relevant for the directions.)Why
Chromium/Webkit-based browsers seem to have issues with the geolocation.
https://bugs.chromium.org/p/chromium/issues/detail?id=586015
The default
maximumAge
is0
, in theory forcinggetCurrentPosition
to request a fresh position each time, but apparently this process may fail if awatchPosition
is running and hasn't updated the position recently (hinting about another level of internal cache mechanism…).By using an explicit
maximumAge
value, the browser is allowed to re-use immediately a previous position without requesting a new one, reducing the number of cases when it will fail.The 5 minutes value is a trade-off, it should match a majority of use cases of the app while ignoring really too old positions…