Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKWebView in Notification Content Extension never loads while phone is locked

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

like image 219
Peter Lapisu Avatar asked Nov 14 '22 18:11

Peter Lapisu


1 Answers

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!"
    }
    
}
like image 88
Peter Lapisu Avatar answered Jun 10 '23 06:06

Peter Lapisu