Geolocation should not use FusedLocationProviderApi BALANCED_POWER in GPS-only mode
Reported by
tonygarn...@gmail.com,
Jun 14 2016
|
|||||||||||||
Issue descriptionDevice name: - Xperia Z2, Cyanogenmod 12.1, Android 5.1.1 - (bug also manifests on Samsung S7, Stock ROM, Android 6.0.1) From "Settings > About Chrome" Application version: Chrome 51.0.2704.81 OS: Android 5.1.1; Xperia Z2 Build/LMY49J URLs (if applicable): https://stockholm.ccs.neu.edu/~tonyg/chrome-geolocation-problem/ Behavior in Android Browser (if applicable): Same as Chrome; Chrome DEV is also the same Steps to reproduce: (1) Ensure that location-tracking is set to GPS ONLY (2) Visit https://stockholm.ccs.neu.edu/~tonyg/chrome-geolocation-problem/ (3) Allow the request to use location information (4) Notice that GPS results are never given; neither results nor error callback are invoked; notice also that the little pin indicating location tracking does not appear in the toolbar Expected result: watchPosition should yield results, even in GPS-ONLY mode. Actual result: watchPosition does not yield results in Chrome in GPS-ONLY mode. - - - Here's the index.html at that URL: <!doctype html> <meta charset="utf-8"> <body> <pre id="loc"></pre> <pre id="err"></pre> <script> var watchId = navigator.geolocation.watchPosition(function (pos) { console.log(pos); document.getElementById('loc').innerText = JSON.stringify({ latitude: pos.coords.latitude, longitude: pos.coords.longitude, timestamp: pos.timestamp }, null, 2); }, function (err) { console.log(err); document.getElementById('err').innerText = JSON.stringify(err, null, 2); }); console.log('watchId', watchId); </script> </body> I get position information (and the pin appears in the toolbar indicating that location-tracking is active) in all of the following circumstances: - Firefox Android, location set to "high accuracy" (i.e. GPS+wifi) - Firefox Android, location set to "device only" (i.e. GPS-only) - Chrome Android, location set to "high accuracy" (i.e. GPS+wifi) - Firefox for desktop/PC - Chrome for desktop/PC - Safari for desktop/PC but I do NOT get any response from watchPosition at all when using Chrome, Chrome DEV, or the default browser on Android with location set to "device only" (i.e. GPS-only). Neither of the callbacks is ever invoked (evidence: I never see anything from those console.log statements).
,
Jun 14 2016
Bug also manifests with: Chrome 51.0.2704.81, Android 5.0.1; SCH-I545 Build/LRX22C
,
Jun 17 2016
,
Jan 15 2017
Bug also seen in:
Chrome 55.0.2883.91, Android 6.0.1; Honor 5X Build: KIW-l22c675B360.
Behaviour: No response (success/error) in all modes, ie,
High accuracy: GPS + wifi + mobile,
Battery saving - Wifi and mobile
Device only - Use GPS only
Firefox 50.1.0 giving instant results in High accuracy.
code:
navigator.geolocation.watchPosition(function(d){
sp.writeSpeed(d);
}, function error(err) {
$('#error').html('ERROR(' + err.code + '): ' + err.message)
}, {
enableHighAccuracy: true,
maximumAge: 0
});
,
Oct 31 2017
Confirm the issue. No way to get position with the GPS only settings who is now the default option on lot off phone. related to this Cordova issue who concludes in a chromium issue : https://issues.apache.org/jira/browse/CB-13241
,
Apr 4 2018
tonygarnockjones@ -- Thanks for reporting this issue. Request you to update your Chrome to latest #65.0.3325.109 and let us know your observations.
,
Apr 12 2018
pnangunoori@6 - Unfortunately, I still see the same symptoms with Chrome 65.0.3325.109. (The URL supplied above is no longer responsive, but I have the same code available at https://eighty-twenty.org/~tonyg/location.html, if you'd like to reproduce the issue.)
,
Apr 12 2018
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Apr 12 2018
,
Apr 13 2018
Tested on Pixel 2 Android 8.1.0, Samsung J7 Android 7.0.0 and Sony C6902 Android 4.4.4 on latest Chrome #65.0.3325.109 and Canary #67.0.3395.0 and able to Latitude, Longitude and Time stamp details after enabling location on the device. Could you please share the screen cast of the issue observed at your end for the better understanding. Please let us know if we have missed anything. Attached screenshot for reference. Thanks!
,
Apr 13 2018
Notice there is no GPS icon (the "pin" icon) in the system toolbar in your screenshot. Was your phone set to use GPS *only* for location? That is the problem at hand: location works with wifi-only, and wifi+GPS, but does not work with GPS only.
,
Apr 13 2018
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Apr 16 2018
tonygarnockjones@ -- Yes, we have selected "Device Only - User GPS to determine location' in device settings and able to get Latitude, Longitude and Time stamp details after enabling location on the device. Is the issue reproduced on all the networks at your end or for any specific network. Thanks!
,
Apr 25 2018
Assigning to mattreynolds@ to investigate potential next steps as we continue to be unable to reproduce this issue.
,
Apr 26 2018
Hi Tony, thanks for reporting this and providing the test page. I'm able to repro this reliably on two devices: Nexus 5X, Android 8.0.0, Chrome 66.0.3359.126 Pixel 1, Android 8.1.0, Chrome 66.0.3359.126 In both cases a blank page was displayed, indicating no position estimate was provided and no errors were encountered. There is no GPS icon displayed in the toolbar, indicating we are probably not attempting to acquire a new estimate even though we have an active watchPosition.
,
Apr 27 2018
@mattreynolds, I'm glad you see the same symptoms as I do! Does using another browser (e.g. Firefox) work (yielding a location or error, plus a GPS icon) on those two devices? @pnangunoori, it's interesting that it works for you. On the screenshots you posted, I don't see anything I recognise as a GPS icon - am I just out-of-date wrt what that icon looks like in recent Android, or is it in fact not there? Either way, to answer your other question: the issue is reproduced on all wifi networks and also on my cellular data plan (LTE; three.co.uk), fwiw.
,
Apr 27 2018
Both Chrome and Google Play Services retain the last position estimate. To get around this, I've been restarting the device between trials. I suspect pnangunoori had some cached data when trying to repro this issue. Firefox also fails to generate position estimates, but does show a GPS pin. If I refresh the page, it succeeds. Maybe it's getting a cached estimate? I'm not sure if this is where Firefox gets its position estimate, but it seems that they're using the android.location.LocationProvider API to access GPS data which could explain the difference in behavior: https://dxr.mozilla.org/mozilla-central/source/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/scanners/GPSScanner.java Chrome uses FusedLocationProviderApi, a Google Play Services API that can provide fused position estimates when multiple sources are available. In this case it should only be using GPS due to the OS settings. This seems like a bug in Android's LocationProvider; when there's no cached estimate it fails to report a position estimate to the first client that subscribes for GPS updates. The observed behavior makes sense if Firefox is re-subscribing after the first page load and is thus able to get the cached value that was found during the first subscription. I don't know why FusedLocationProviderApi never engages the GPS hardware, that could be a separate bug. I added some debug logging in Chrome to make sure we're using the API correctly. It returns a success code from requestLocationUpdates but our onLocationChanged callback is never called. I didn't see anything obviously wrong, and it's the same code path used for wifi-only and GPS+wifi so I don't think the bug is on our end.
,
Apr 27 2018
This is actually where Firefox gets GPS data, the file I linked in the last comment is for the stumbler: https://dxr.mozilla.org/mozilla-central/source/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java#364 It's using android.location.LocationProvider. I filed b/78771705 against the Android API. I'll leave this bug open until we can confirm this is an Android issue.
,
Aug 20
The location provider behavior is WAI. When using PRIORITY_BALANCED_POWER_ACCURACY, the fused location provider will "very rarely" (never?) use GPS as a location provider. This means that Chrome should avoid using this mode if we detect that Android is configured for GPS-only location estimates. Instead, use PRIORITY_HIGH_ACCURACY even when enableHighAccuracy is false.
,
Sep 11
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/544705c3d510d0cf37e1c734b674ee68536c200b commit 544705c3d510d0cf37e1c734b674ee68536c200b Author: Matt Reynolds <mattreynolds@google.com> Date: Tue Sep 11 21:53:09 2018 geolocation: Use high accuracy in sensors-only mode The FusedLocationProvider API determines which location providers to use based on a priority mode specified in the API call. In PRIORITY_BALANCED_POWER_ACCURACY mode, the request will never cause power-intensive providers like GPS to be used unless another app requests it. Instead, the network provider is preferred. If Android is configured to disable network location providers but to enable sensors (like GPS), then elevate the priority of the request to improve the likelihood that GPS sensors will be used to acquire a location. BUG= 620003 Change-Id: Ia11b7d367b0bdf89631a3e0ccfc696daf1d238a3 Reviewed-on: https://chromium-review.googlesource.com/1182289 Commit-Queue: Matt Reynolds <mattreynolds@chromium.org> Reviewed-by: Ted Choc <tedchoc@chromium.org> Reviewed-by: Miguel Casas <mcasas@chromium.org> Cr-Commit-Position: refs/heads/master@{#590496} [modify] https://crrev.com/544705c3d510d0cf37e1c734b674ee68536c200b/components/location/android/java/src/org/chromium/components/location/LocationUtils.java [modify] https://crrev.com/544705c3d510d0cf37e1c734b674ee68536c200b/services/device/geolocation/BUILD.gn [modify] https://crrev.com/544705c3d510d0cf37e1c734b674ee68536c200b/services/device/geolocation/DEPS [modify] https://crrev.com/544705c3d510d0cf37e1c734b674ee68536c200b/services/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderGmsCore.java
,
Sep 11
Chrome on Android will now use PRIORITY_HIGH_ACCURACY if a geolocation request is made when the device is in sensors-only mode. In other modes, PRIORITY_BALANCED_POWER_ACCURACY is used unless the position request is made with the enableHighAccuracy option. To put an Android P device into sensors-only mode, set "Use location" to On and turn off "Improve Location Accuracy" under Google Location Accuracy. |
|||||||||||||
►
Sign in to add a comment |
|||||||||||||
Comment 1 by tonygarn...@gmail.com
, Jun 14 2016