Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No continuous position updating for OwnTracks 2.5 #1759

Closed
dijkvb opened this issue Jul 18, 2024 · 29 comments
Closed

No continuous position updating for OwnTracks 2.5 #1759

dijkvb opened this issue Jul 18, 2024 · 29 comments
Labels

Comments

@dijkvb
Copy link

dijkvb commented Jul 18, 2024

App build number: 2.5.0
Android version: Android 10
Device: Samsung A6
Installation source: Google Play

Previous OwnTracks versions allowed continuous position updating (and MQTT data exchange) while the phone was tucked away in my pocket. The latest version seems to have lost that capability: the position gets updated only when the app is activated manually. For me that is an OwnTracks killer. Or have I missed something?

@jpmens
Copy link
Member

jpmens commented Jul 18, 2024

Can you please verify and confirm the app is set to report significant changes?

@growse
Copy link
Collaborator

growse commented Jul 19, 2024

Also, does it still behave like this in move mode?

@dijkvb
Copy link
Author

dijkvb commented Jul 19, 2024

My smartphone has been operating in “move” mode for ages, with position updates issued every few seconds (parameter set at 10 seconds). I have not touched the parameter settings.
At the moment OwnTracks stops issuing position updates as soon as the screen goes dark (checked with ot-recorder).

@dijkvb
Copy link
Author

dijkvb commented Jul 19, 2024

My wife’s smartphone (Samsung A34, Android 14) has the same problem. Equivalent parameter set. Can’t be that we are the only ones suffering from this...

@growse
Copy link
Collaborator

growse commented Jul 19, 2024

Do you have access to a device that isn't a Samsung to test this on?

@growse
Copy link
Collaborator

growse commented Jul 19, 2024

Also, literally any logs would be helpful here. It's not clear if the locations are still being collected and queued, but just failing to send, or if something else is going on.

@growse growse added the needs-more-info A little more info requested from the submitter label Jul 19, 2024
@fabianonline
Copy link

Some problem here. Pixel 6, all battery-optimizations that I know of are diabled for owntracks. The previous version was running fine. I've attached a debug log, I hope it helps. If you need more help debugging this, just let me know.

owntracks-log.txt

@growse
Copy link
Collaborator

growse commented Jul 19, 2024

Thanks for the log. I see the location callback just stops being triggered, which hints that the device is no longer receiving location updates from the OS. Some questions:

  • Does this happen on both Wifi and 4G/LTE/whatever?
  • Does this happen if the device is charging but with the screen off?
  • Is the foreground service notification still present (It's possible to dismiss foreground service notifications from Android 14 - you couldn't before)
  • Definitely not in battery saver mode? No battery saver icon?
  • What's the values of "battery optimization whitelisted" and "Location Permissions Granted" in the Status page?

