19

Update: it is a Google Play Service issue, reported internally here and it will be fixed from version 13.4.0

We use the cordova gelocation plugin and the method navigator.geolocation.watchPosition() with the option enableHighAccuracy: true to track the user location and get the most accurate results.

Our app has been around for more than 1 year and we used to have no problems with any device getting a very good location accuracy, 4/6 meters when outside and the sky is clear.

Lately, many of our users are reporting not being able to get anything less than 10m accuracy no matter what they do.

We decided to test it ourselves and we found to have the same issue. Initially, we thought we introduced some bug in our latest release, we triple checked everything but we made no changes to code/dependencies involving geolocation.

We tested older versions of our app as well, where we are sure it was possible to get like 4m accuracy, but surprisingly they do not work either, accuracy is capped at 10m.

We tried different version of Android and we can reproduce the issue on any platform from 5 (Lollipop) to 8 (Oreo). We also have the same problem on iOS 10/11. Again, we have not updated the app in months.

There is a recent question about the same issue here:

Someone else is having the same problem using Android native code here

Does anyone know what is going on? Is it a permission issue? Location Services are set to High Accuracy as well.

For the sake of completeness, we are able to get 3/4 meters accuracy using the old version (2.x) of this plugin

Is it the only way to go?

We would rather not introduce an extra dependency for something that was working so well out of the box.

Many thanks

Paranoid Android
  • 4,672
  • 11
  • 54
  • 73
  • @tnt-rox Are you saying that the recievers in the phones are of bad quality and therefore the accuracy will suddenly be capped at 10.0 after a while? – thelastchief Mar 19 '18 at 11:28
  • @tnt-rox we used to get 4 meters on almost all our test devices, now I am not able to go below 10m no matter what I try, not even on my pixel 2. – Paranoid Android Mar 19 '18 at 12:36
  • Exactly, this would suggest that it is not a hardware problem at all. But instead it is a software problem. @tnt-rox – thelastchief Mar 19 '18 at 13:43
  • @tnt-rox the same happens in airplane mode – Paranoid Android Mar 19 '18 at 15:02
  • @Mirko Did you find a fix to this problem somehow? I mean did you some other way of getting better then 10m? – thelastchief Mar 26 '18 at 14:17
  • @thelastchief with this plugin https://github.com/mauron85/cordova-plugin-background-geolocation/tree/2.x I get down to 3 meters, I will look at the native code and use what I need. – Paranoid Android Mar 27 '18 at 14:52
  • I have the same issue with accuracy capped at 10 meters even though apps like GPS Test showing 3 meters. Have you managed to find solution with the original plugin? – Patronaut Aug 15 '18 at 06:46
  • @Patronaut there is not any solution with the original plugin, you have to use native code to go below 10 meters. – Paranoid Android Aug 16 '18 at 08:11

2 Answers2

4

Looking at source code:

Old plugin (2.x) Source:

  watchPosition: function(success, error, args) {
    var win = function() {
        var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
        geo.watchPosition(success, error, {
            enableHighAccuracy: args[1]
        });
    };
    exec(win, error, "Geolocation", "getPermission", []);
},

New Plugin (master) Source:

watchPosition: function(success, error, args) {
    var pluginWatchId = utils.createUUID();

    var win = function() {
        var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
        pluginToNativeWatchMap[pluginWatchId] = geo.watchPosition(success, error, args);
    };

    var fail = function() {
        if (error) {
            error(new PositionError(PositionError.PERMISSION_DENIED, 'Illegal Access'));
        }
    };
    exec(win, fail, "Geolocation", "getPermission", []);

    return pluginWatchId;
},

In OLD plugin code enableHighAccuracy is a boolean set by (arg1 of array).

With NEW version of plugin you need to pass arg as JSON with that flag set: {enableHighAccuracy: true} to reproduce same call to geo.watchPosition function with high accuracy.

Old Way:

navigator.geolocation.watchPosition(geolocationSuccess,
                                                  geolocationError,
                                                  [false,true]);

New Way:

navigator.geolocation.watchPosition(geolocationSuccess,
                                                  geolocationError,
                                                  { enableHighAccuracy: true });
Frix33
  • 1,231
  • 10
  • 27
1

To whom it might concern, it is a Google Play Services issue, reported internally here and it will be fixed from version 13.4.0

Update: solved after updating to Play Services 14.3.66, accuracy down to 4m again!

Paranoid Android
  • 4,672
  • 11
  • 54
  • 73