New issue
Advanced search Search tips

Issue 769231 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug-Regression



Sign in to add a comment

navigator.geolocation.getCurrentPosition ignores maximumAge

Reported by amueller...@gmail.com, Sep 27 2017

Issue description

Steps to reproduce the problem:
1. start geo.html 
2. click "show position"
3. change your position, wait some time and then click "show position" again

What is the expected behavior?
The coordinates should be changing

What went wrong?
you will always get the same coordinates

Did this work before? Yes sorry i do not know the version of chrome but is not long ago 

Does this work in other browsers? Yes

Chrome version: Chrome 61.0.3163.98  Channel: n/a
OS Version: 5.1.1
Flash Version: 

It works with firefox.
It also do not work with chrome 62 and 63.
maximAge works with watchposition
 
geo.html
1.4 KB View Download

Comment 1 by scheib@chromium.org, Sep 27 2017

Owner: juncai@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 2 by juncai@chromium.org, Sep 28 2017

Status: Started (was: Assigned)
Cc: juncai@chromium.org
Owner: ----
Status: Available (was: Started)
I did some tests on Android using the geo.html, and sometimes the position is the same even when the device is moved, but not always.
i use a sony z-Ultra and the android setting for location is "device only". The position coming from getCurrentPostion is always the same. Only if an other app use the GPS, then there is a new position.
The same works very well with older chrome versions in the past.
Owner: mattreynolds@chromium.org
Status: Started (was: Available)
I can repro this reliably but only with Android Location set to "Device only".

I see two issues:

Neither getCurrentPosition nor watchPosition check that the returned location is younger than the maximumAge. In both cases we grab the first position estimate from the location provider and return it immediately. Instead, we should reject any estimate older than maximumAge and wait for new data.

Second, we don't stay subscribed to the location service long enough to trigger a new GPS fix. Earlier this year we switched the default location provider from Android's LocationManager to Google Play Services' FusedLocationProviderApi. In "Device only" mode it appears that subscribing to the API just long enough to request the current position estimate always returns a cached estimate. With Android Location set to "High accuracy", position updates are much more frequent and cached estimates are rarer.

To fix, Geolocation should ignore stale position estimates but stay subscribed to the location provider. This will make it more likely that a new GPS position estimate will be available before the call times out.
Components: Blink>Geolocation
Components: -Blink>Location
I tested the behavior of other browsers to help us determine how fixing this bug will affect existing web content.

Firefox 56:

maximumAge is handled correctly. Firefox will prefer to return a cached estimate when available, as long as the age of the estimate is less than maximumAge. When maximumAge is zero, returned estimates are always newer than the call to getCurrentPosition. Firefox appears to do some rate limiting; when maximumAge is zero (indicating we want a fresh estimate) the callbacks from subsequent calls can be delayed by as much as five seconds.

Edge 38.14393.1066.0:

Edge does not handle maximumAge correctly. It's possible Edge never caches position estimates and always returns new estimates. Setting maximumAge:Infinity, timeout:0 (indicating we want a cached estimate of any age) fails with TIMEOUT, even after previous geolocation calls succeed in returning an estimate.

Safari 10.1.2 (12603.3.8):

Safari doesn't recognize "Infinity" as a valid timeout value, so I used 1000000 instead. The timestamp returned with the position estimate uses the wrong epoch (Jan 1, 2001 UTC). Correcting for this, it appears that sometimes Safari will return an estimate that is older than maximumAge. This is most common after a long period of inactivity, and does not persist (ie, the next call will usually return a timestamp younger than maximumAge). This occurs even when maximumAge is zero. When a cached estimate is requested (maximumAge:1000000, timeout:0), it always fails with TIMEOUT even if a recent geolocation call succeeded.

Internet Explorer 11.1770.14393.0

A position estimate is only returned on the first call to getCurrentPosition, subsequent calls fail with POSITION_UNAVAILABLE. Timeout:0 is not handled properly and will always fail with TIMEOUT, even when a cached estimate is available.
Project Member

Comment 9 by bugdroid1@chromium.org, Dec 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7

commit 827f73a3b5021bb2ce9b3b51a63f5aa9471198e7
Author: Matt Reynolds <mattreynolds@google.com>
Date: Thu Dec 07 21:59:51 2017

Reject stale geolocation estimates

The Geolocation API allows callers to specify a maximum age when
requesting the current location. If the most recent location fix is
older, the API specifies that a new estimate should be returned.

With this CL, if we receive a location estimate that is too old to
satisfy the maximum age option, we will now wait for the provider to
provide a new estimate.

BUG= 769231 

