Description
Here's what the current spec says:
-
The
watchPosition()
algorithm just passes the wholeoptions
to "request a position" steps. -
The "request a position" steps says it should wait for a change at step 7.5.1:
Wait for a significant change of geographic position. What constitutes a significant change of geographic position is left to the implementation. User agents MAY impose a rate limit on how frequently position changes are reported.
-
But before that, at step 7.3 it calls "acquire a position" again with the whole
options
. -
And "acquire a position" creates the timeout task regardless of the existence of
watchId
.
And in the description of timeout
it has a non-normative note that says:
An options.timeout value 0 can cause immediate failures.
And browsers work differently:
- With
timeout: 0
:- Safari halts immediately
- Chrome immediately triggers error callback and still calls success callback
- Firefox silently does nothing.
- With
timeout: 1
:- Safari errors immediately and still proceeds to call success callback
- Chrome behaves similar to Safari, but on Windows the initial call succeeds without any error
- Firefox keeps triggers the error callback as if it's `setInterval(errorCallback, 1);
- With
timeout: 1000
:- The initial call succeeds without any error for both Safari and Chrome. The following calls still trigger the error callback after 1 sec. The success callback is triggered later in any case.
- Firefox still repeatedly triggers the error callback.
Certainly Firefox is bugged here, but I'm not sure the point to time out for watchPosition when it's still expected to proceed after that. We are getting webcompat reports where websites consider the error callback as a full error instead of just "taking time to get the initial position". (See the "Blocks" references in https://bugzilla.mozilla.org/show_bug.cgi?id=1920302)
Should we consider removing timeout from watchPosition, or is there a known real-world use case for the initial timeout?