gpt4 book ai didi

ios - WKWebView 正在尝试在后台运行,尽管它已关闭并且应该被处置

转载 作者:行者123 更新时间:2023-12-03 14:52:29 36 4
gpt4 key购买 nike

我在应用程序的 UIViewController 容器中有一个简单的 WKWebView。用户将使用 WKWebView 打开此 UIViewController 容器,然后最终使用导航“返回”项将其关闭。导航项配置容器和 WKWebView。它有效,但在每次关闭时,我都会在日志中看到以下错误:
第一对错误:

[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}


第二对错误:

[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}


第三对错误:

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


WKWebView 是从容器 UIViewController 的 viewDidDisappear 中配置的。 (也尝试通过以下方式将其移动到 viewWillDisappear ,这没有区别):
webView.stopLoading()
webView.configuration.userContentController.removeScriptMessageHandler(forName: "...")
webView.navigationDelegate = nil
webView.scrollView.delegate = nil
webView = nil
这些错误似乎没有负面影响。但我想了解:我是否错过了对 WKWebView 处置的一些清理工作?为什么它会尝试“进入后台”?

最佳答案

我面临同样的问题,发现了这两个有趣的线程:

  • https://developer.apple.com/forums/thread/112095 Apple 支持人员声称这些警告(例如,Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service)不是你应该担心的
  • Xcode 8, iOS 10 - "Starting WebFilter logging for process"这是帮助我消除这些警告的唯一解决方案。基本上,您应该设置 OS_ACTIVITY_MODE = disable
  • 关于ios - WKWebView 正在尝试在后台运行,尽管它已关闭并且应该被处置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65162287/

    36 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com