Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 25665D950 for ; Tue, 25 Sep 2012 17:10:04 +0000 (UTC) Received: (qmail 49939 invoked by uid 500); 25 Sep 2012 17:10:04 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 49875 invoked by uid 500); 25 Sep 2012 17:10:04 -0000 Mailing-List: contact callback-commits-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-commits@incubator.apache.org Received: (qmail 49864 invoked by uid 99); 25 Sep 2012 17:10:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Sep 2012 17:10:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9E6F03B5A7; Tue, 25 Sep 2012 17:10:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: js commit: [ios] Attempt to fix a crash in iOS XHR bridge mode. Message-Id: <20120925171003.9E6F03B5A7@tyr.zones.apache.org> Date: Tue, 25 Sep 2012 17:10:03 +0000 (UTC) Updated Branches: refs/heads/master de45f5d2a -> 533c707ee [ios] Attempt to fix a crash in iOS XHR bridge mode. Relevant issue: https://issues.apache.org/jira/browse/CB-1404 Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/533c707e Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/533c707e Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/533c707e Branch: refs/heads/master Commit: 533c707ee48f1191fde2d92376b1a5cc45e4a72a Parents: de45f5d Author: Andrew Grieve Authored: Tue Sep 25 13:08:53 2012 -0400 Committer: Andrew Grieve Committed: Tue Sep 25 13:08:53 2012 -0400 ---------------------------------------------------------------------- lib/ios/exec.js | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/533c707e/lib/ios/exec.js ---------------------------------------------------------------------- diff --git a/lib/ios/exec.js b/lib/ios/exec.js index 1759ecc..6635c0b 100644 --- a/lib/ios/exec.js +++ b/lib/ios/exec.js @@ -115,6 +115,14 @@ function iOSExec() { // which case the command will be picked up without notification. if (cordova.commandQueue.length == 1 && !cordova.commandQueueFlushing) { if (bridgeMode) { + // Re-using the XHR improves exec() performance by about 10%. + // It is possible for a native stringByEvaluatingJavascriptFromString call + // to cause us to reach this point when a request is already in progress, + // so we check the readyState to guard agains re-using an inprogress XHR. + // Refer to CB-1404. + if (execXhr && execXhr.readyState != 4) { + execXhr = null; + } execXhr = execXhr || new XMLHttpRequest(); // Changing this to a GET will make the XHR reach the URIProtocol on 4.2. // For some reason it still doesn't work though...