macOS 应用程序在 M1 上的 WKWebView() 上崩溃并出现 EXC_BREAKPOINT

发布于 2025-01-10 06:23:38 字数 1919 浏览 4 评论 0原文

我们的应用程序在 Intel 机器上调试时运行正常,但在配备 M1 的 MacBook Pro 上运行时崩溃。

当我们尝试初始化 WKWebView

在此处输入图像描述

使用 DispatchQueue.main.async 在主线程上调用 setUpWebViewUI

什么我们尝试过

  • 我们尝试了所有常见的解决方案(干净的派生数据、Rosetta、 ETC..)。
  • 一些开发人员建议更改架构设置,但是 也不适合我们。
  • 我们尝试了其他初始化方法 WKWebView 但这也会导致同样的崩溃。

工作原理

我们发现的一件事是,如果未附加 Xcode,该应用程序也可以正常工作。如果我们使用产品文件夹中的 .app 文件运行应用程序,那么它可以正常工作而不会发生任何崩溃。

版本详细信息:

macOS 版本:11.6.4。
Xcode 版本:13.2.1

调用堆栈

#0  0x00000001972bbf50 in void JSC::LinkBuffer::copyCompactAndLinkCode<unsigned int>(JSC::MacroAssembler&, JSC::JITCompilationEffort) ()
#1  0x00000001972bb35c in JSC::LinkBuffer::linkCode(JSC::MacroAssembler&, JSC::JITCompilationEffort) ()
#2  0x0000000197908104 in JSC::LLInt::createJSGateThunk(void*, WTF::PtrTag, char const*) ()
#3  0x0000000196edec44 in JSC::LLInt::initialize() ()
#4  0x0000000197a9410c in void std::__1::__call_once_proxy<std::__1::tuple<JSC::initialize()::$_0&&> >(void*) ()
#5  0x000000018195d2b0 in std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) ()
#6  0x0000000197a90ac8 in JSC::initialize() ()
#7  0x000000019ca24fc0 in WebKit::runInitializationCode(void*) ()
#8  0x000000018195d2b0 in std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) ()
#9  0x000000019c80cafc in WebKit::InitializeWebKit2() ()
#10 0x000000019caeba84 in -[WKWebViewConfiguration init] ()
#11 0x000000019cae12b0 in -[WKWebView initWithFrame:] ()
#12 0x0000000104263428 in @nonobjc WKWebView.init() ()
#13 0x0000000104262350 in WKWebView.__allocating_init() ()
#14 0x000000010440c20c in AccountDetailViewController.setUpWebViewUI() at 

Our app works properly when debugging on Intel machines but it crashes when we run on MacBook Pro with M1.

App crash when we try to init WKWebView

enter image description here

setUpWebViewUI is called on main thread using DispatchQueue.main.async

What we tried

  • We have tried all common solutions (clean, derived data, Rosetta,
    etc..).
  • Some developers suggest changing schema settings but that
    also doesn't work for us.
  • We tried other init methods of
    WKWebView but that also result in the same crash.

What works

One thing we found is that the app works properly if Xcode is not attached. If we run the app using the .app file in the Product folder then it works without any crash.

Version details:

macOS Version: 11.6.4.
Xcode Version: 13.2.1

Call Stack

#0  0x00000001972bbf50 in void JSC::LinkBuffer::copyCompactAndLinkCode<unsigned int>(JSC::MacroAssembler&, JSC::JITCompilationEffort) ()
#1  0x00000001972bb35c in JSC::LinkBuffer::linkCode(JSC::MacroAssembler&, JSC::JITCompilationEffort) ()
#2  0x0000000197908104 in JSC::LLInt::createJSGateThunk(void*, WTF::PtrTag, char const*) ()
#3  0x0000000196edec44 in JSC::LLInt::initialize() ()
#4  0x0000000197a9410c in void std::__1::__call_once_proxy<std::__1::tuple<JSC::initialize()::$_0&&> >(void*) ()
#5  0x000000018195d2b0 in std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) ()
#6  0x0000000197a90ac8 in JSC::initialize() ()
#7  0x000000019ca24fc0 in WebKit::runInitializationCode(void*) ()
#8  0x000000018195d2b0 in std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) ()
#9  0x000000019c80cafc in WebKit::InitializeWebKit2() ()
#10 0x000000019caeba84 in -[WKWebViewConfiguration init] ()
#11 0x000000019cae12b0 in -[WKWebView initWithFrame:] ()
#12 0x0000000104263428 in @nonobjc WKWebView.init() ()
#13 0x0000000104262350 in WKWebView.__allocating_init() ()
#14 0x000000010440c20c in AccountDetailViewController.setUpWebViewUI() at 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

西瓜 2025-01-17 06:23:39

MacOS 13 和 XCode 14.1 仍然存在同样的问题。

只需将 WKWebKit 的实例附加到 IB 中的 NSWindow 中,就会在加载窗口控制器时应用程序立即崩溃。

Still same problem here, MacOS 13 and XCode 14.1.

Just attaching an instance of WKWebKit into an NSWindow in IB makes the app crash right away when the window controller is loaded.

蛮可爱 2025-01-17 06:23:38

我有同样的问题。对我有用的唯一解决方法是在 Rosetta 下运行 XCode(在 /Applications 打开 XCode 设置并设置 Rosetta 复选框),然后在目标 My mac (Rosetta) 上构建并运行应用程序

在这种情况下,所有代码将针对 x86_64 进行编译,这不会出现 WKWebView 的问题。

I have the same problem. The only workaround that works for me is to run XCode under Rosetta (in /Applications open settings of XCode and set Rosetta checkbox) and then build and run app on target My mac (Rosetta)

In this case all code will compile for x86_64 which doesn't have the problem with WKWebView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文