QField icon indicating copy to clipboard operation
QField copied to clipboard

Background location (notification and maybe location requests) seems to happen when not expected

Open gdt opened this issue 10 months ago • 6 comments

I updated to 3.5.0 (apk from github) for Android. On opening QField, I see a "positioning service" notification. I find this confusing for two reasons:

  • I haven't opened a project, so I don't expect QFIeld to ask for position. There's no UI that is displaying my position, so I'd say it should not be activated. (Hard for me to follow what's going on; I don't see the green warning dot for location use from CalyxOS, so I'm guessing the issue is just the notification.)
  • Generally, programs that use location do not display this kind of notification when in the foreground. They display it when they are both 1) in the background and 2) doing background tracking, when configured to do so.

I pushed the "go home (square)" to get back to the home screen. The notification is still there. In this state, not having opened a project, and background, QField should not be asking for location or doing much of anything at all. Android doctrine seems not to distinguish much between back button and home button; the app is not on the screen and is not expected to do much, unless configured explicitly to do so.

My main project does have a tracking layer, as I was experimenting with that. But even if I load the project, I don't really expect background tracking and background battery use. I'd expect that background tracking is something I'd have to opt into from settings or a wizard, and that if this is in the Play store the rules would require that, from having watched e.g. Vespucci struggle with play store approvals: Even when the user had asked for recording position in background, their was angst about specific language.

(I'm not suggesting QField is doing anything devious; I view these as UI issues and also a battery issue of not running the GNSS receiver unless asked for.)

gdt avatar Feb 17 '25 18:02 gdt

Just reconfigured for internal GNSS vs bluetooth that's powered off :-) Looks like with opening a project with tracking and hitting home, positioning continues to run. And just on opening QFIeld, no project, it's requesting location.

gdt avatar Feb 17 '25 18:02 gdt

@gdt , thanks for the feedback. Let me try to explain in more details how positioning behaves in QField.

First, when you open QField and positioning was activate during your last session, QField will enable positioning on launch. The expectation here is that users who turned positioning on will want it on next time they return to QField. The other advantage of activating positioning on launch is that for GNSS internal/external devices requiring a bit of time to get a fix, the sooner we launch it, the sooner the user gets a reading. If we'd wait 2-5 second for a user to open a project, it's potentially 2-5 seconds we could have used to get a fix.

The positioning service on Android is actually a foreground service. We rely on it to provide positioning while QField is open and people are browsing their projects as well as when the app is suspended / put in background.

One thing that was not made clear until now is that when we turn off positioning in QField (via long-press on top of the positioning button and unchecking [x] positioning enabled), we didn't reflect that in the notification. That's fixed here: https://github.com/opengisch/QField/pull/6070

With that said, let me know if you have lingering questions / observations. If there is a feature request that lingers after these explanations (e.g. turn off positioning when app suspended / phone locked when not tracking), we can turn this issue into an enhancement request.

nirvn avatar Mar 08 '25 06:03 nirvn

I see what you are trying to do, but as I see it privacy norms in open source are more important than shaving a few seconds. And, there are battery usage issues. In my case, I haven't set up a server so I am doing import/export via nextcloud, the now-amusingly-named "cable" option. So it's not all that odd for me to open up and want to manipulate files without opening a project.

Hard to know others expectations, but I wouldn't have been surprised to see location used when opening a project. It's really "I've started the app, which could do multiple things, some of which need location, but I have not asked it to do any of those yet".

(I am surprised you aren't having trouble with google play approvals.)

It might be helpful to look at how Vespucci does this. My memory is that there's only a notification when positioning is obtained in the background, not when the app is in the foreground and it using location is not news. I am not up to date with Vespucci and will try to have a look.

gdt avatar Mar 08 '25 11:03 gdt

@gdt , it seems what you are looking for here is an option for QField to start with its positioning always turned off, even when you left it on in your last session (i.e. when you actually have asked it to do something 😉 that's being remembered by QField). That's an enhancement you could add to QField's idea platform here (https://ideas.qfield.org/), the upvotes on it would give all of us a good idea of whether many people are looking for such a functionality.

nirvn avatar Mar 08 '25 11:03 nirvn

That might be nice to have that sort of disabling but what I think I am asking for is for QField not to ask the OS for position until I as the user do something where I would expect position to be requested. I am actually ok with position being obtained for display when I open a project, because I expect to see the project's rendered map, and my position on it. (I don't expect it to be recorded, and I don't expect it to be sent anywhere :-)

(The behavior of the auto tracking layer is probably another issue, but that's out of scope in this issue.)

gdt avatar Mar 08 '25 12:03 gdt

Further data points after experimentation and field data gathering:

  • Now that i understand tracking better, I am careful to disable it before exiting QField, after a session where I intend to record tracks. I find that when starting QFIeld later, it starts getting position regardless of whether the last project I had open was performing tracking or not.
  • After opening QField to e.g. look at local files and import/export, but not opening a project (such as one might do after returning from the field, or preparing to go out), if I switch away with home or back, then it continues to ask for position in the background, apparently indefinitely.

Thus, I think it's clear that QFIeld is asking for position when it should not be, contrary to normal Android app behavior guidelines.

To fix, I suggest:

  • do not ask for position just because QFIeld is opened, used to access 'Local files", or used to access settings
  • ask for position when a project is opened (because the user expects to see a blue dot with their position in normal use of the program)
  • ask for position in the background when a project has been opened and tracking is enabled, and the project has not yet been closed (via back button twice in project)

This will align behavior with the standard expectations (and likely official UI and app store rules regarding background location), and with how essentially every other map type program behaves

The background-location-when-shouldn't behavior is I think new since the persistent tracking feature, and I think it's clearly a bug in that implementation.

gdt avatar Mar 24 '25 18:03 gdt

I'm still seeing all these problems, with the up-to-date version today (I'm using obtainium).

I really do not understand how QFIeld is not getting kicked out of Google Play.

gdt avatar Jul 23 '25 23:07 gdt

@gdt , this PR should answer to what was raised here:

https://github.com/opengisch/QField/pull/6693

You can give the APKs a try when they emerge.

nirvn avatar Oct 05 '25 07:10 nirvn