Skip to content
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
merged 1 commit into from
May 20, 2021

Conversation

bbecquet
Copy link
Contributor

Description

Pass an explicit maximumAge parameter to the getCurrentPosition 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 is 0, in theory forcing getCurrentPosition to request a fresh position each time, but apparently this process may fail if a watchPosition 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…

@bbecquet bbecquet requested a review from amatissart May 20, 2021 14:06
Copy link
Contributor

@amatissart amatissart left a comment

Choose a reason for hiding this comment

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

It looks good to me after some tests on Linux and Android, for both Chrome and Firefox.

In some cases, I observed a geolocation timeout after repeated selections of "Your position" in the direction inputs, specifically on Firefox on my laptop. But that's not a new problem (already observed after #886), and I cannot find any reproducible pattern for this.

@bbecquet bbecquet merged commit fe4bec0 into Qwant:master May 20, 2021
@bbecquet bbecquet deleted the QMAPS-2134-fix-geoloc branch May 20, 2021 16:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants