You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/10/15 16:01:24 UTC
ios commit: CB-5037 Fix bridge sometimes not resetting properly
during page transitions
Updated Branches:
refs/heads/master da98a3d55 -> 18252a746
CB-5037 Fix bridge sometimes not resetting properly during page transitions
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/18252a74
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/18252a74
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/18252a74
Branch: refs/heads/master
Commit: 18252a7463823518622ef5aafdc442eda3c796c7
Parents: da98a3d
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Oct 11 20:47:42 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Oct 15 10:01:14 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVCommandQueue.m | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/18252a74/CordovaLib/Classes/CDVCommandQueue.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandQueue.m b/CordovaLib/Classes/CDVCommandQueue.m
index 6af31c8..851d28c 100644
--- a/CordovaLib/Classes/CDVCommandQueue.m
+++ b/CordovaLib/Classes/CDVCommandQueue.m
@@ -66,10 +66,22 @@
- (void)maybeFetchCommandsFromJs:(NSNumber*)requestId
{
+ NSInteger rid = [requestId integerValue];
+
+ // An ID of 1 is a special case because that signifies the first request of
+ // the page. Since resetRequestId is called from webViewDidStartLoad, and the
+ // JS context at the time of webViewDidStartLoad is still that of the previous
+ // page, it's possible for requests from the previous page to come in after this
+ // point. We ignore these by enforcing that ID=1 be the first ID.
+ if ((_lastCommandQueueFlushRequestId == 0) && (rid != 1)) {
+ CDV_EXEC_LOG(@"Exec: Ignoring exec request from previous page.");
+ return;
+ }
+
// Use the request ID to determine if we've already flushed for this request.
// This is required only because the NSURLProtocol enqueues the same request
// multiple times.
- if ([requestId integerValue] > _lastCommandQueueFlushRequestId) {
+ if (rid > _lastCommandQueueFlushRequestId) {
_lastCommandQueueFlushRequestId = [requestId integerValue];
[self fetchCommandsFromJs];
}
@@ -81,10 +93,8 @@
NSString* queuedCommandsJSON = [_viewController.webView stringByEvaluatingJavaScriptFromString:
@"cordova.require('cordova/exec').nativeFetchMessages()"];
+ CDV_EXEC_LOG(@"Exec: Flushed JS->native queue (hadCommands=%d).", [queuedCommandsJSON length] > 0);
[self enqueCommandBatch:queuedCommandsJSON];
- if ([queuedCommandsJSON length] > 0) {
- CDV_EXEC_LOG(@"Exec: Retrieved new exec messages by request.");
- }
}
- (void)executePending