For what it's worth, this was my day today - I'm not seeing (and haven't seen the entire 2.5 cycle) any issues with locations suddenly not arriving in the app. I'm not saying there's no issue, but if I can't replicate it then this might take a little while troubleshooting.

image

@fabianonline would you be willing to temporarily join our unstable track? That'll get you a new build on each commit, so should help us iterate a little faster. If so, shoot me your play store email address and I'll add you in.

@growse growse added bug and removed needs-more-info A little more info requested from the submitter labels Jul 19, 2024
@fabianonline
Copy link

fabianonline commented Jul 19, 2024 via email

@growse
Copy link
Collaborator

growse commented Jul 19, 2024

Works or not should be good enough for the moment.

Can you try clicking on those fields in the status page? It should take you through to the android settings that let you also (maybe) disable battery optimization for the app, and allow permission for location (background) access. Some more dimensions to try!

edit I just clicked around on my phone to check the battery optimisation setting. They've made it a little more confusing on Android 14, where to set between "Optimized" and "Unrestricted" you have to actually click on the "Allow background usage" text next to the simple on-off toggle. That then takes you to a different screen to give you radio buttons. Just in case you can't find it :p

@fabianonline
Copy link

fabianonline commented Jul 20, 2024 via email

@fabianonline
Copy link

I'm happy to report that it's now working fine. User error. XD The changed settings mentioned in the previous comment made all the difference.

But I think the wording in the status screen could be better (based on the german translation, but I'd hope it is close enough to the english wording to bring my point across): "Location permission granted: Exact" sound just like the thing I'd want - but what I actually want is "Exact (background enabled)". Maybe you could change "Exact" to be something like "Exact, but only when in foreground"?
Same with "Battery optimization enabled": My knowledge from other android apps is that battery optimization is the feature where Android kills apps in background to reduce battery usage. For me it was clear that I want to have this function off for owntracks so that it can keep running in the background. So "No" seemed perfectly fine with me - with "Yes" being the actually correct value.

Maybe you could also color those values? The "bad" value being red and the correct one green would probably have helped me notice these errors by myself without having to waste your time... ;-)

But anyway: Thanks a lot for your help!

@dijkvb
Copy link
Author

dijkvb commented Jul 20, 2024

I can confirm that the problem has been solved by changing the location setting to be “always on”. Shame on Google? Anyway, many thanks for the speedy response and all the good work! I’m impressed!

@anthonycle67
Copy link

"Always On" option is unavailable for OwnTracks app on Samsung S24+. Only "Allowed while using app" is available. This was also true for version 2.4.12. However, location was still updated in the background. Version 2.5.0 doesn't work with this setting.

@growse
Copy link
Collaborator

growse commented Jul 22, 2024

"Always On" option is unavailable for OwnTracks app on Samsung S24+. Only "Allowed while using app" is available. This was also true for version 2.4.12. However, location was still updated in the background. Version 2.5.0 doesn't work with this setting.

Can you share a screenshot?

This is what I see on the emulator under location permission for the app:

image

@anthonycle67
Copy link

anthonycle67 commented Jul 22, 2024 via email

@jpmens
Copy link
Member

jpmens commented Jul 22, 2024

@anthonycle67 screenshots are not attached when replying by email

@anthonycle67
Copy link

Screenshot_20240722_072218_Permission controller

@anthonycle67
Copy link

Screenshot_20240722_072604_Permission controller

@growse
Copy link
Collaborator

growse commented Jul 22, 2024

Please see attached. Note that I am currently running V2.4.12, but V2.5.0 also has the same options. Thanks. ⁣Get TypeApp for Android ​

On Jul 22, 2024, 6:56 AM, at 6:56 AM, Andrew Rowson @.> wrote: > "Always On" option is unavailable for OwnTracks app on Samsung S24+. Only "Allowed while using app" is available. This was also true for version 2.4.12. However, location was still updated in the background. Version 2.5.0 doesn't work with this setting. Can you share a screenshot? This is what I see on the emulator under location permission for the app: image -- Reply to this email directly or view it on GitHub: #1759 (comment) You are receiving this because you commented. Message ID: @.>

Can you double-check on 2.5.0? It explicitly added an extra permission capability, which changes that menu.

@growse
Copy link
Collaborator

growse commented Jul 22, 2024

@fabianonline This is super-useful data, thank you!

So, a couple of things.

Background Location permission

This is a new option in 2.5.0. Historically, it's not been requested by OT because it hasn't been necessary. An application with an active foreground service doesn't need ACCESS_BACKGROUND_LOCATION permission, because the component receiving the location (the service) is a foreground component! This is how it worked <2.5.0.

The other factor here is that if you want to publish an app on the play store that asks for ACCESS_BACKGROUND_LOCATION, there's a bunch of hoops you have to jump through, including (but not limited to) sending Google a youtube video showing how your app works.

There was a fair bit of pressure from users to add this in. I'm not sure where it came from. I suspect that people put the pieces together of "OwnTracks needs locations", "locations should be collected when my phone is in my pocket, when OT is running in the background" and "OT doesn't ask for background location permission" and concluding "Ah, I know why it's not working quite how I want". This is not an unreasonable conclusion!

I resisted for a bit because (a) I wasn't convinced that it would actually solve any issues and (b) paperwork + poking Google often doesn't go well - worst case we get banned from the play store! Eventually, I added it in for 2.5.0, mostly because it might actually solve some problems (especially around geofence detection), but partly to make the GH issues go away.

It seems that something, somewhere though has changed. I don't know if it's

  • later versions of Android now behave differently for foreground services that request locations without ACCESS_BACKGROUND_LOCATION, or
  • it's a bug in Android, or
  • if Android treats the app differently for having ACCESS_BACKGROUND_LOCATION available in the manifest but not granted.

The irony is that if the last one is true, then people who upgraded from <2.5.0 will now have a worse experience, because the permission state carried across the upgrade will be for ACCESS_FINE_LOCATION to be granted, but ACCESS_BACKGROUND_LOCATION to be not granted (because they've not explicitly granted before). This seems to be what you're finding!

Battery Optimization

Battery Optimization is a murky, mystery world. There's no hard-and-fast list of behaviours that change between "Unrestricted / Optimised (default) / Restricted" modes, or what changes between different battery saver modes.

Apps are left in this sort of "Be Lucky!" limbo, where the docs talk about things that "may" become throttled, or unreliable. So if an app requests location updates every 30 seconds, and Android suddenly decides that the battery drain is too high, the location callback just stops getting called. The OS just stops delivering locations. There's no intent (as far as I can tell) that's fired at the app to let it know that locations are being disabled, or throttled, or in any way going to start behaving differently.

The app _can_subscribe to DEVICE_IDLE_MODE_CHANGED and other intents, but these don't work on all OS versions, and (as far as I can tell) not particularly reliable.

Worse, it seems that different device vendors vary the rules on what gets disabled / throttled under different battery conditions. https://dontkillmyapp.com/ exists entirely to highlight how badly behaved different vendors are when it comes to restricting perfectly useful Android APIs under arbitrary conditions. I get why they do it - battery life sells phones. Samsung get to market their 24-hour battery life (or whatever), which is only achievable because they force-kill every app the moment the screen goes off.

UI/UX

The reality is that OT is used by a fair few people on a wide range of devices, and behaviour is inevitably different from one to the next. The thing I could use the most help with is working out how best to provide a user-experience that guides the user towards enabling / disabling whatever setting is needed. There's two main ways here:

  1. Better text/i18n - if you think the wording could be changed / improved in whatever language you consume the app in, please head over to our translation site to submit a change: https://poeditor.com/projects/view?id=419041. If you want to propose a change to the base English labels, you can do this either on POEditor or (preferably) via a PR here.
  2. Better layout to guide the user towards the right settings. I'm not convinced that it's sufficient to just display the settings in the status activity. Something on the main Map activity that alerts the user that they've not got background location enabled might be a good idea. The trick here is balancing letting the user know vs annoying them if they don't want to enable it.

In short, any help here would be hugely useful.

@anthonycle67
Copy link

anthonycle67 commented Jul 22, 2024 via email

@growse
Copy link
Collaborator

growse commented Jul 22, 2024

It's starting to smell like we need to be more proactive with users in nudging them towards allowing background location permission.

@mcnewton
Copy link

Seems similar with my wife's phone (OnePlus 9, Android 14). Hasn't sent anything apart from lwt messages for a few days. Enabled "Allow all the time" and it has started reporting location again.

@anthonycle67
Copy link

Confirmed that selecting "Always on" on Samsung S24 solved issue.

@compuguy
Copy link

compuguy commented Jul 26, 2024

I'm not having issues with sending location positions. Owntracks for Android 2.5 doesn't show current positions for anyone consistently. The recorder app does get the tracks. This might be a separate issue from this one..

Edit: I do have location set to always on. So that's not the issue.

@ckrey
Copy link
Member

ckrey commented Jul 26, 2024

If you use Move mode you may see the problem we found in #1768. A fix will be available shortly

@Pierric82
Copy link

Pierric82 commented Jul 30, 2024

At the risk of posting a technically unnecessary message, I want to give thanks to everyone active in this conversation, from the OP to @growse. I realised yesterday my tracking wasn't working anymore and was worried I'd find no helpful solution, especially if that was in part due to my phone's Android "flavour", as sometimes happens. But look at this, a healthy community had already reported the issue and a responsive and helpful dev explained what was happening. In a second I had confirmed that my phone was now also set to "only while using the app", which I quickly changed, so hopefully the issue is fixed for me as well, now.
This is really great, and makes me even happier to be using owntracks! Keep up the fantastic work!

@growse
Copy link
Collaborator

growse commented Jul 30, 2024

Currently proposing this dialog if no background location permissions. This should catch those upgrading (and therefore won't have otherwise be prompted to enable background permission).

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants