Geolocation API watchPosition() sends errors when timeout is set
Categories
(Core :: DOM: Geolocation, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox139 | --- | fixed |
People
(Reporter: asgermog, Assigned: saschanaz)
References
Details
(Keywords: parity-chrome, parity-safari, webcompat:platform-bug)
User Story
platform-scheduled:2025-6-30
Attachments
(1 file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:130.0) Gecko/20100101 Firefox/130.0
Steps to reproduce:
function success(position) {
console.log(position.coords.latitude, position.coords.longitude);
}
function error() {
alert("Sorry, no position available.");
}
const options = {
enableHighAccuracy: true,
maximumAge: 30000,
timeout: 27000,
};
const watchID = navigator.geolocation.watchPosition(success, error, options);
https://codepen.io/AsgMog/pen/KKOPywg
Actual results:
This code is supposed to watch the users position. It gives the position correctly the first time, but aftwards it gives an error every "timeout" miliseconds.
Expected results:
The position should have been returned every time it changed and only return a timeout if it actually timeouted.
On both Safari and Chrome it works like this.
Comment 1•11 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Geolocation' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Assignee | ||
Updated•11 months ago
|
Updated•11 months ago
|
Assignee | ||
Comment 2•11 months ago
|
||
(Confirming. Off topic but interesting to see that the GLS backend fires success callback every one second)
Comment 3•9 months ago
|
||
No known site breakage, only a testcase on CodePen, so we can't prioritize this.
Assignee | ||
Updated•9 months ago
|
Reporter | ||
Comment 4•9 months ago
|
||
A problem is, that it affects Leaflet when trying to watch a user's location. Since Leaflet is widely used I imagine that it must be an issue for a few developers.
Here is a CodePen with the leaflet issue. The timeout value is 10000 milliseconds per the default.
Reporter | ||
Comment 5•9 months ago
|
||
I forgot to add the CodePen π
Assignee | ||
Comment 6•5 months ago
|
||
"Platform: All" given it affects Android too. (Linux is only partially affected by geoclue fallback timeout which also should not happen for watchPosition. Windows is not affected.)
Dennis, should we revisit comment #3?
Comment 7•5 months ago
|
||
I'll bring this up in our next triage meeting! Thanks for the ping.
Updated•5 months ago
|
Comment 8•5 months ago
|
||
Removing the WebCompat priority here. We automatically calculate the priority based on the sum of the scores of all dependent bugs, and those are triaged correctly. Eventually(tm), we might want to have BugBot update the flags for core bugs, but we don't need to do anything for now.
Comment 9•5 months ago
|
||
(In reply to Kagami Rosylight [:saschanaz] (they/them) (OOO until 2025-03-29) from comment #6)
"Platform: All" given it affects Android too. (Linux is only partially affected by geoclue fallback timeout which also should not happen for watchPosition. Windows is not affected.)
Just to understand the Platform: ARM64
flag better: That actually wants to capture MacOS and Android, but not Windows on ARM, I assume ? If so I wonder if it is not just confusing to set anything here given the lack of multiple selections for the OS.
Assignee | ||
Comment 10•5 months ago
|
||
That was only to reflect the platform of the initial report, but maybe we can leave it unspecified here.
Assignee | ||
Comment 11•5 months ago
|
||
Updated•5 months ago
|
Assignee | ||
Comment 12•5 months ago
|
||
Filed a spec bug. I think the easiest way to deal with the issue is just to disable the timeout feature for watchPosition
. If that turns out to be problematic then we can try to follow other engines' behavior to only allow initial timeout (but their current behavior doesn't fully make sense either).
Comment 13•5 months ago
|
||
Thanks for taking this bug, Kagami.
I tentatively added platform-scheduled:2025-06-30
given that a patch is in review. If this needs more effort to mimic other browsers' behavior, please let me know and we can revise the scheduled info.
Updated•5 months ago
|
Comment 14•5 months ago
|
||
Comment 16•5 months ago
|
||
bugherder |
Updated•4 months ago
|
Description
•