microg / UnifiedNlp

Alternative network location provider for Android, with plugin interface to easily integrate third-party location providers.
973 stars 210 forks source link

Location timing issues #211

Open ploink opened 3 years ago

ploink commented 3 years ago

I have noticed timing issues with apps that use network location. Often it makes it very slow or impossible to get a location.

Using the latest microg v0.2.17.204714 but this has been a problem - if i remember correctly - since gmscore v0.2.11, that includes UnifiedNlp 2.0-alpha6.

After some testing with my Hellocation test app in combination with my fork of Local-GSM-Backend I noticed the following behaviour:

  1. The network location update interval cannot be shorter than 30 seconds. When an app requests updates faster than that, microG/Unifiednlp limits it to 30 seconds.
  2. No location update is performed until the first 30 seconds have expired, then you get an update every 30 seconds.
  3. When you close the app that requests the updates, then launch it again and restart location updates, the 30s timer is not reset. It means you have to wait anything between 0 and 30 seconds depending on the state of the location update timer.

Edit: I did most of my testing with a previous microg version and things seem to have improved. There is still the 30s minimum, which I think is a bit slow but would need to compare with Gapps for reference. The behaviour is a little different but I can still get in a situation that it takes a while before the first location is requested. Will do some more testing.

jwrdegoede commented 2 years ago

I'm seeing similar network location timing issues on a lineage-17.1 + latest micro-G config. I've run several tests and the amount of time between updates (and the amount of time when only a "stale" location is available) seems to depend on which Nlp providers are used:

If you have no objection against using the Apple Wifi webAPIs (and thus sending some data to Apple) then using the Apple Wifi NLP provider from F-Droid is a good workaround for the timings issues. At least this seems to work well for me.

jwrdegoede commented 2 years ago

A quick update on this, I just retried this on a fresh install and for the apple backend to work properly I also need to disable the "throttle wifi scanning" option under developer options and then disable + re-enable the apple wifi backend in the microg location settings.

Without this the apple backend was behaving quite similar to the mozilla NLP (IchnaeaNlpBackend) version 1.3.3 case, where Networklocation works with 5 seconds ok + 10 seconds stale data. Unfortunately disabling "throttle wifi scanning" does not help for the 1.3.3 mozilla NLP backend.