This is an automated email from the ASF dual-hosted git repository. GitToTheHub pushed a commit to branch pr-fix-ios-suppress-cancellations-errors-for-beforeload in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
commit 9559b6b063da0411da8617b407ddc98a96ab9d7f Author: Manuel Beck <[email protected]> AuthorDate: Tue May 5 14:52:19 2026 +0200 fix(ios): suppress expected cancellation errors when `beforeload` is set - If `beforeload` is set, there will an error logged for every page load: `webView:didFailProvisionalNavigation - 102: Frame load interrupted`. No the error will be suppressed if beforeload is set. - Add `isBeforeloadEnabled` to `CDVWKInAppBrowser` - Generated-By: GPT-5.3-Codex Co-authored-by: Copilot <[email protected]> --- src/ios/CDVWKInAppBrowser.h | 1 + src/ios/CDVWKInAppBrowser.m | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/ios/CDVWKInAppBrowser.h b/src/ios/CDVWKInAppBrowser.h index 12fcb19..a5ba51b 100644 --- a/src/ios/CDVWKInAppBrowser.h +++ b/src/ios/CDVWKInAppBrowser.h @@ -51,6 +51,7 @@ typedef NSDictionary CDVSettingsDictionary; - (void)show:(CDVInvokedUrlCommand *)command; - (void)hide:(CDVInvokedUrlCommand *)command; - (void)loadAfterBeforeload:(CDVInvokedUrlCommand *)command; +- (BOOL)isBeforeloadEnabled; @end diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index 92a35b4..a998f39 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -341,6 +341,11 @@ [self.inAppBrowserViewController navigateTo:url]; } +- (BOOL)isBeforeloadEnabled +{ + return ![_beforeload isEqualToString:@""]; +} + // This is a helper method for the inject{Script|Style}{Code|File} API calls, which // provides a consistent method for injecting JavaScript code into the document. // @@ -1170,11 +1175,28 @@ decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler - (void)webView:(WKWebView *)theWebView failedNavigation:(NSString *) delegateName withError:(nonnull NSError *)error { - // Log fail message, stop spinner, update back/forward - NSLog(@"webView:%@ - %ld: %@", delegateName, (long)error.code, [error localizedDescription]); self.backButton.enabled = theWebView.canGoBack; self.forwardButton.enabled = theWebView.canGoForward; [self.spinner stopAnimating]; + + BOOL isBeforeloadEnabled = self.navigationDelegate != nil && [self.navigationDelegate isBeforeloadEnabled]; + + // When using beforeload, navigations are intentionally cancelled and restarted. + // This results in expected cancellation errors with code NSURLErrorCancelled or + // WebKitErrorDomain code 102. Suppress these expected cancellation errors so + // they do not trigger false loaderror events. + BOOL isExpectedCancellation = + isBeforeloadEnabled && ( + (error.code == NSURLErrorCancelled) || + ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102) + ); + + if (isExpectedCancellation) { + return; + } + + // Populate error + NSLog(@"webView:%@ - %ld: %@", delegateName, (long)error.code, [error localizedDescription]); self.addressLabel.text = NSLocalizedString(@"Load Error", nil); [self.navigationDelegate webView:theWebView didFailNavigation:error]; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
