问题描述
我在应用程序的 UIViewController 容器中有一个简单的 WKWebView.用户将使用 WKWebView 打开这个 UIViewController 容器,然后最终将使用导航返回"关闭它.物品.导航项配置容器和WKWebView.它有效,但在每次关闭时,我都会在日志中看到以下错误:
第一对错误:
[assertion] 获取断言时出错:<Error Domain=RBSAssertionErrorDomain Code=3 目标未运行或缺少所需的目标权利"用户信息={RBSAssertionAttribute=<RBSDomainAttribute|域:com.apple.webkit"名称:背景"sourceEnvironment:"(null)">, NSLocalizedFailureReason=目标未运行或缺少所需的目标权限}>
[ProcessSuspension] 0x7f8f9d404210 - ProcessAssertion:无法获取 PID 为 27176 的进程的 RBS 后台断言WebProcess 后台断言",错误:错误域=RBSAssertionErrorDomain 代码=3目标未运行或缺少所需的目标权利"用户信息={RBSAssertionAttribute=<RBSDomainAttribute|域:com.apple.webkit"名称:背景"sourceEnvironment:"(null)">, NSLocalizedFailureReason=目标未运行或缺少所需的目标权限}
第二对错误:
[assertion] 获取断言时出错:<Error Domain=RBSAssertionErrorDomain Code=2 指定的目标进程不存在";UserInfo={NSLocalizedFailureReason=指定的目标进程不存在}>
[ProcessSuspension] 0x7f8f9d005c30 - ProcessAssertion:无法获取 PID 为 27176 的进程的 RBS 后台断言WebProcess 后台断言",错误:错误域 = RBSAssertionErrorDomain 代码 = 2指定的目标进程不存在";UserInfo={NSLocalizedFailureReason=指定的目标进程不存在}
第三对错误:
无法向服务 com.apple.WebKit.WebContent 发出信号:113:找不到指定的服务
无法向服务 com.apple.WebKit.Networking 发出信号:113:找不到指定的服务
WKWebView 是从容器 UIViewController 的 viewDidDisappear
(也尝试将其移动到 viewWillDisappear
,这没有什么区别)以如下方式处理的:
webView.stopLoading()webView.configuration.userContentController.removeScriptMessageHandler(forName: "...")webView.navigationDelegate = nilwebView.scrollView.delegate = nil网络视图 = 零
这些错误似乎没有负面影响.但我想了解:我是否缺少对 WKWebView 处理的一些清理?为什么它试图进入背景"?
我面临同样的问题,发现以下两个有趣的主题:
- https://developer.apple.com/forums/thread/112095Apple 支持人员声称这些警告(例如,无法向服务 com.apple.WebKit.Networking 发出信号:113:找不到指定的服务)不是您应该担心的事情
- Xcode 8, iOS 10 - "启动 WebFilter 日志记录对于进程,这是帮助我消除这些警告的唯一解决方案.基本上,你应该设置 OS_ACTIVITY_MODE = disable
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:
Second pair of errors:
Third pair of errors:
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"?
I am facing same issues and found these two interesting threads:
- 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
- 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
这篇关于WKWebView 正在尝试在后台运行,尽管它已关闭并且应该被处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!