You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Sean Nikolai Fridman (JIRA)" <ji...@apache.org> on 2012/09/14 11:50:07 UTC

[jira] [Created] (CB-1462) False logic for native watchPosition/clearWatch

Sean Nikolai Fridman created CB-1462:
----------------------------------------

             Summary: False logic for native watchPosition/clearWatch
                 Key: CB-1462
                 URL: https://issues.apache.org/jira/browse/CB-1462
             Project: Apache Cordova
          Issue Type: Bug
          Components: Android, CordovaJS
    Affects Versions: 2.0.0
            Reporter: Sean Nikolai Fridman
            Assignee: Joe Bowser


Note: This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist not only on Android.

Description: When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...

_(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_

And the potential issue in Javascript is this: if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Joe Bowser (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458161#comment-13458161 ] 

Joe Bowser commented on CB-1462:
--------------------------------

Actually, I'll take it back
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Joe Bowser
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Joe Bowser (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457368#comment-13457368 ] 

Joe Bowser commented on CB-1462:
--------------------------------

We can only fix our own code.  For geolocation, we use what's built into the browser, for better or for worse.  The question is whether this bug is bad enough for us to polyfill it.
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Assigned] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Joe Bowser (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joe Bowser reassigned CB-1462:
------------------------------

    Assignee: Filip Maj  (was: Joe Bowser)

We use the Android implementation, so we can't really fix that.  Cordova JS common code probably needs a check.
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Assigned] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Joe Bowser (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joe Bowser reassigned CB-1462:
------------------------------

    Assignee: Joe Bowser  (was: Filip Maj)
    
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Joe Bowser
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Reopened] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Filip Maj (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Filip Maj reopened CB-1462:
---------------------------


Ah, thanks [~sfrdmn], yes I think you are right.

I believe the correct fix in this case is, [in the {{win}} and {{fail}} native callbacks|https://github.com/apache/incubator-cordova-android/blob/master/framework/src/org/apache/cordova/CordovaLocationListener.java#L53-L79], to add a {{size()}} check at the bottom of the methods and, if {{== 0}}, call {{stop()}}.

Thoughts [~bowserj]?
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Filip Maj (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457382#comment-13457382 ] 

Filip Maj commented on CB-1462:
-------------------------------

One more thing: the native implementation on Android is fine as long as my latest fix is in the JS.

When Android's "position-retrieved" callback fires, it [calls the {{win}} method, which clears the callback list|https://github.com/apache/incubator-cordova-android/blob/master/framework/src/org/apache/cordova/CordovaLocationListener.java#L67]. So even though that one callback fires back into javascript (but with my fix doesn't invoke the user's success callback), it will only happen one time.

Hope that helps!
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Filip Maj (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Filip Maj resolved CB-1462.
---------------------------

       Resolution: Fixed
    Fix Version/s: 2.2.0

Confirmed that this was the issue.

I have added a test for this issue and a fix to the logic in commit [dab8e8|https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=commit;h=dab8e8485f7c8801a5344aaf95aad6c53ca57eba].
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Sean Nikolai Fridman (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Nikolai Fridman updated CB-1462:
-------------------------------------

    Description: 
Note: This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist more platforms.

Description: When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...

_(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_

And the potential issue in Javascript is this: if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

  was:
Note: This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist not only on Android.

Description: When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...

_(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_

And the potential issue in Javascript is this: if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

    
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Joe Bowser
>              Labels: clearwatch, geolocation, watchposition
>
> Note: This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist more platforms.
> Description: When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> And the potential issue in Javascript is this: if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Joe Bowser (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joe Bowser resolved CB-1462.
----------------------------

    Resolution: Fixed

Fixed with this commit: https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=commit;h=772aedc263aa695e94c8dcd99aec05525b96f907
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Joe Bowser
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Sean Nikolai Fridman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457396#comment-13457396 ] 

Sean Nikolai Fridman commented on CB-1462:
------------------------------------------

Thanks :) Hmm... I was actually intending on forcing native geolocation to avoid the sort of "black box" of the stock implementation. Figured I could just add on to what you guys already have. But I guess it's pretty low priority for Cordova since it's only used pre 2.0...

BTW, I'm pretty sure that for Android, even though the callback list is cleared, the location listener is not stopped.
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Sean Nikolai Fridman (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Nikolai Fridman updated CB-1462:
-------------------------------------

    Description: 
*Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.

*Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...

_(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_

*And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

  was:
Note: This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.

Description: When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...

_(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_

And the potential issue in Javascript is this: if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

    
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Joe Bowser
>              Labels: clearwatch, geolocation, watchposition
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Filip Maj (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457378#comment-13457378 ] 

Filip Maj commented on CB-1462:
-------------------------------

Sean: I just want to reiterate that as Joe points out, by default the cordova-js implementation does _not_ get used on Android. Because all Android devices since 2.0 have the {{navigator.geolocation}} object existing in the Android WebView class, cordova-js sidesteps that and lets the stock implementation existing in the WebView live.

Therefore, unless you are _explicitly_ calling the cordova-js geolocation code with:

{{cordova.require('cordova/plugin/geolocation').getCurrentPosition()}} or {{cordova.require('cordova/plugin/geolocation').watchPosition()}}

.. you will be using the Android implementation, not Cordova's.
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Assigned] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Joe Bowser (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joe Bowser reassigned CB-1462:
------------------------------

    Assignee: Filip Maj  (was: Joe Bowser)

Assigning back to you since this is your refactor.
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Sean Nikolai Fridman (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Nikolai Fridman updated CB-1462:
-------------------------------------

    Description: 
Note: This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.

Description: When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...

_(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_

And the potential issue in Javascript is this: if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

  was:
Note: This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist more platforms.

Description: When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...

_(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_

And the potential issue in Javascript is this: if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

    
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Joe Bowser
>              Labels: clearwatch, geolocation, watchposition
>
> Note: This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> Description: When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> And the potential issue in Javascript is this: if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Sean Nikolai Fridman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457361#comment-13457361 ] 

Sean Nikolai Fridman commented on CB-1462:
------------------------------------------

Alrighty, but that doesn't affect the issue I experienced with the native Android code. 

Android still won't know whether it can disable location update listeners on clearWatch because it will still have a callback id in its callback list. Eventually the callback will be called, and yeah, with this fix the success callback JS side won't be run, but GPS/NetworkLocation will still be running since it wasn't stopped on clearWatch.

I guess native could always check to shut off GPS on the win/fail callbacks? Would be curious to know how other native implementations do it. I still wonder: can native really handle the situation properly without knowing the callback is associated with a watch operation?
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Assigned] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Filip Maj (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Filip Maj reassigned CB-1462:
-----------------------------

    Assignee: Joe Bowser  (was: Filip Maj)

Assigning to Joe to resolve the native Android bits, if applicable.
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Joe Bowser
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Filip Maj (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457386#comment-13457386 ] 

Filip Maj commented on CB-1462:
-------------------------------

In other words: the callback list implementation is a one-shot-fire pattern. The watch table has a hash that keeps the IDs alive until explicitly cleared with the clearWatch command.
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CB-1462) False logic for native watchPosition/clearWatch

Posted by "Sean Nikolai Fridman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457381#comment-13457381 ] 

Sean Nikolai Fridman commented on CB-1462:
------------------------------------------

Sorry, don't quite understand. Isn't it your code? The bug I'm referring to is in the CordovaLocationListener class. And yeah, you use the browser implementation, but you _do_ have a native fallback implementation. I'm filing a bug for the native fallback.
                
> False logic for native watchPosition/clearWatch
> -----------------------------------------------
>
>                 Key: CB-1462
>                 URL: https://issues.apache.org/jira/browse/CB-1462
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.0.0
>            Reporter: Sean Nikolai Fridman
>            Assignee: Filip Maj
>              Labels: clearwatch, geolocation, watchposition
>             Fix For: 2.2.0
>
>
> *Note:* This is a bug in Android's native geolocation implementation. I can't speak to what happens on other platforms. However, I get the feeling that the bug is symptomatic of the JS implementation so it might very well exist on more platforms.
> *Description:* When watchPosition is called, it first calls getCurrentLocation (resulting in a native call to getLocation), then makes a native call to addWatch. In Android, addWatch callback ids and getLocation callback ids are stored in separate data structures. The bug I'm seeing is, when I call clearWatch before the watch operation's implicit getCurrentLocation callback is invoked, the watch operation is removed/stopped in native, but the corresponding getCurrentLocation operation is not.  This is not compliant with the W3C spec, which states that that no further callbacks for the watch operation should be invoked. Worse, this causes a bug on Android where GPS is never shut off! clearWatch stops the location listener *iff* {{callbacks.size + watches.size == 0}}, and so if the callback hadn't been invoked yet...
> _(Actually, skimming back through the code, I'm not seeing anywhere where the location listener is stopped after a getCurrentPosition. Which may be another issue... not sure.)_
> *And the potential issue in Javascript is this:* if native has no knowledge of which getCurrentLocation callbacks are part of a watch operation and which are just normal independent ones, how can it possibly remove the callback id for the implicit getCurrentLocation operation on clearWatch? And how can it possibly know if it can really stop listening for location updates?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira