You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2026/05/06 15:27:40 UTC
(cordova-plugin-inappbrowser) branch master updated: fix(ios): suppress expected cancellation errors when `beforeload` is set (#1145)
This is an automated email from the ASF dual-hosted git repository.
GitToTheHub pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
The following commit(s) were added to refs/heads/master by this push:
new 0cea6cc fix(ios): suppress expected cancellation errors when `beforeload` is set (#1145)
0cea6cc is described below
commit 0cea6cc48feb85dae85ec624d6ebb5e03abe95ff
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Wed May 6 17:27:34 2026 +0200
fix(ios): suppress expected cancellation errors when `beforeload` is set (#1145)
- 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 <co...@github.com>
---
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 f8cec46..fea8bea 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -353,6 +353,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.
//
@@ -1186,11 +1191,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: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org