Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKWebView is trying to run on background, although it's closed and should be disposed

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"?

like image 939
ytrewq Avatar asked Dec 05 '20 21:12

ytrewq


People also ask

How do I release WKWebView?

Common Ways That Developers Leak WKWebViews The most common way to leak WKWebViews is to allocate new ones instead of reusing ones that you've already created. Sometimes, engineers think they are properly reusing webviews, but they do not check for buildups of WKWebView instances when profiling in Xcode.

Is WKWebView the same as Safari?

WKWebView is acting different (outdated browser) than Safari (iOS version of Safari ofc). If I visit adidas.com/yeezy on Safari, there is no problem. But when I visit this site in WKWebView, it says that the browser is not modern enough. I really need to fix this otherwise my app can't work.

What is the difference between UIWebView and WKWebView?

Difference Between UIWebview and WKWebView UIWebview is a part of UIKit, so it is available to your apps as standard. You don't need to import anything, it will we there by default. But WKWebView is run in a separate process to your app,. You need to import Webkit to use WKWebView in your app.

What is a WKWebView?

Overview. A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app's UI. A web view supports a full web-browsing experience, and presents HTML, CSS, and JavaScript content alongside your app's native views.


1 Answers

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
like image 161
Ivan Avatar answered Nov 08 '22 17:11

Ivan