Skip to content

The timeout option doesn't make sense for watchPosition #184

Open
@saschanaz

Description

@saschanaz

Here's what the current spec says:

  1. The watchPosition() algorithm just passes the whole options to "request a position" steps.

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

  3. But before that, at step 7.3 it calls "acquire a position" again with the whole options.

  4. 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:

  1. With timeout: 0:
    • Safari halts immediately
    • Chrome immediately triggers error callback and still calls success callback
    • Firefox silently does nothing.
  2. 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);
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions