Processing location updates in the background
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ubuntu-application-lifecycle |
Triaged
|
High
|
Thomas Voß |
Bug Description
We have a number of applications which need to process location updates in the background, e.g. the following:
- Navigation apps
- "Anchor watch" (alerts you when the device moves more than x meters from the initial position)
- Fitness trackers
- General purpose loggers
- Geofencing for various things, e.g. "remind me to buy butter the next time I am around the supermarket"
Each of these have different requirements:
- It might be simply enough to track the location in the background, but don't process anything, and just give the app the cached list of updates as soon as it is focused again.
- It might be necessary to just react to an event, for example "location deviated more than x meters from point x", "more than x seconds have passed since the last update", "GPS became available/
- The app might have to do an unknown amount of arbitrary processing on the data, e.g. there are fitness trackers which process every GPS update that comes in, smoothen across multiple samples to remove jitter, do text-to-speech and upload the data to a cloud service all in one go. Navigation apps might also have to do quite a lot of work, e.g. they can alert you about dangerous locations so they need to access the map data in the background.
This list is incomplete, we cannot anticipate every use case our developers might have.
The proposed solution was to register a callback handler with location-service instead of allowing the application to do background processing, but I see the following challenges with that:
- We have to limit the execution time of the callback handler somehow, but how do we find a limit that matches all devices, all situations and all use cases?
- The callback handler binary has to be freshly executed every time something happens, load all the context, process the location update, and then exit. That's quite a lot of overhead compared to an app-supplied background process that just loads all the context once in the beginning and then blocks on D-Bus calls between updates.
Changed in ubuntu-application-lifecycle: | |
importance: | Undecided → High |
assignee: | nobody → Thomas Voß (thomas-voss) |
At least for the third case, I would propose adding a new security policy, like "location- unfocused" , which behaves mostly like the "location" policy. The difference being, that when an application carrying this policy asks for permission to use the GPS, the location service would show a different prompt to the user, where it's clearly communicated that the application will continue running in the background.
In such case we should also change the OOM setting for this application, to make it less likely to get killed than an ordinary app (reason: think of a navigation app for cyclist, which alerts you with sounds about where to turn; if it just dies, you are unlikely to get to your destination :-) ).
If we can introduce some limitations on the CPU usage (such as: let the application run only for the first X milliseconds after having received a location update) instead of just letting it run all the time, that could be a nice plus.