2

I've been dabbling with hybrid app development using Cordova (an extendable web view wrapper for those who haven't used it). One thing that I've noticed is that whenever I request the user's location with window.geolocation, the location fix almost always takes longer compared to a native app.

For instance, it will take 5 or 6 seconds to get a suitable fix with window.geolocation from a "cold start", but the Google Maps app will pan to my location within 2 seconds or less. The same seems to happen with other native apps. This is kind of confusing as I'd imagine they both source data from the underlying Android API. Is there some sort of magic configuration option or caching strategy that I'm missing out on as a web-focused developer?

redct
  • 884
  • 1
  • 6
  • 8
  • have you tried doing a android build with the crosswalk engine? https://crosswalk-project.org/ – Jess Patton Jul 09 '15 at 14:10
  • Not yet, but I ran the app on a Nexus 5, so I assume it's using the latest Chrome engine so there wouldn't be much of a difference(?) – redct Jul 09 '15 at 16:26
  • there is a huge difference, crosswalk is still miles ahead of the chrome engine when used to build your mobile app. I do builds with both every iteration and compare. – Jess Patton Jul 09 '15 at 16:36
  • Good to know, thank you. This may indeed solve my issue. – redct Jul 09 '15 at 22:31
  • Did you ever resolve this? I'm seeing the same issue (6s vs instant on other apps) and crosswalk does not make a difference. – FuzzyTree Feb 18 '16 at 17:38
  • I have not. The disparity seems to have gotten better on Crosswalk after upgrading to Android 5.x, but I can't say I've encountered meaningful progress in answering this question. – redct Feb 19 '16 at 21:45

1 Answers1

1

Late to the party, but navigator.geolocation methods do not use any of the native APIs, that is why it is slower. It uses the WebView implementation of the device.

Also, I recently found out that accuracy gets capped at 10 meters no matter how good your GPS is.

The only fix is to use native code

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