microg / UnifiedNlp

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

LocationProvider sometimes returning NaN #150

Open Phyks opened 6 years ago

Phyks commented 6 years ago

Hi,

First of all, I'm not sure this is the right repo to post this issue. Please, let me know if it should belong to another repo and I'll fix it.

I'm using LineageOS with microg ROM on my Nexus 5, together with UnifiedNlp and Apple Wifi backend. I am also using OwnTracks (which relies on FusedLocationProvider as far as I know) to track my phone's position every 5 minutes and send the location to a remote server. My phone geolocation setting is always set to "power saving".

I noticed that from time to time, I receive a NaN, NaN location, which is directly coming from the FusedLocationProvider implementation, as far as I know. I'm not exactly sure what happens here, and I guess this might be actually a regular behavior of FusedLocationProvider (when it cannot acquire a location for instance). Still, apparently, from reading the official docs of this Google API, it should never return a NaN value.

This is not a really big deal in OwnTracks as it handles it quite fine, and simply implicitly converts it to zero and this can be filtered away afterwards on the server side. On the contrary, many apps I've encountered so far are not resilient to an unexpected NaN value here and simply crash.

Thanks!

n76 commented 6 years ago

Lineage with microG has gsmcore in it and gmscore has UnifiedNlp built in, so a separate install of UnifiedNlp should not be needed.

The only time I've noticed gmscore/unifiedNlp returning NaN values is when the backend returned NaN values to it. So I'd start looking at the Apple backend. The issue might not be there but that is where I'd start debugging.

FWIW, the Moxilla backend seems to work better for me than the Apple backend. But I seldom use either as I am usually have data disabled and have the GPS enabled. In that situation the the Déjá Vu on phone only backend works for me. But of course I'd be recommending a back end that I wrote. :)

Phyks commented 6 years ago

Lineage with microG has gsmcore in it and gmscore has UnifiedNlp built in, so a separate install of UnifiedNlp should not be needed.

Sure, I did not install any extra UnifiedNlp package (except the backend). I was not sure whether the provided UnifiedNlp code was actually coming from this repo or from the GmsCore repo.

The only time I've noticed gmscore/unifiedNlp returning NaN values is when the backend returned NaN values to it. So I'd start looking at the Apple backend. The issue might not be there but that is where I'd start debugging.

Ok! I don't know much about Android dev, so I might be very naive here. It seems this code could easily result in latitude / longitude being null, depending on the response from Apple.

FWIW, the Moxilla backend seems to work better for me than the Apple backend. But I seldom use either as I am usually have data disabled and have the GPS enabled. In that situation the the Déjá Vu on phone only backend works for me. But of course I'd be recommending a back end that I wrote. :)

I should give the Mozilla backend a try. I was expecting the Apple backend to be more accurate around here though (and I read somewhere about some rate-limiting issues with the Mozilla backend). Sure Deja Vu seems to be one of the best backend, but does not really match my use case :/