Home Blog Page 2

webkit – iOS 26 internet web page with script is terminated on customized scheme WKURLSchemeHandler


One thing has modified in iOS 26 (examined on beta 4) and now if customized scheme is used and internet web page accommodates script aspect then WebKit is terminated with following log:

0x1130bc170 - [PID=47858] WebProcessProxy::didClose: (internet course of 0 crash)
0x1130bc170 - [PID=47858] WebProcessProxy::processDidTerminateOrFailedToLaunch: motive=Crash

Steps to breed:

  1. Create WKWebView with customized configuration and customized url scheme handler
  2. Load HTML with script aspect inside that references to a different file

Anticipated consequence: WKWebView is loaded

Precise consequence: WKWebView is terminated

Code instance:

last class CustomSchemeViewController: UIViewController {
    override func viewDidLoad() {
        tremendous.viewDidLoad()

        let sampleConfiguration = WKWebViewConfiguration()
        sampleConfiguration.setURLSchemeHandler(
            SampleURLSchemeHandler(),
            forURLScheme: "pattern"
        )

        let webView = WKWebView(body: view.bounds, configuration: sampleConfiguration)
        webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        view.addSubview(webView)

        webView.navigationDelegate = self

        webView.load(URLRequest(url: URL(string: "pattern://pages/pattern.html")!))
    }
}

extension CustomSchemeViewController: WKNavigationDelegate {
    func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
        print("webViewWebContentProcessDidTerminate")
    }
}

last class SampleURLSchemeHandler: NSObject, WKURLSchemeHandler {
    personal func submit(_ physique: String, mimeType: String, urlSchemeTask: WKURLSchemeTask) {
        let physique = Information(physique.utf8)

        let response = URLResponse(
            url: urlSchemeTask.request.url!,
            mimeType: mimeType,
            expectedContentLength: physique.depend,
            textEncodingName: nil
        )

        urlSchemeTask.didReceive(response)
        urlSchemeTask.didReceive(physique)
        urlSchemeTask.didFinish()
    }

    func webView(_ webView: WKWebView, begin urlSchemeTask: WKURLSchemeTask) {
        change urlSchemeTask.request.url?.lastPathComponent {
        case "pattern.html":
            submit("""