WKContentRuleListStore.default() 在 iOS 14 中崩溃 [英] WKContentRuleListStore.default() crash in iOS 14

查看:21
本文介绍了WKContentRuleListStore.default() 在 iOS 14 中崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用 WKContentRuleListStore 来阻止内容.但是,当我尝试使用 Swift 5.3/iOS 14 进行编译时,在尝试实例化 WKContentRuleListStore.default() 时出现运行时崩溃.

My app makes use of content blocking using WKContentRuleListStore. However, when I try to compile using Swift 5.3/iOS 14, I get a runtime crash when trying to instantiate WKContentRuleListStore.default().

我在 iOS 13 中没有注意到这个崩溃,甚至没有注意到使用 iOS 13 SDK 构建并在 iOS 14 上运行.

I did not notice this crash in iOS 13, or even building with the iOS 13 SDK and running on iOS 14.

显示的错误仅是调用站点上的 EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0).

The error presented is only EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0) at callsite.

堆栈跟踪:

#0  0x00007fff28541233 in WTFCrashWithInfo(int, char const*, char const*, int) ()
#1  0x00007fff286c6868 in WebKit::runInitializationCode(void*) ()
#2  0x00007fff202cbf2a in std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) ()
#3  0x00007fff286c3623 in WebKit::InitializeWebKit2() ()
#4  0x00007fff288e23ea in API::ContentRuleListStore::ContentRuleListStore(WTF::String const&, bool) ()
#5  0x00007fff288e2348 in API::ContentRuleListStore::ContentRuleListStore(bool) ()
#6  0x00007fff288e23ac in API::ContentRuleListStore::nonLegacyDefaultStore() ()
#7  0x00007fff2876013d in +[WKContentRuleListStore defaultStore] ()
#8  0x000000010c797fa9 in static WebViewRules.compile() at /MyApp/Features/WebView/WebViewRules.swift:36

推荐答案

很快就找到了解决方案,但希望为遇到相同问题的任何人记录下来.

Found the solution pretty quickly but wanted to document it for any folks that run into the same issue.

WKContentRuleListStore.default() 必须在主线程上调用.看来这是 iOS 14 和相应 SDK 中引入的新(未记录)要求.

WKContentRuleListStore.default() must be called on the main thread. It appears this is a new (undocumented) requirement introduced in iOS 14 and the corresponding SDK.

DispatchQueue.main.async {
  let store = WKContentRuleListStore.default()
  // use the store...
}

这篇关于WKContentRuleListStore.default() 在 iOS 14 中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