Remove setTimeout() when sending plugin results. Exec() benchmark on an iPad2: (before) IFRAME_NAV: 300 XHR_NO_PAYLOAD: 150 XHR_WITH_PAYLOAD: 190 IFRAME_NAV+async: 143 XHR_NO_PAYLOAD+async: 120 XHR_WITH_PAYLOAD+async: 110
(after) IFRAME_NAV: 800-900 XHR_NO_PAYLOAD: 830-880 XHR_WITH_PAYLOAD: 350 IFRAME_NAV+async: 200-300 XHR_NO_PAYLOAD+async: 150 XHR_WITH_PAYLOAD+async: 200 Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/c8ac3c26 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/c8ac3c26 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/c8ac3c26 Branch: refs/heads/master Commit: c8ac3c2607e9b0dd7d00898e1276337eeaa10044 Parents: 1a41569 Author: Andrew Grieve <agri...@chromium.org> Authored: Thu Oct 4 11:43:13 2012 -0400 Committer: Andrew Grieve <agri...@chromium.org> Committed: Thu Oct 4 11:43:13 2012 -0400 ---------------------------------------------------------------------- CordovaLib/Classes/CDVPlugin.m | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/c8ac3c26/CordovaLib/Classes/CDVPlugin.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVPlugin.m b/CordovaLib/Classes/CDVPlugin.m index 2f8b4f2..a747d75 100644 --- a/CordovaLib/Classes/CDVPlugin.m +++ b/CordovaLib/Classes/CDVPlugin.m @@ -95,9 +95,9 @@ // override to remove caches, etc } -- (void) onReset +- (void)onReset { - // Override to cancel any long-running requests when the WebView navigates or refreshes. + // Override to cancel any long-running requests when the WebView navigates or refreshes. } - (void)dealloc @@ -127,12 +127,12 @@ - (NSString*)success:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId { - return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toSuccessCallbackString:callbackId]]]; + return [self writeJavascript:[pluginResult toSuccessCallbackString:callbackId]]; } - (NSString*)error:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId { - return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toErrorCallbackString:callbackId]]]; + return [self writeJavascript:[pluginResult toErrorCallbackString:callbackId]]; } @end