3

I got a cordova app with the geolocation plugin : https://github.com/apache/cordova-plugin-geolocation

A lot of my users report that geolocation was slow in my app (what they mean by slow is something around 6 seconds). They said when we use Waze, it takes 2 seconds...

I found this post on SO too : Why is HTML5 geolocation slower than native on Android?

I already use the Cordova crosswalk plugin : https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview

But it doesn't change the performance of geolocation.

Users have lot of different phones (Samsung, Sony, LG, ...) but it seems to take 6 secondes for all phones. And I use EnableHighAccuracy false to have better performance.

Any ideas?

Community
  • 1
  • 1
JeromeModi
  • 117
  • 1
  • 7
  • "A lot of my users": have you tried yourself with a device in a "good environment" (with wifi/gsm/gps enabled)? I think that this problem is due to the bad location of some of your users. – lifeisfoo Sep 03 '15 at 07:05
  • Hi, Yes I tried with an LG G3 indoor. Waze take 3 times less to get my location and I don't think they Infinite cache my position. What is the average time to get a location? I saw this post too : https://issues.apache.org/jira/browse/CB-5977 And we are in Europe, I don't know if it plays a role but just to be sure – JeromeModi Sep 03 '15 at 08:29
  • I've seen. Keep in mind that every application could adopt also some caching strategy (or other optimization) to have a "faster experience", e.g.: use immediately the last cached position and make a new position request that when is completed will update the user position. – lifeisfoo Sep 03 '15 at 08:35
  • Yea I know. But even when removing cache or reinstalling app, some native app are always fast and get latitude and longitude in less than 2 seconds. I was just wondering why ^^ Maybe I will use the strategy to infinite cache position and retrieving the user current position in background. So only the first use will take 6 seconds and I thing no users will complain about that :) – JeromeModi Sep 03 '15 at 12:56
  • running into the exact same (6s). it seems Crosswalk provides its own geolocation which will override the plugin (so you could actually uninstall the plugin - see http://stackoverflow.com/questions/35489286/cordova-geolocation-still-works-after-geolocation-plugin-is-removed). but i'm not sure if crosswalk/webview's geolocation implementation is the cause because i haven't been able to disable it or force the geolocation plugin to be used instead – FuzzyTree Feb 18 '16 at 21:10

1 Answers1

1

Problem is there are actually two APIs for geolocation in GMS Android distribution. One system API and another is GMS. Native apps probably uses GMS implementation, which is in fact geolocation services aggregator for all apps which use it. And this is reason why location is available so quickly with this API.

Older webViews certainly use Android system API, so they are slower, or even not able to get location at all, while the other apps can. You may want to use this cordova-plugin-locationservices plugin, which uses GMS as location provider (or some fork as it looks abandoned now).

However, I think webView finally uses this API too since Chrome WebView on Android 7 and up, so problem should solve itself eventually.

Velda
  • 527
  • 1
  • 5
  • 20