Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 63C92DAF1 for ; Mon, 17 Sep 2012 21:51:09 +0000 (UTC) Received: (qmail 28775 invoked by uid 500); 17 Sep 2012 21:51:09 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 28720 invoked by uid 500); 17 Sep 2012 21:51:08 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 28655 invoked by uid 99); 17 Sep 2012 21:51:08 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2012 21:51:08 +0000 Date: Tue, 18 Sep 2012 08:51:08 +1100 (NCT) From: "Filip Maj (JIRA)" To: callback-dev@incubator.apache.org Message-ID: <1156774463.89968.1347918668911.JavaMail.jiratomcat@arcas> In-Reply-To: <1070269224.79651.1347616207869.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (CB-1462) False logic for native watchPosition/clearWatch MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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