Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout on iOS after clearWatch #112

Open
JimBacon opened this issue Aug 31, 2018 · 0 comments
Open

Timeout on iOS after clearWatch #112

JimBacon opened this issue Aug 31, 2018 · 0 comments

Comments

@JimBacon
Copy link

iOS 11.4.1

I experience a timeout error after calling watchPosition and then calling clearWatch in the first success callback.

Example code would be some thing like

var count = 0
var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { enableHighAccuracy: true });

var onSuccess= function (position) {
  if (count === 0) {
    navigator.geolocation.clearWatch(watchID);
  }
  count ++;
}

function onError(error) {
    console.log('code: ' + error.code + '\n' +
        'message: ' + error.message + '\n');
}

What I believe is happening is

  1. watchPosition calls geolocation.getCurrentPosition followed by
  2. exec(win, fail, 'Geolocation', 'addWatch', [id, options.enableHighAccuracy]);
  3. The onSuccess callback following step 1 calls clearWatch
  4. The win callback following step 2 restarts the timeout
  5. The timeout is hit because the geolocation was stopped in step 3

This was unexpected behaviour which I only figured out by looking at the source code of the plugin. I could easily resolve the problem by calling clearWatch a second time but it would be nicer for the plugin to handle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants