Bug 214566 - [GTK] GeoclueGeolocationProvider uses very low accuracy setting (city) as default geolocation API
Summary: [GTK] GeoclueGeolocationProvider uses very low accuracy setting (city) as def...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: PC Linux
: P2 Normal
Assignee: Adrian Perez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-20 12:53 PDT by Chris McGee
Modified: 2020-07-27 08:05 PDT (History)
5 users (show)

See Also:


Attachments
Patch (2.15 KB, patch)
2020-07-27 04:49 PDT, Adrian Perez
no flags Details | Formatted Diff | Diff
Patch v2 (2.27 KB, patch)
2020-07-27 05:57 PDT, Adrian Perez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris McGee 2020-07-20 12:53:23 PDT
When using the Epiphany browser in Linux with libwebkit2gtk (v2.28.3) and the geoclue2 library with a website like openstreetmap.org or maps.google.com the accuracy is very low at around 25km or "city" level. Geoclue ends up using only IP-based location, which is intended to give a city level of accuracy. According to the source code of Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp geoclue will only be instructed to provide greater accuracy with cell phone tower location, wifi, bluetooth beacons and even GPS if the enableHighAccuracy position option is enabled.

Websites like Open Street Map or Google Maps do not use the enableHighAccuracy position options for simple location, which not very useful with only a city level of accuracy. They appear to assume that at least a street level of accuracy could be given without enabling a GPS on the device.

The MDN reference on the HTML Geolocation API points out GPS as a differentiating factor for using enableHighAccuracy: https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions/enableHighAccuracy

In terms of geoclue, street level accuracy can be achieved without GPS using the presence of nearby cell phone towers, wifi endpoints and bluetooth low energy beacons. But, these require the street level setting. Otherwise, it's just the IP address based lookup.

Changing GeoclueGeoLocationProvider.cpp to use GeoclueAccuracySteetLevel (6) as the default could be a more reasonable tradeoff of accuracy for performance and might give a better experience for Linux users.
Comment 1 Adrian Perez 2020-07-27 04:49:42 PDT
Created attachment 405266 [details]
Patch
Comment 2 Carlos Garcia Campos 2020-07-27 05:40:38 PDT
Comment on attachment 405266 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=405266&action=review

> Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp:244
>      unsigned accuracy = m_isHighAccuracyEnabled ? 8 : 4;

You have only changed the comment, I guess this should be:

unsigned accuracy = m_isHighAccuracyEnabled ? 8 : 6;

no?
Comment 3 Adrian Perez 2020-07-27 05:53:14 PDT
(In reply to Carlos Garcia Campos from comment #2)
> Comment on attachment 405266 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=405266&action=review
> 
> > Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp:244
> >      unsigned accuracy = m_isHighAccuracyEnabled ? 8 : 4;
> 
> You have only changed the comment, I guess this should be:
> 
> unsigned accuracy = m_isHighAccuracyEnabled ? 8 : 6;
> 
> no?

Indeed, I'll post an updated patch 🤦️
Comment 4 Adrian Perez 2020-07-27 05:57:53 PDT
Created attachment 405268 [details]
Patch v2
Comment 5 EWS 2020-07-27 08:05:05 PDT
Committed r264920: <https://trac.webkit.org/changeset/264920>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 405268 [details].