9
votes

I have a simple WKWebView in a UIViewController container in the application. User will open this UIViewController container with WKWebView, and then will eventually close it with navigation "Back" item. The navigation item disposes container and WKWebView. It works, but on every closure I see the following errors in the log:

First pair of errors:

[assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>

[ProcessSuspension] 0x7f8f9d404210 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 27176, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}

Second pair of errors:

[assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}>

[ProcessSuspension] 0x7f8f9d005c30 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 27176, error: Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}

Third pair of errors:

Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service

The WKWebView is disposed from container UIViewController's viewDidDisappear (also tried to move it to viewWillDisappear, which made no difference) in the following way:

webView.stopLoading()
webView.configuration.userContentController.removeScriptMessageHandler(forName: "...")
webView.navigationDelegate = nil
webView.scrollView.delegate = nil
webView = nil

There's no negative side effects of those errors it seems. But I want to understand: am I missing some cleanup on WKWebView disposal? Why does it try to "enter background"?

2
I am getting the same set of errors, but I get them when I click on a link in the WKWebView that has a custom url scheme that my WKWebView is looking for using WKWebViewConfiguration().setURLSchemeHandler(...) I tried adding background processing via the Capabilities section in my Xcode project, but that had no change on the errors. - kdbdallas
I have a similar issue on iPhone 11 PRO and iPhone 11 Mini when using a Cordova app. See following issue for more info: stackoverflow.com/questions/67571345/… - Marcel Schürmann
@MarcelSchürmann in my case those were just warnings. So far we didn't see any side effects they caused or anything like that... - Kiril S.

2 Answers

4
votes

I am facing same issues and found these two interesting threads:

  1. https://developer.apple.com/forums/thread/112095 where a guy from Apple's support claims that these warnings (e.g. Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service) aren't something you should worry about
  2. Xcode 8, iOS 10 - "Starting WebFilter logging for process" this was the only solution that helped me silence these warnings. Basically, you should set OS_ACTIVITY_MODE = disable
-4
votes

I was able to get rid of the errors by adding this method to my VC

deinit{
   view = UIView()
   webView = nil
}

Hopefully this helps