Apache Cordova
  1. Apache Cordova
  2. CB-3530

PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

    Details

      Description

      I have a PhoneGap app on iOS which was working fine with PhoneGap 2.3.0 but crashes with 2.7.0 with the following error:

      2013-05-02 10:08:13.214 App[8896:c07] CDVWebViewDelegate: Navigation started when state=1

      2013-05-02 10:08:13.215 App[8896:c07] Failed to load webpage with error: (null)

      The problem is:
      CDVWebViewDelegate.m: shouldStartLoadWithRequest() function: In switch case, default: error code is being passed as nil

      and in CDVInAppBrowser.m: didFailLoadWithError() function, error.localizedDescription is being referenced, which causes a crash as error object is nil.

      For now, i added a check in the above function to put default values for error code if the error object is nil. I hope this crash is fixed in the next PhoneGap release.

      1. 2013-07-08.crash
        36 kB
        Fabian Chacon Carrillo
      2. 2013-07-08.crash
        36 kB
        Fabian Chacon Carrillo

        Issue Links

          Activity

          Hide
          Ginil Fernandez added a comment -

          Just confirming this occurs in the main webview as well as the inapp browser. It seems to be related to having a hashtag in the URL.

          Show
          Ginil Fernandez added a comment - Just confirming this occurs in the main webview as well as the inapp browser. It seems to be related to having a hashtag in the URL.
          Hide
          Montyleena added a comment - - edited

          wow, thanks for the info. Apparently, the error "CDVWebViewDelegate: Navigation started when state=1" is only coming with 2.7.0. After getting this error, we see "Load error" in the InAppBrowser status bar. I hope this gets fixed in the next release.

          Show
          Montyleena added a comment - - edited wow, thanks for the info. Apparently, the error "CDVWebViewDelegate: Navigation started when state=1" is only coming with 2.7.0. After getting this error, we see "Load error" in the InAppBrowser status bar. I hope this gets fixed in the next release.
          Hide
          Shazron Abdullah added a comment -

          Hi all, what is the window.open code to replicate this?

          Show
          Shazron Abdullah added a comment - Hi all, what is the window.open code to replicate this?
          Hide
          Montyleena added a comment -

          var ref = window.open(url, '_blank', 'location=yes');
          The app doesn't crash immediately. Once i close the child browser and try to do anything in the main app, it crashes

          Show
          Montyleena added a comment - var ref = window.open(url, '_blank', 'location=yes'); The app doesn't crash immediately. Once i close the child browser and try to do anything in the main app, it crashes
          Hide
          Shazron Abdullah added a comment -

          Please provide a url that this can be replicated on, since I can't repro this

          Show
          Shazron Abdullah added a comment - Please provide a url that this can be replicated on, since I can't repro this
          Hide
          Montyleena added a comment -

          Try with this URL: en.wikipedia.org/wiki/Hashtag
          Click on different items in the TOC like Origin, Style etc. if you don't get the error the 1st time after clicking on an item, then scroll to the top of this URL page and click on another link, eventually you will get the following error:

          "CDVWebViewDelegate: Navigation started when state=1"
          "webView: didFailLoadWithError - (null)

              • WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[3]

          I can reproduce this even on the iPad simulator. After this error, all links stop working in the same instance of InAppBrowser and i get 3 lines of error mentioned above.

          Show
          Montyleena added a comment - Try with this URL: en.wikipedia.org/wiki/Hashtag Click on different items in the TOC like Origin, Style etc. if you don't get the error the 1st time after clicking on an item, then scroll to the top of this URL page and click on another link, eventually you will get the following error: "CDVWebViewDelegate: Navigation started when state=1" "webView: didFailLoadWithError - (null) WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> *** - [__NSPlaceholderDictionary initWithObjects:forKeys:count:] : attempt to insert nil object from objects [3] I can reproduce this even on the iPad simulator. After this error, all links stop working in the same instance of InAppBrowser and i get 3 lines of error mentioned above.
          Hide
          Shazron Abdullah added a comment -

          Thank you! I'll verify and fix tomorrow.

          Show
          Shazron Abdullah added a comment - Thank you! I'll verify and fix tomorrow.
          Hide
          Montyleena added a comment -

          Thanks! that sounds good. Will this fix be included in 2.8.0?
          Can you please also look at this issue: https://issues.apache.org/jira/browse/CB-3531

          Show
          Montyleena added a comment - Thanks! that sounds good. Will this fix be included in 2.8.0? Can you please also look at this issue: https://issues.apache.org/jira/browse/CB-3531
          Hide
          Shazron Abdullah added a comment -

          Still couldn't repro, but found the culprit I think (thanks for the clues in the description): https://github.com/apache/cordova-ios/blob/7e0a32892a540295e7de5da6a4832dfdaf337ac0/CordovaLib/Classes/CDVWebViewDelegate.m#L200

          didFailLoadWithError code always assumes that the NSError passed in is not nil. The fix is not to pass in nil there but create a default one.

          Show
          Shazron Abdullah added a comment - Still couldn't repro, but found the culprit I think (thanks for the clues in the description): https://github.com/apache/cordova-ios/blob/7e0a32892a540295e7de5da6a4832dfdaf337ac0/CordovaLib/Classes/CDVWebViewDelegate.m#L200 didFailLoadWithError code always assumes that the NSError passed in is not nil. The fix is not to pass in nil there but create a default one.
          Hide
          ASF subversion and git services added a comment -

          Commit e7fbca99e3e38586f68771bfc2a09f5ee420dd67 in branch refs/heads/master from Shazron Abdullah <shazron@apache.org>
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=e7fbca9 ]

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1"

          Show
          ASF subversion and git services added a comment - Commit e7fbca99e3e38586f68771bfc2a09f5ee420dd67 in branch refs/heads/master from Shazron Abdullah <shazron@apache.org> [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=e7fbca9 ] CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1"
          Hide
          ASF subversion and git services added a comment -

          Commit 45d3fb2084b40fe896c86623e7e890a25764dc81 in branch refs/heads/2.8.x from Shazron Abdullah <shazron@apache.org>
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=45d3fb2 ]

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1"

          Show
          ASF subversion and git services added a comment - Commit 45d3fb2084b40fe896c86623e7e890a25764dc81 in branch refs/heads/2.8.x from Shazron Abdullah <shazron@apache.org> [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=45d3fb2 ] CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1"
          Hide
          Montyleena added a comment -

          That's great! Thanks a lot!

          Show
          Montyleena added a comment - That's great! Thanks a lot!
          Hide
          Montyleena added a comment -

          Can you please check https://issues.apache.org/jira/browse/CB-3576 and https://issues.apache.org/jira/browse/CB-3531?
          I think CB-3576 can be fixed easily. It's really a problem that we can't access locally signed https URLs in InAppBrowser.

          Show
          Montyleena added a comment - Can you please check https://issues.apache.org/jira/browse/CB-3576 and https://issues.apache.org/jira/browse/CB-3531? I think CB-3576 can be fixed easily. It's really a problem that we can't access locally signed https URLs in InAppBrowser.
          Hide
          Montyleena added a comment -

          Thanks for the fix! when can we expect 2.8.0 with this fix?

          Show
          Montyleena added a comment - Thanks for the fix! when can we expect 2.8.0 with this fix?
          Hide
          Ulrich Schleicher added a comment -

          I get this Error with Phonegap 2.8.0 The App works on Android fine, but on iOS I get this error.

          Show
          Ulrich Schleicher added a comment - I get this Error with Phonegap 2.8.0 The App works on Android fine, but on iOS I get this error.
          Hide
          Montyleena added a comment -

          I tested this today with 2.8.0 and the issue is not entirely fixed. The navigation doesn't break now and the app doesn't crash (compared to 2.7.0) but the error "CDVWebViewDelegate: Navigation started when state=1" can still be seen on the XCode debug terminal and the InAppBrowser tool bar displays a "Load Error" so it's very misleading for the user. Here's the complete error trace:

          "CDVWebViewDelegate: Navigation started when state=1"
          "webView:didFailLoadWithError - CDVWebViewDelegate: Navigation started when state=1"

          It seems that the fix only handled nil being passed as error code but didn't handle the reason why "CDVWebViewDelegate: Navigation started when state=1" error is coming

          Show
          Montyleena added a comment - I tested this today with 2.8.0 and the issue is not entirely fixed. The navigation doesn't break now and the app doesn't crash (compared to 2.7.0) but the error "CDVWebViewDelegate: Navigation started when state=1" can still be seen on the XCode debug terminal and the InAppBrowser tool bar displays a "Load Error" so it's very misleading for the user. Here's the complete error trace: "CDVWebViewDelegate: Navigation started when state=1" "webView:didFailLoadWithError - CDVWebViewDelegate: Navigation started when state=1" It seems that the fix only handled nil being passed as error code but didn't handle the reason why "CDVWebViewDelegate: Navigation started when state=1" error is coming
          Hide
          Montyleena added a comment -

          The issue is not entirely fixed. Please check my latest comment for more details.

          Show
          Montyleena added a comment - The issue is not entirely fixed. Please check my latest comment for more details.
          Hide
          Fredy Levin added a comment - - edited

          I'm getting a very similar behavior on 2.8.0 in iOS to what Montyleena described.
          The complete error trace is:

          "CDVWebViewDelegate: Navigation started when state=1"
          "Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1"

          What could be done to fix this?

          Show
          Fredy Levin added a comment - - edited I'm getting a very similar behavior on 2.8.0 in iOS to what Montyleena described. The complete error trace is: "CDVWebViewDelegate: Navigation started when state=1" "Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1" What could be done to fix this?
          Hide
          Shazron Abdullah added a comment -

          Ok, I'll take a look again but the author of the state machine code is away so it may take some time for me to get familiar. But does anything actually fail? (besides the error message). Anything on the loaded webpage that is not working?

          Show
          Shazron Abdullah added a comment - Ok, I'll take a look again but the author of the state machine code is away so it may take some time for me to get familiar. But does anything actually fail? (besides the error message). Anything on the loaded webpage that is not working?
          Hide
          Montyleena added a comment -

          @Shazron, there is no issue with the functionality after getting this error but the InAppBrowser tool bar displays the message: "Load Error" so it's very misleading for the user, so this does needs to be fixed. This issue wasn't coming in 2.4.0 on iOS (i upgraded from 2.4.0 to 2.7.0 and now 2.8.0)

          Show
          Montyleena added a comment - @Shazron, there is no issue with the functionality after getting this error but the InAppBrowser tool bar displays the message: "Load Error" so it's very misleading for the user, so this does needs to be fixed. This issue wasn't coming in 2.4.0 on iOS (i upgraded from 2.4.0 to 2.7.0 and now 2.8.0)
          Hide
          Fredy Levin added a comment -

          Not sure if it's related but I'm experiencing a "blinking" effect when transitioning within a single page app and using href="#pagetwo" which I didn't notice this on 2.6.0.

          Could it be relevant?
          If not, do you happen to know how I can deal with it?

          Show
          Fredy Levin added a comment - Not sure if it's related but I'm experiencing a "blinking" effect when transitioning within a single page app and using href="#pagetwo" which I didn't notice this on 2.6.0. Could it be relevant? If not, do you happen to know how I can deal with it?
          Hide
          Monica Magallanes added a comment - - edited

          Fredy Levin: Is your code fully working with this "blinking"? I do have the same problem. The console log shows twice the error message every time I change page and using anchors href="#pagetwo". I'm using 2.8.0.

          "CDVWebViewDelegate: Navigation started when state=1"
          "Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1"

          Show
          Monica Magallanes added a comment - - edited Fredy Levin: Is your code fully working with this "blinking"? I do have the same problem. The console log shows twice the error message every time I change page and using anchors href="#pagetwo". I'm using 2.8.0. "CDVWebViewDelegate: Navigation started when state=1" "Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1"
          Hide
          Fredy Levin added a comment -

          Monica, the code seems to be working but the blinking thing obviously affects user experience.
          I'm getting the same 2 error messages as you are but only from the 2nd transition, the first one doesn't generate any errors.

          Show
          Fredy Levin added a comment - Monica, the code seems to be working but the blinking thing obviously affects user experience. I'm getting the same 2 error messages as you are but only from the 2nd transition, the first one doesn't generate any errors.
          Hide
          Ulrich Schleicher added a comment -

          I solved the problem for my issue i used jquery mobile but dont usecthis then you get the error too. $.mobile.changePage( "../resources/confirm.html"). You have to use it in this way
          $.mobile.changePage( '../resources/confirm.html'). Now the works on ios fine.

          Show
          Ulrich Schleicher added a comment - I solved the problem for my issue i used jquery mobile but dont usecthis then you get the error too. $.mobile.changePage( "../resources/confirm.html"). You have to use it in this way $.mobile.changePage( '../resources/confirm.html'). Now the works on ios fine.
          Hide
          Farhad Farzaneh added a comment -

          I am having same problem on 2.7.0 on iOS with jqueryMobile. It seems that if you navigate from one part of a document to another using jqueryMobile, it triggers a loadPage() method. This in turn triggers shouldStartLoadWithRequest: in the CDVWebViewDelegate, which bumps the state from STATE_IDLE to STATE_WAITING_FOR_LOAD_START. However, because the page is already loaded, and doesn't really require further loading, no other state events are triggered, so the _state gets stuck waiting for a load start, and you'll keep getting this message.

          I'm not familiar enough with the source, but it seems we should be able to know that that we're already on the page, and change the state transitioning logic accordingly if we're just moving from one hashtagged ref to another.

          Show
          Farhad Farzaneh added a comment - I am having same problem on 2.7.0 on iOS with jqueryMobile. It seems that if you navigate from one part of a document to another using jqueryMobile, it triggers a loadPage() method. This in turn triggers shouldStartLoadWithRequest: in the CDVWebViewDelegate, which bumps the state from STATE_IDLE to STATE_WAITING_FOR_LOAD_START. However, because the page is already loaded, and doesn't really require further loading, no other state events are triggered, so the _state gets stuck waiting for a load start, and you'll keep getting this message. I'm not familiar enough with the source, but it seems we should be able to know that that we're already on the page, and change the state transitioning logic accordingly if we're just moving from one hashtagged ref to another.
          Hide
          Farhad Farzaneh added a comment - - edited

          I solved the problem for my use case by inserting the following code in CDVWebViewDelegate.m in method - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType

          [line 166 in my version]

          //    We're going to check if this URL is simply moving from one part of a document to another.  If it is, we should not load it again 
              if ( webView && webView.request && webView.request.URL ) {
                  NSString *prevUrl, *requestUrl;
                  prevUrl = webView.request.URL.absoluteString;
          
                  NSString *urlFragment =@"#";
                  if (webView.request.URL.fragment)
                      urlFragment = [urlFragment stringByAppendingString:webView.request.URL.fragment];
                  NSRange range = [prevUrl rangeOfString:urlFragment];
                  prevUrl = [prevUrl substringToIndex:range.location];
                  
                  urlFragment = @"#";
                  if ( request.URL.fragment )
                      urlFragment = [urlFragment stringByAppendingString:request.URL.fragment];
                  requestUrl = [request.URL.absoluteString substringToIndex:range.location];
                  
                  //  Actually not sure if this should return YES or NO - NO works for my use case
                  if ( [prevUrl isEqualToString:requestUrl] )
                      return NO;
              }
          
          Show
          Farhad Farzaneh added a comment - - edited I solved the problem for my use case by inserting the following code in CDVWebViewDelegate.m in method - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType [line 166 in my version] // We're going to check if this URL is simply moving from one part of a document to another. If it is, we should not load it again if ( webView && webView.request && webView.request.URL ) { NSString *prevUrl, *requestUrl; prevUrl = webView.request.URL.absoluteString; NSString *urlFragment =@ "#" ; if (webView.request.URL.fragment) urlFragment = [urlFragment stringByAppendingString:webView.request.URL.fragment]; NSRange range = [prevUrl rangeOfString:urlFragment]; prevUrl = [prevUrl substringToIndex:range.location]; urlFragment = @ "#" ; if ( request.URL.fragment ) urlFragment = [urlFragment stringByAppendingString:request.URL.fragment]; requestUrl = [request.URL.absoluteString substringToIndex:range.location]; // Actually not sure if this should return YES or NO - NO works for my use case if ( [prevUrl isEqualToString:requestUrl] ) return NO; }
          Hide
          Shazron Abdullah added a comment -

          I think Farhad Farzaneh's proposed solution is the answer. Farhad, if you have a pull request, that would be great so we can credit you (and make changes as appropriate).

          If not I could adapt it, add tests, and put it in for you.

          Show
          Shazron Abdullah added a comment - I think Farhad Farzaneh 's proposed solution is the answer. Farhad, if you have a pull request, that would be great so we can credit you (and make changes as appropriate). If not I could adapt it, add tests, and put it in for you.
          Hide
          Farhad Farzaneh added a comment -

          I don't have a pull request, and am actually not familiar enough with the code to understand the unintended consequences of my fix. One thought is that returning NO above could mess up the browsing history if someone is counting on that. Will try to test and report back.

          Also, not being familiar with objective-C, I looked to see if I could add tests by adapting from existing tests but didn't see anything appropriate. So please feel free to adapt and add tests.

          Show
          Farhad Farzaneh added a comment - I don't have a pull request, and am actually not familiar enough with the code to understand the unintended consequences of my fix. One thought is that returning NO above could mess up the browsing history if someone is counting on that. Will try to test and report back. Also, not being familiar with objective-C, I looked to see if I could add tests by adapting from existing tests but didn't see anything appropriate. So please feel free to adapt and add tests.
          Hide
          ASF subversion and git services added a comment -

          Commit caa93a57b0de81d619effff217fdc20fcc329bc4 in branch refs/heads/CB-3530 from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=caa93a5 ]

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          Show
          ASF subversion and git services added a comment - Commit caa93a57b0de81d619effff217fdc20fcc329bc4 in branch refs/heads/ CB-3530 from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=caa93a5 ] CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)
          Hide
          Shazron Abdullah added a comment -

          I pushed this to the CB-3530 branch, pending further testing. Unit tests added as well: https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=commit;h=caa93a57b0de81d619effff217fdc20fcc329bc4

          Show
          Shazron Abdullah added a comment - I pushed this to the CB-3530 branch, pending further testing. Unit tests added as well: https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=commit;h=caa93a57b0de81d619effff217fdc20fcc329bc4
          Hide
          ASF subversion and git services added a comment -

          Commit db43c7668c93e916eddba978475f22e6e8b9d61f in branch refs/heads/master from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=db43c76 ]

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          commit fe971530ea4bd5e083cc4d8f70f692f55bd3469f
          Author: Shazron Abdullah <shazron@apache.org>
          Date: Wed Jun 19 15:13:59 2013 -0700

          Remove verbose NSLogs.

          commit caa93a57b0de81d619effff217fdc20fcc329bc4
          Author: Shazron Abdullah <shazron@apache.org>
          Date: Tue Jun 18 17:50:01 2013 -0700

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          Show
          ASF subversion and git services added a comment - Commit db43c7668c93e916eddba978475f22e6e8b9d61f in branch refs/heads/master from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=db43c76 ] CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page) commit fe971530ea4bd5e083cc4d8f70f692f55bd3469f Author: Shazron Abdullah <shazron@apache.org> Date: Wed Jun 19 15:13:59 2013 -0700 Remove verbose NSLogs. commit caa93a57b0de81d619effff217fdc20fcc329bc4 Author: Shazron Abdullah <shazron@apache.org> Date: Tue Jun 18 17:50:01 2013 -0700 CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)
          Hide
          ASF subversion and git services added a comment -

          Commit db43c7668c93e916eddba978475f22e6e8b9d61f in branch refs/heads/master from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=db43c76 ]

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          commit fe971530ea4bd5e083cc4d8f70f692f55bd3469f
          Author: Shazron Abdullah <shazron@apache.org>
          Date: Wed Jun 19 15:13:59 2013 -0700

          Remove verbose NSLogs.

          commit caa93a57b0de81d619effff217fdc20fcc329bc4
          Author: Shazron Abdullah <shazron@apache.org>
          Date: Tue Jun 18 17:50:01 2013 -0700

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          Show
          ASF subversion and git services added a comment - Commit db43c7668c93e916eddba978475f22e6e8b9d61f in branch refs/heads/master from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=db43c76 ] CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page) commit fe971530ea4bd5e083cc4d8f70f692f55bd3469f Author: Shazron Abdullah <shazron@apache.org> Date: Wed Jun 19 15:13:59 2013 -0700 Remove verbose NSLogs. commit caa93a57b0de81d619effff217fdc20fcc329bc4 Author: Shazron Abdullah <shazron@apache.org> Date: Tue Jun 18 17:50:01 2013 -0700 CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)
          Hide
          ASF subversion and git services added a comment -

          Commit f1caddf404ceef7cb65e952cb93eebb7faddc7b9 in branch refs/heads/2.9.x from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=f1caddf ]

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          commit fe971530ea4bd5e083cc4d8f70f692f55bd3469f
          Author: Shazron Abdullah <shazron@apache.org>
          Date: Wed Jun 19 15:13:59 2013 -0700

          Remove verbose NSLogs.

          commit caa93a57b0de81d619effff217fdc20fcc329bc4
          Author: Shazron Abdullah <shazron@apache.org>
          Date: Tue Jun 18 17:50:01 2013 -0700

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          Show
          ASF subversion and git services added a comment - Commit f1caddf404ceef7cb65e952cb93eebb7faddc7b9 in branch refs/heads/2.9.x from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=f1caddf ] CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page) commit fe971530ea4bd5e083cc4d8f70f692f55bd3469f Author: Shazron Abdullah <shazron@apache.org> Date: Wed Jun 19 15:13:59 2013 -0700 Remove verbose NSLogs. commit caa93a57b0de81d619effff217fdc20fcc329bc4 Author: Shazron Abdullah <shazron@apache.org> Date: Tue Jun 18 17:50:01 2013 -0700 CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)
          Hide
          ASF subversion and git services added a comment -

          Commit f1caddf404ceef7cb65e952cb93eebb7faddc7b9 in branch refs/heads/2.9.x from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=f1caddf ]

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          commit fe971530ea4bd5e083cc4d8f70f692f55bd3469f
          Author: Shazron Abdullah <shazron@apache.org>
          Date: Wed Jun 19 15:13:59 2013 -0700

          Remove verbose NSLogs.

          commit caa93a57b0de81d619effff217fdc20fcc329bc4
          Author: Shazron Abdullah <shazron@apache.org>
          Date: Tue Jun 18 17:50:01 2013 -0700

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          Show
          ASF subversion and git services added a comment - Commit f1caddf404ceef7cb65e952cb93eebb7faddc7b9 in branch refs/heads/2.9.x from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=f1caddf ] CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page) commit fe971530ea4bd5e083cc4d8f70f692f55bd3469f Author: Shazron Abdullah <shazron@apache.org> Date: Wed Jun 19 15:13:59 2013 -0700 Remove verbose NSLogs. commit caa93a57b0de81d619effff217fdc20fcc329bc4 Author: Shazron Abdullah <shazron@apache.org> Date: Tue Jun 18 17:50:01 2013 -0700 CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)
          Hide
          Monica Magallanes added a comment -

          I have upgraded to Phonegap 2.9.0. The error was showing twice in 2.8.0. Now in 2.9.0 it shows only once under same circumstances. Is something else causing it? Should I do something else?

          Show
          Monica Magallanes added a comment - I have upgraded to Phonegap 2.9.0. The error was showing twice in 2.8.0. Now in 2.9.0 it shows only once under same circumstances. Is something else causing it? Should I do something else?
          Hide
          Shazron Abdullah added a comment -

          Monica Magallanes what url triggers this? Before this line: https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/CDVWebViewDelegate.m#L240

          Can you add this code and report if it gets printed out when you see the error:

           NSLog(@"CB-3530 -- original: %@ new: %@", [webView.request.URL description], [request.URL description]);
          
          Show
          Shazron Abdullah added a comment - Monica Magallanes what url triggers this? Before this line: https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/CDVWebViewDelegate.m#L240 Can you add this code and report if it gets printed out when you see the error: NSLog(@ "CB-3530 -- original: %@ new : %@" , [webView.request.URL description], [request.URL description]);
          Hide
          Monica Magallanes added a comment -

          I added the code just after line 246, where I can get the error printed as follows:
          2013-06-24 20:40:01.471 rex[10312:907] CDVWebViewDelegate: Navigation started when state=1
          2013-06-24 20:40:01.472 rex[10312:907] CB-3530 – original: file:///var/mobile/Applications/1DA0699E-3D17-4ACE-94AD-B165F12EE842/rex.app/www/index.html new: file:///var/mobile/Applications/1DA0699E-3D17-4ACE-94AD-B165F12EE842/rex.app/www/index.html#/var/mobile/Applications/1DA0699E-3D17-4ACE-94AD-B165F12EE842/rex.app/www/index.html

          Show
          Monica Magallanes added a comment - I added the code just after line 246, where I can get the error printed as follows: 2013-06-24 20:40:01.471 rex [10312:907] CDVWebViewDelegate: Navigation started when state=1 2013-06-24 20:40:01.472 rex [10312:907] CB-3530 – original: file:///var/mobile/Applications/1DA0699E-3D17-4ACE-94AD-B165F12EE842/rex.app/www/index.html new: file:///var/mobile/Applications/1DA0699E-3D17-4ACE-94AD-B165F12EE842/rex.app/www/index.html#/var/mobile/Applications/1DA0699E-3D17-4ACE-94AD-B165F12EE842/rex.app/www/index.html
          Hide
          Shazron Abdullah added a comment -

          Wow, that is one weird file URL for the new request! This certainly helps, thanks! I'll add this type of URL to the unit tests and re-fix, although I'm certainly curious why the URL is like that - I've never seen that in normal usage :/ Maybe it's a UI framework that is mucking about with things?

          Show
          Shazron Abdullah added a comment - Wow, that is one weird file URL for the new request! This certainly helps, thanks! I'll add this type of URL to the unit tests and re-fix, although I'm certainly curious why the URL is like that - I've never seen that in normal usage :/ Maybe it's a UI framework that is mucking about with things?
          Hide
          Shazron Abdullah added a comment -

          I updated the unit tests to test for the malformed fragment, and they all still pass. I think this is a case where this is an error, it still prints the error string, but is harmless since it doesn't report "Load Error" in the location bar.

          Show
          Shazron Abdullah added a comment - I updated the unit tests to test for the malformed fragment, and they all still pass. I think this is a case where this is an error, it still prints the error string, but is harmless since it doesn't report "Load Error" in the location bar.
          Hide
          ASF subversion and git services added a comment -

          Commit f7b82dab42fe7f45042c3d7c0a898e0c60940019 in branch refs/heads/master from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=f7b82da ]

          CB-3530 Updated unit tests

          Show
          ASF subversion and git services added a comment - Commit f7b82dab42fe7f45042c3d7c0a898e0c60940019 in branch refs/heads/master from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=f7b82da ] CB-3530 Updated unit tests
          Hide
          ASF subversion and git services added a comment -

          Commit c2cda903a85e958fec0ac0771cebdd4a73519a5d in branch refs/heads/2.9.x from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=c2cda90 ]

          CB-3530 Updated unit tests

          Show
          ASF subversion and git services added a comment - Commit c2cda903a85e958fec0ac0771cebdd4a73519a5d in branch refs/heads/2.9.x from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=c2cda90 ] CB-3530 Updated unit tests
          Hide
          Shazron Abdullah added a comment -

          Assigning to 3.0.0 to get a better fix in to eliminate the error message once and for all. Right now I believe it should never trigger a Load Error in the location bar if it's a navigation to a url fragment

          Show
          Shazron Abdullah added a comment - Assigning to 3.0.0 to get a better fix in to eliminate the error message once and for all. Right now I believe it should never trigger a Load Error in the location bar if it's a navigation to a url fragment
          Hide
          daryl hansen added a comment -

          I got this printed in my log:

          2013-06-27 16:01:59.201 HawaiiRealEstateApp[8091:c07] CDVWebViewDelegate: Navigation started when state=1
          2013-06-27 16:01:59.201 HawaiiRealEstateApp[8091:c07] Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1
          2013-06-27 16:01:59.201 HawaiiRealEstateApp[8091:c07] CB-3530 – original: file:///Users/daryl/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/CA6C0FC8-1928-4995-87E1-7EB363AF7F57/HawaiiRealEstateApp.app/www/index.html

          new: file:///Users/daryl/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/CA6C0FC8-1928-4995-87E1-7EB363AF7F57/HawaiiRealEstateApp.app/www/SearchResultsMaui.html?Class=Residential&AgentID%5B%5D=23949&AgentID%5B%5D=11258&AgentID%5B%5D=13485&AgentID%5B%5D=10027&SortField1=C_L_AskingPrice&SortOrder1=DESC&SortField2=C_LM_char10_69&SortOrder2=ASC#/Users/daryl/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/CA6C0FC8-1928-4995-87E1-7EB363AF7F57/HawaiiRealEstateApp.app/www/MauiPropertyDetails.html?WhatMLS=353039

          _______________________________________________________

          This confirms that is an issue with the hash tag, which is the way JQM navigates. This has been ongoing and I think it would be a good idea to fix this in a 2.9.1 version. I really don't want to wait for 3.0 and a get a whole slew of new issues. Can you please just fix this.

          Show
          daryl hansen added a comment - I got this printed in my log: 2013-06-27 16:01:59.201 HawaiiRealEstateApp [8091:c07] CDVWebViewDelegate: Navigation started when state=1 2013-06-27 16:01:59.201 HawaiiRealEstateApp [8091:c07] Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1 2013-06-27 16:01:59.201 HawaiiRealEstateApp [8091:c07] CB-3530 – original: file:///Users/daryl/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/CA6C0FC8-1928-4995-87E1-7EB363AF7F57/HawaiiRealEstateApp.app/www/index.html new: file:///Users/daryl/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/CA6C0FC8-1928-4995-87E1-7EB363AF7F57/HawaiiRealEstateApp.app/www/SearchResultsMaui.html?Class=Residential&AgentID%5B%5D=23949&AgentID%5B%5D=11258&AgentID%5B%5D=13485&AgentID%5B%5D=10027&SortField1=C_L_AskingPrice&SortOrder1=DESC&SortField2=C_LM_char10_69&SortOrder2=ASC#/Users/daryl/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/CA6C0FC8-1928-4995-87E1-7EB363AF7F57/HawaiiRealEstateApp.app/www/MauiPropertyDetails.html?WhatMLS=353039 _______________________________________________________ This confirms that is an issue with the hash tag, which is the way JQM navigates. This has been ongoing and I think it would be a good idea to fix this in a 2.9.1 version. I really don't want to wait for 3.0 and a get a whole slew of new issues. Can you please just fix this.
          Hide
          ASF subversion and git services added a comment -

          Commit f7b82dab42fe7f45042c3d7c0a898e0c60940019 in branch refs/heads/2.9.x from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=f7b82da ]

          CB-3530 Updated unit tests

          Show
          ASF subversion and git services added a comment - Commit f7b82dab42fe7f45042c3d7c0a898e0c60940019 in branch refs/heads/2.9.x from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=f7b82da ] CB-3530 Updated unit tests
          Hide
          daryl hansen added a comment -

          What are these "Updated Unit tests" that keep getting posted with a link to a file called CDVWebViewDelegateTests.m? Are these fixes or just tests?

          Show
          daryl hansen added a comment - What are these "Updated Unit tests" that keep getting posted with a link to a file called CDVWebViewDelegateTests.m? Are these fixes or just tests?
          Show
          Shazron Abdullah added a comment - Those are updates. The main commit was earlier: https://issues.apache.org/jira/browse/CB-3530?focusedCommentId=13687461&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13687461
          Hide
          daryl hansen added a comment -

          Can we use that to fix the bug?

          Show
          daryl hansen added a comment - Can we use that to fix the bug?
          Hide
          Shazron Abdullah added a comment -

          Of course - why wouldn't you, it is the fix for this bug, it is in the latest codebase.

          Show
          Shazron Abdullah added a comment - Of course - why wouldn't you, it is the fix for this bug, it is in the latest codebase.
          Hide
          daryl hansen added a comment -

          But the latest version 2.9 still has the same problem, so how could it be fixed?

          Show
          daryl hansen added a comment - But the latest version 2.9 still has the same problem, so how could it be fixed?
          Hide
          Shazron Abdullah added a comment -

          It's not the same problem - it will never show the error in the location bar anymore. This is still open because of the console log message.
          See: https://issues.apache.org/jira/browse/CB-3530?focusedCommentId=13693476&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13693476

          Show
          Shazron Abdullah added a comment - It's not the same problem - it will never show the error in the location bar anymore. This is still open because of the console log message. See: https://issues.apache.org/jira/browse/CB-3530?focusedCommentId=13693476&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13693476
          Hide
          Shazron Abdullah added a comment -

          Right now this doesn't affect any loading functionality, from what I gather.

          Show
          Shazron Abdullah added a comment - Right now this doesn't affect any loading functionality, from what I gather.
          Hide
          daryl hansen added a comment -

          Ah, OK. Thank you. I understand now. The bug is only related to the console log and won't effect the app we send to the Apple app store.

          Show
          daryl hansen added a comment - Ah, OK. Thank you. I understand now. The bug is only related to the console log and won't effect the app we send to the Apple app store.
          Hide
          Fabian Chacon Carrillo added a comment -

          Hi everyone, I'm using 2.9 version but I still have this error: Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1. So after some time clicking a link, the app crash and the done button of the InApp Browser disappeared, so I'm unable to back to my app. I don't know if this fact could help, but I realized that this error occurs most often in IPad mini.

          I appreciate any help, thanks in advance.

          Show
          Fabian Chacon Carrillo added a comment - Hi everyone, I'm using 2.9 version but I still have this error: Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1. So after some time clicking a link, the app crash and the done button of the InApp Browser disappeared, so I'm unable to back to my app. I don't know if this fact could help, but I realized that this error occurs most often in IPad mini. I appreciate any help, thanks in advance.
          Hide
          Shazron Abdullah added a comment -

          Fabian: if you have the crash log, that would be great

          Show
          Shazron Abdullah added a comment - Fabian: if you have the crash log, that would be great
          Hide
          Fabian Chacon Carrillo added a comment -

          Hi Shazron, do you have time to review the crash logs? Thanks in advance

          Show
          Fabian Chacon Carrillo added a comment - Hi Shazron, do you have time to review the crash logs? Thanks in advance
          Hide
          Shazron Abdullah added a comment - - edited

          Can't tell anything from that but I think it might be another type of crash unrelated to this one and may be related to the InAppBrowser (even though the error shows, it is benign).

          It could be this: CB-4147

          Show
          Shazron Abdullah added a comment - - edited Can't tell anything from that but I think it might be another type of crash unrelated to this one and may be related to the InAppBrowser (even though the error shows, it is benign). It could be this: CB-4147
          Hide
          ASF subversion and git services added a comment -

          Commit 8050fda8239a74875d3761ddcace718a62c00517 in branch refs/heads/master from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=8050fda ]

          CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)

          Moved error log to print only in the failure condition.

          Show
          ASF subversion and git services added a comment - Commit 8050fda8239a74875d3761ddcace718a62c00517 in branch refs/heads/master from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=8050fda ] CB-3530 PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page) Moved error log to print only in the failure condition.
          Hide
          Griffin Mobile added a comment -

          Hello,

          I currently have phone gap 3.4.0 and Xcode 5.1.1 and I'm getting the error message below - Do you have any ideas. I've been googling this for two days with not luck. I see that this was suppose to be fixed but not sure why I'm getting this error.

          CDVWebViewDelegate: Navigation started when state=1
          Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1

          v/r
          Donald Bozeman

          Show
          Griffin Mobile added a comment - Hello, I currently have phone gap 3.4.0 and Xcode 5.1.1 and I'm getting the error message below - Do you have any ideas. I've been googling this for two days with not luck. I see that this was suppose to be fixed but not sure why I'm getting this error. CDVWebViewDelegate: Navigation started when state=1 Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1 v/r Donald Bozeman
          Hide
          Rushabh Shah added a comment -

          Hello, I am also experiencing the same issue only this is occurring on both iOS and Android devices.

          The error occurs after I navigate back and forth between pages. It is not consistent, it takes about 10-15 navigations between pages before the error appears.

          I am using version 3.2.0

          Please let me know if you need any additional information.

          Thank you

          Show
          Rushabh Shah added a comment - Hello, I am also experiencing the same issue only this is occurring on both iOS and Android devices. The error occurs after I navigate back and forth between pages. It is not consistent, it takes about 10-15 navigations between pages before the error appears. I am using version 3.2.0 Please let me know if you need any additional information. Thank you
          Hide
          Pu Wang added a comment -

          I am using the latest cordova(3.5.0-0.2.7), I am still having this issue, and finally I found that the webview.request.absoluteString is always the root path of my website.

          And I fix it by update the CDVWebViewDelegate.m, the method: - (BOOL) request:(NSURLRequest*)newRequest isEqualToRequestAfterStrippingFragments:(UIWebView*)webview,
          changed the line:

          *NSTring* originalRequestUrl = [originalRequest.URL absoluteString]; *
          

          to :

          *NString& originalRequestUrl = [self evalForCurrentURL absoluteString];*
          

          I don't known why that the webview.request.URL is always the root of my website after navigate with JQM , but the method evalForCurrentURL will get the correct current url.

          Please review and check if the current fix really works.

          Show
          Pu Wang added a comment - I am using the latest cordova(3.5.0-0.2.7), I am still having this issue, and finally I found that the webview.request.absoluteString is always the root path of my website. And I fix it by update the CDVWebViewDelegate.m, the method: - (BOOL) request:(NSURLRequest*)newRequest isEqualToRequestAfterStrippingFragments:(UIWebView*)webview, changed the line: *NSTring* originalRequestUrl = [originalRequest.URL absoluteString]; * to : *NString& originalRequestUrl = [self evalForCurrentURL absoluteString];* I don't known why that the webview.request.URL is always the root of my website after navigate with JQM , but the method evalForCurrentURL will get the correct current url. Please review and check if the current fix really works.
          Hide
          Shazron Abdullah added a comment -

          For our purposes that method cannot be patched like how you did it, because of the unit tests, the function itself should not have a dependency on the evalForCurrentURL method, it perhaps should pass in a NSURL instead.

          Show
          Shazron Abdullah added a comment - For our purposes that method cannot be patched like how you did it, because of the unit tests, the function itself should not have a dependency on the evalForCurrentURL method, it perhaps should pass in a NSURL instead.
          Hide
          Pu Wang added a comment -

          That's good, I am expecting this to be fixed, but in my solution , I have to use the changes I made.

          thanks!

          Show
          Pu Wang added a comment - That's good, I am expecting this to be fixed, but in my solution , I have to use the changes I made. thanks!

            People

            • Assignee:
              Shazron Abdullah
              Reporter:
              Montyleena
            • Votes:
              0 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

              • Created:
                Updated:

                Development