Change-Id: I2bea9a6df5327bc21e81e1154c6dfa25ef5c40c9
Reviewed-on: https://chromium-review.googlesource.com/703976
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522568}
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/cached-position-called-once.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/callback-exception.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/callback-to-remote-context.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/callback-to-remote-context2.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/coordinates-interface-attributes.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/delayed-permission-allowed-for-multiple-requests.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/delayed-permission-allowed.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/delayed-permission-denied-for-multiple-requests.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/delayed-permission-denied.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/disconnected-frame-already.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/disconnected-frame-permission-denied.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/disconnected-frame.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/error-clear-watch.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/maximum-age.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/multiple-requests.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/permission-denied-already-clear-watch.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/permission-denied-already-error.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/permission-denied-already-success.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/permission-denied-stops-watches.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/permission-denied.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/position-string.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/reentrant-permission-denied.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/reentrant-success.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/resources/callback-to-deleted-context-inner1.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/resources/geolocation-mock.js
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/resources/window-close-popup.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/success-clear-watch.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/success.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/timeout-negative-expected.txt
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/timeout-negative.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/timeout-over-max-of-unsigned.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/timeout-zero-expected.txt
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/timeout-zero.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/timeout.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/timestamp.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/watch.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/geolocation-api/watchPosition-page-visibility.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/http/tests/devtools/geolocation-emulation-tests.js
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/LayoutTests/http/tests/geolocation-api/geolocation-default-feature-policy.https.sub.html
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/Source/modules/geolocation/GeoNotifier.cpp
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/Source/modules/geolocation/GeoNotifier.h
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/Source/modules/geolocation/Geolocation.cpp
[modify] https://crrev.com/827f73a3b5021bb2ce9b3b51a63f5aa9471198e7/third_party/WebKit/Source/modules/geolocation/Geolocation.h

Status: Fixed (was: Started)
Project Member

Comment 11 by bugdroid1@chromium.org, Dec 8 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2291dbccada8799f4c706a223a62cb20648e02ea

commit 2291dbccada8799f4c706a223a62cb20648e02ea
Author: Maxim Kolosovskiy <kolos@chromium.org>
Date: Fri Dec 08 10:48:54 2017

Revert "Reject stale geolocation estimates"

This reverts commit 827f73a3b5021bb2ce9b3b51a63f5aa9471198e7.

Reason for revert: 
Broken test geolocation-api/maximum-age.html
since https://uberchromegw.corp.google.com/i/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/65059

Original change's description:
> Reject stale geolocation estimates
> 
> The Geolocation API allows callers to specify a maximum age when
> requesting the current location. If the most recent location fix is
> older, the API specifies that a new estimate should be returned.
> 
> With this CL, if we receive a location estimate that is too old to
> satisfy the maximum age option, we will now wait for the provider to
> provide a new estimate.
> 
> BUG= 769231 
> 
> Change-Id: I2bea9a6df5327bc21e81e1154c6dfa25ef5c40c9
> Reviewed-on: https://chromium-review.googlesource.com/703976
> Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
> Reviewed-by: Mike West <mkwst@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#522568}

TBR=mattreynolds@chromium.org,mkwst@chromium.org

Change-Id: I3b32186363734f56570aa3087a7fda432bc5d17d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug:  769231 
Reviewed-on: https://chromium-review.googlesource.com/816994
Reviewed-by: Maxim Kolosovskiy <kolos@chromium.org>
Commit-Queue: Maxim Kolosovskiy <kolos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522756}
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/cached-position-called-once.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/callback-exception.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/callback-to-remote-context.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/callback-to-remote-context2.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/coordinates-interface-attributes.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/delayed-permission-allowed-for-multiple-requests.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/delayed-permission-allowed.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/delayed-permission-denied-for-multiple-requests.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/delayed-permission-denied.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/disconnected-frame-already.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/disconnected-frame-permission-denied.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/disconnected-frame.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/error-clear-watch.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/maximum-age.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/multiple-requests.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/permission-denied-already-clear-watch.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/permission-denied-already-error.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/permission-denied-already-success.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/permission-denied-stops-watches.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/permission-denied.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/position-string.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/reentrant-permission-denied.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/reentrant-success.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/resources/callback-to-deleted-context-inner1.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/resources/geolocation-mock.js
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/resources/window-close-popup.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/success-clear-watch.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/success.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/timeout-negative-expected.txt
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/timeout-negative.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/timeout-over-max-of-unsigned.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/timeout-zero-expected.txt
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/timeout-zero.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/timeout.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/timestamp.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/watch.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/geolocation-api/watchPosition-page-visibility.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/http/tests/devtools/geolocation-emulation-tests.js
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/LayoutTests/http/tests/geolocation-api/geolocation-default-feature-policy.https.sub.html
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/Source/modules/geolocation/GeoNotifier.cpp
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/Source/modules/geolocation/GeoNotifier.h
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/Source/modules/geolocation/Geolocation.cpp
[modify] https://crrev.com/2291dbccada8799f4c706a223a62cb20648e02ea/third_party/WebKit/Source/modules/geolocation/Geolocation.h

Issue doesn't repro on latest M65 as per the above steps, coordinates changes when we change the position. Thanks 

Sign in to add a comment