Closed Bug 1920302 Opened 11 months ago Closed 5 months ago

Geolocation API watchPosition() sends errors when timeout is set

Categories

(Core :: DOM: Geolocation, defect)

Firefox 130
Unspecified
All
defect

Tracking

()

RESOLVED FIXED
139 Branch
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.

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.

Component: Untriaged → DOM: Geolocation
Product: Firefox → Core
OS: Unspecified → macOS
Hardware: Unspecified → ARM64
Severity: -- → S3
Webcompat Priority: --- → ?

(Confirming. Off topic but interesting to see that the GLS backend fires success callback every one second)

Status: UNCONFIRMED → NEW
Ever confirmed: true

No known site breakage, only a testcase on CodePen, so we can't prioritize this.

Webcompat Priority: ? → ---

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.

I forgot to add the CodePen πŸ™ƒ

https://codepen.io/AsgMog/pen/WNVPqzR

"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?

Flags: needinfo?(dschubert)
OS: macOS → All

I'll bring this up in our next triage meeting! Thanks for the ping.

Webcompat Priority: --- → ?
Flags: needinfo?(dschubert)

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.

Webcompat Priority: ? → ---

(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.

Flags: needinfo?(krosylight)

That was only to reflect the platform of the initial report, but maybe we can leave it unspecified here.

Flags: needinfo?(krosylight)
Hardware: ARM64 → Unspecified
Assignee: nobody → krosylight
Status: NEW → ASSIGNED

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).

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.

User Story: (updated)
Attachment #9476044 - Attachment description: Bug 1920302 - Disable timeout for watchPosition r=smaug → Bug 1920302 - Do not start timer repeatedly for watchPosition r=smaug
Pushed by krosylight@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c45d26a0bc76 Do not start timer repeatedly for watchPosition r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/51794 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch
Upstream PR merged by moz-wptsync-bot
QA Whiteboard: [qa-triage-done-c140/b139]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: