8

In NCE (Notification Content Extension) i use a WKWebView, which loads local and remote content

however, while the phone is locked, the method

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!)

will never get called and also

func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error)

func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error)

doesn't get called with any error

the webview gets stuck on loading... but all works as expected when the phone is unlocked

Is this a bug, or intended? how to avoid this, or detect this issue

Console output during activation of the NCE while phone is locked

2021-10-01 12:12:25.737559+0200 Minuta-NCE[4223:493144] [Process] 0x1022ce100 - [PID=4253] WebProcessProxy::didClose: (web process 4253 crash)
2021-10-01 12:12:25.737619+0200 Minuta-NCE[4223:493144] [Process] 0x1022ce100 - [PID=4253] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=3
2021-10-01 12:12:25.737726+0200 Minuta-NCE[4223:493144] [Process] 0x101824c18 - [pageProxyID=69, webPageID=70, PID=4253] WebPageProxy::processDidTerminate: (pid 4253), reason 3
2021-10-01 12:12:25.739596+0200 Minuta-NCE[4223:493144] [Loading] 0x101824c18 - [pageProxyID=69, webPageID=70, PID=4253] WebPageProxy::dispatchProcessDidTerminate: reason=3
2021-10-01 12:12:25.739746+0200 Minuta-NCE[4223:493144] [Process] 0x101824c18 - [pageProxyID=69, webPageID=70, PID=4253] WebPageProxy::tryReloadAfterProcessTermination: process crashed and the client did not handle it, not reloading the page because we reached the maximum number of attempts
2021-10-01 12:12:25.740206+0200 Minuta-NCE[4223:494960] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
2021-10-01 12:12:25.741077+0200 Minuta-NCE[4223:494960] [ProcessSuspension] 0x1022f9980 - ProcessAssertion: Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=4253, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
2021-10-01 12:12:25.742912+0200 Minuta-NCE[4223:494960] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
2021-10-01 12:12:25.742953+0200 Minuta-NCE[4223:494960] [ProcessSuspension] 0x1022f99e0 - ProcessAssertion: Failed to acquire RBS assertion 'WebProcess Background Assertion' for process with PID=4253, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
2021-10-01 12:12:25.746129+0200 Minuta-NCE[4223:494960] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}>
2021-10-01 12:12:25.746167+0200 Minuta-NCE[4223:494960] [ProcessSuspension] 0x1022f9aa0 - ProcessAssertion: Failed to acquire RBS assertion 'WebProcess Background Assertion' for process with PID=4253, error: Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}
2021-10-01 12:12:25.746444+0200 Minuta-NCE[4223:494960] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}>
2021-10-01 12:12:25.747201+0200 Minuta-NCE[4223:494960] [ProcessSuspension] 0x1022f9b00 - ProcessAssertion: Failed to acquire RBS assertion 'WebProcess Suspended Assertion' for process with PID=4253, error: Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}

but as mentioned earlier, sadly no error is returned back in code

Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179

1 Answers1

3

For now i only fix this with a user message displayed after a threshold timer

self.webView.loadFileURL(fileURL, allowingReadAccessTo: baseURL)
    
DispatchQueue.main.asyncAfter(deadline: .now() + 2) { [weak self] in
    
    guard let self = self else {return}
    if (!self.webLoaded && !self.webError) {
        self.infoLabel.text = "Device must be unlocked!"
    }
    
}
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
  • When trying to load a URL contents in Share extension I am getting this error `Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit"`. The content loads but I see this in the console. Does the extension require entitlement to run WebKit? (I am using LPLinkView, which might use WKWebView for fetching metadata) – user1046037 Nov 26 '21 at 00:40
  • 1
    i didn't found any entitlement that would enable it to work proper... at least none documented – Peter Lapisu Nov 26 '21 at 09:40
  • Thanks, If you have time, could you have a look at https://stackoverflow.com/questions/70118893/nsextension-runtime-warning-nsxpcdecoder-validateallowedclassforkey – user1046037 Nov 26 '21 at 10:28