Bug 92798

Summary: Only update location if location actually changes
Product: GeoClue Reporter: Jonas Danielsson <jonas>
Component: GeneralAssignee: Geoclue Bugs <geoclue-bugs>
Status: RESOLVED MOVED QA Contact: Geoclue Bugs <geoclue-bugs>
Severity: normal    
Priority: medium CC: jonas, tiagomatos
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: gclue-simple: Only notify on location change

Description Jonas Danielsson 2015-11-03 15:15:42 UTC
When I started GNOME Maps with MAPS_DEBUG=1 I noticed that we got a lot of notications about updated location:

Gjs-Message: JS LOG: DEBUG: Updated location: 
Gjs-Message: JS LOG: DEBUG: Updated location: 
Gjs-Message: JS LOG: DEBUG: Updated location: 
Gjs-Message: JS LOG: DEBUG: Updated location: 
Gjs-Message: JS LOG: DEBUG: Updated location: 
Gjs-Message: JS LOG: DEBUG: Updated location: 


One every second, but the location did not seem to change. This seems like a bug.
Comment 1 Jonas Danielsson 2015-11-03 15:27:54 UTC
Created attachment 119385 [details] [review]
gclue-simple: Only notify on location change

We only want to notify on the 'location' property if
the location actually has changed. Otherwise the
applications will perform their callback code to often.
Comment 2 Zeeshan Ali 2015-11-12 18:12:33 UTC
I'm not sure why this is needed, especially on library level. If geoclue says that location has been updated, you need to point to the new location anyway, cause the previous location instance will not be kept around forever.

I'm afraid you'd want to dig into service code to see why you are getting redundant location updates. If I were to guess, it's cause wifi networks around you are changing (signal strength etc) and somehow geoclue fails to filter the duplication location.

http://cgit.freedesktop.org/geoclue/tree/src/gclue-locator.c#n78
Comment 3 Rui Tiago Matos 2017-07-21 10:07:37 UTC
(In reply to Zeeshan Ali from comment #2)
> http://cgit.freedesktop.org/geoclue/tree/src/gclue-locator.c#n78

It seem to me that the second comparison here:

            if (geocode_location_get_distance_from (gloc, cur_gloc) * 1000 <
                geocode_location_get_accuracy (gloc) &&
                geocode_location_get_accuracy (gloc) >
                geocode_location_get_accuracy (cur_gloc)) {

should be old_accuracy >= new_accuracy otherwise we always update the location if the accuracy doesn't change (which is likely?)
Comment 4 Zeeshan Ali 2017-07-21 14:34:32 UTC
(In reply to Rui Tiago Matos from comment #3)
> (In reply to Zeeshan Ali from comment #2)
> > http://cgit.freedesktop.org/geoclue/tree/src/gclue-locator.c#n78
> 
> It seem to me that the second comparison here:
> 
>             if (geocode_location_get_distance_from (gloc, cur_gloc) * 1000 <
>                 geocode_location_get_accuracy (gloc) &&
>                 geocode_location_get_accuracy (gloc) >
>                 geocode_location_get_accuracy (cur_gloc)) {
> 
> should be old_accuracy >= new_accuracy otherwise we always update the
> location if the accuracy doesn't change (which is likely?)

I guess but note that the first part of condition means that we are talking of the case where the distance between new and last location is within the accuracy circle of the new location, which isn't very likely?


This logic isn't checking if the location is the same and it doesn't intend to. The thing is that we want to give app location update each time a source reports an update. For some sources (e.g GPS), it makes sense to report location every second, since the timestamp of accurate locations can be important for apps. For others (e.g wifi), we need better methods of filtering location updates.

Also note that there are two properties that control how often app wants the location update:

https://www.freedesktop.org/software/geoclue/docs/gdbus-org.freedesktop.GeoClue2.Client.html#gdbus-property-org-freedesktop-GeoClue2-Client.DistanceThreshold
https://www.freedesktop.org/software/geoclue/docs/gdbus-org.freedesktop.GeoClue2.Client.html#gdbus-property-org-freedesktop-GeoClue2-Client.TimeThreshold
Comment 5 GitLab Migration User 2018-05-06 14:37:10 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/geoclue/geoclue/issues/66.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.