Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1BAD61772B for ; Mon, 22 Jun 2015 08:14:35 +0000 (UTC) Received: (qmail 21955 invoked by uid 500); 22 Jun 2015 08:14:34 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 21911 invoked by uid 500); 22 Jun 2015 08:14:34 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 21898 invoked by uid 99); 22 Jun 2015 08:14:34 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Jun 2015 08:14:34 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 214821819EA for ; Mon, 22 Jun 2015 08:14:34 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.879 X-Spam-Level: ** X-Spam-Status: No, score=2.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id H0bVoldLkGHm for ; Mon, 22 Jun 2015 08:14:32 +0000 (UTC) Received: from mail-vn0-f53.google.com (mail-vn0-f53.google.com [209.85.216.53]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 106CB261A0 for ; Mon, 22 Jun 2015 08:14:32 +0000 (UTC) Received: by vnbf129 with SMTP id f129so1246995vnb.4 for ; Mon, 22 Jun 2015 01:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=bNI+BF9bwK8G69+n229uvb854alKbOPeZgYlbzxbmcI=; b=OVc5kZv9+qH2dxHp/f2F64AV8Nm144xqlBYEPFcQRHj41y2hEHCPsK3N1/OmvzFR/F XfDBWNjuMOHiCXHUk0LCI1YMDfOgO3lxHOYh7nxaSM3hWSrIUncvok7YwQs+u+BNpuSM DEBe2AShmZ9kuYCxU9hZyKiHPB4oekrZIDDm+v5pVfXl4QM5cfFjJ4mTy5J7bnxzhtD/ rWC5wNXh/AWVEkdoaZQXHG6+VgTUH62TpB+AsgSbtW34URhipPNhzDo/MsXZEShtaBHy SXEyQXYp3Ccc85msNgoaErK2BSKdkBNt/two/gXuY5dpU9yB098aaCmYdCoMgwQNaGG4 CRng== MIME-Version: 1.0 X-Received: by 10.52.52.114 with SMTP id s18mr24900467vdo.9.1434960871220; Mon, 22 Jun 2015 01:14:31 -0700 (PDT) Received: by 10.53.3.172 with HTTP; Mon, 22 Jun 2015 01:14:31 -0700 (PDT) Date: Mon, 22 Jun 2015 11:14:31 +0300 Message-ID: Subject: Malfunction OnlineEventsBridgeMode From: David Hadas To: dev@cordova.apache.org Cc: Gil Dayagi Content-Type: multipart/alternative; boundary=089e0111d57cfeecf6051916dc1c --089e0111d57cfeecf6051916dc1c Content-Type: text/plain; charset=UTF-8 Hi, Apologies for any potential mishaps as this is a first communication with the Cordova community. We may be reporting or shedding light on a known issue. While hunting a bug on an S3 Neo android 4.3 device, resulting in file API not reporting success/failure during asynchronous calls, we had learned that OnlineEventsBridgeMode (NativeToJsMessageQueue.java) seem to be broken. We noticed that from a certain point in time, the Boolean *online* was always set to false during: toggleNetworkRunnable { ... webView.setNetworkAvailable(*online*) } Consequently there were no more online/offline events triggered at the JS and no more consequent polling of messages. To be more precise, events from JAVA to JS were delivered only when someone from the JS was calling androidExec (cordova.js) and never during online/offline events. As a result, we were always missing the last set of events as there were stuck down at the JAVA queue resulting in application freeze. (Once that started, the Boolean *online* was no longer being toggled via notifyOfFlush resulting in a permanent failure resolved only when reloading the software). As far as we understand, WebView only deliverers online/offline events to JS if the state of the Network changes i.e. if after a call to webView. setNetworkAvailable(*false*) one would call webView.setNetworkAvailable( *true*) and vice versa. This means that by design, Cordova seeks to maintain the Boolean *online* to maintain the inverse state of the WebView Network state. If/when the Boolean *online* looses track of the WebView Network state, the system online/offline events are discontinued until software reloading. Till now we were unable to track down the exact sequence leading the Boolean *online* to loose track of the WebView Network state in our system, but we do notice a sequence of two consecutive calls to notifyOfFlush, flipping the Boolean *online* twice - thereafter the Boolean *online* seem to have lost track of the WebView Network state and online/offline events no longer propagated to JS. If our understanding is indeed correct..... than, our main concern is that this design does not converge to a stable state and that inview of the asynchronous nature of the design and reliance on WebView specifics, a KISS methodology which would not put the code at risk of coming into a complete halt in view of a single mishap may be better. I.e. a design with a better self healing property following mishaps. We tried out a simple modification by replacing: webView.setNetworkAvailable(*online*); with: webView.setNetworkAvailable(*true*); // trigger an event webView.setNetworkAvailable(*false*); // reset the webView to its default state This had apparently solved the issues in our S3 Neo android 4.3 device though more testing are needed. If this approach is adopted, it requires cleaning up the code and removing now redundant code such as the notifyOfFlush mechanism which would no longer be needed, same for the JS event listener for offline events etc. This we hope would result in overall simplification of code in this area and better stability and endurance to mishaps. On the negative side, this alternative design results in doubling the amount of times in which webView. setNetworkAvailable() is toggled - forcing certain overhead. Yet, notice that there is no longer a need for cordova.js to listen to offline events, such that the added offline processing is now limited to the WebView internal overhead which is likely to be slim. Please advise, Reg, David Hadas --089e0111d57cfeecf6051916dc1c--