incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject js commit: [ios] Attempt to fix a crash in iOS XHR bridge mode.
Date Tue, 25 Sep 2012 17:10:03 GMT
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 <agrieve@chromium.org>
Authored: Tue Sep 25 13:08:53 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
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...


Mime
View raw message