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"?
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.
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.
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.
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.
I am facing same issues and found these two interesting threads:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With