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

Unsubscribe from Geolocation.watchPosition() in desktop browsers results in an error. #164

Closed
arlowhite opened this issue May 19, 2016 · 4 comments
Labels

Comments

@arlowhite
Copy link

arlowhite commented May 19, 2016

ionic info

Cordova CLI: 6.1.1
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04 LTS
Node Version: v5.11.1

rxjs: 5.0.0-beta.6
ionic-native: 1.2.2 - 1.2.4

cordova-plugin-geolocation version: 2.2.0

Chrome Version 50.0.2661.102 (64-bit) - 51.0.2704.84 (64-bit)
Firefox 47.0

When testing my app with ionic serve in Chrome Dev tools, I get an error when unsubscribing.
http://ionicframework.com/docs/v2/native/geolocation/
However, the same code works fine on my Android device.

In Chrome Dev Tools, I see this warning:
"Unable to clear the previous observable watch for Geolocation watchPosition"
Followed by the stacktrace:

TypeError: Illegal invocation
(anonymous function) @ plugin.js:142
tryCatcher @ tryCatch.js:6
Subscription.unsubscribe @ Subscription.js:29
tryCatcher @ tryCatch.js:6
Subscription.unsubscribe @ Subscription.js:41
Subscriber.unsubscribe @ Subscriber.js:71
tryCatcher @ tryCatch.js:6
Subscription.unsubscribe @ Subscription.js:41
Subscriber.unsubscribe @ Subscriber.js:71
RefCountSubscriber._unsubscribe @ ConnectableObservable.js:123
tryCatcher @ tryCatch.js:6
Subscription.unsubscribe @ Subscription.js:29
Subscriber.unsubscribe @ Subscriber.js:71
tryCatcher @ tryCatch.js:6
Subscription.unsubscribe @ Subscription.js:41
Subscriber.unsubscribe @ Subscriber.js:71
SightingEditPage.onPageWillLeave @ sighting-edit.ts:82

(cutoff rest of stacktrace, unsubscribe is called in onPageWillLeave)

@arlowhite arlowhite changed the title Geolocation does not support chained Observable methods (such as map) Unsubscribe from Geolocation.watchPosition() broken in Chrome Dev Tools. May 19, 2016
@arlowhite
Copy link
Author

EDIT: A previous version of this issue suggested that .map() .publishBehavior().refCount() did not work as expected. However, this is working fine for me now on Android. So I must have made a build or coding mistake when reporting the issue.

@ihadeed
Copy link
Collaborator

ihadeed commented Jun 10, 2016

Sorry @arlowhite, I'm a bit confused here.

Are you still experiencing issues with the GeoLocation plugin?

@mlynch
Copy link
Collaborator

mlynch commented Jun 10, 2016

I did notice the README had an incorrect example of calling unsubscribe. You call it on the return from subscribe not from watchPosition. Updating now...

@arlowhite
Copy link
Author

Updated ionic-native to 1.2.4, no effect.
cordova-plugin-geolocation version: 2.2.0 (same as when bug first created)

Yes, I still see this error with Chrome and Firefox; in Firefox, the message is different:

TypeError: 'clearWatch' called on an object that does not implement interface Geolocation.
Stack trace:
wrapObservable/</<@http://localhost:8100/build/js/app.bundle.js:75831:24
tryCatcher@http://localhost:8100/build/js/app.bundle.js:101172:16
[505]</Subscription</Subscription.prototype.unsubscribe@http://localhost:8100/build/js/app.bundle.js:89968:25
tryCatcher@http://localhost:8100/build/js/app.bundle.js:101172:16

Just to clarify, there's no issue when running on my Android device. This error is only seen when developing on the desktop in Chrome or Firefox while using ionic serve.

I can't test Internet Explorer since I'm on Linux and don't have my development environment setup in Windows.

You don't see this error when unsubscribing in a desktop browser environment?

I would say this is a minor bug that almost isn't worth hunting down except for the fact that it may worry developers when they see it. And it's not good to have a method that errors in the development environment but works when deployed to a mobile device.

@arlowhite arlowhite changed the title Unsubscribe from Geolocation.watchPosition() broken in Chrome Dev Tools. Unsubscribe from Geolocation.watchPosition() in desktop browsers results in an error. Jun 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants