菜鸟教程小白 发表于 2022-12-11 18:27:56

错误重新加载 JS 时,iOS React Native 应用程序在 JSCExecutor.cpp 中崩溃


                                            <p><p>我刚刚将 React Native 集成到现有的 iOS 应用程序中。当我转到初始化 React Native 的屏幕时,如果打包程序没有运行,我会看到通常的红色屏幕,上面写着“不存在捆绑 URL”。如果我点击底部的“重新加载 JS”按钮(或按 Cmd+R)两次,我会收到以下崩溃:</p>

<pre><code>JSCExecutor.cpp:158] Check failed: *m_isDestroyed JSCExecutor::destroy() must be called before its destructor!
</code></pre>

<p>我正在使用 <a href="https://github.com/facebook/react-native/blob/master/local-cli/templates/HelloWorld/ios/HelloWorld/AppDelegate.m" rel="noreferrer noopener nofollow">this</a> 之类的代码初始化 RN ,创建一个 <code>RCTRootView</code>。</p>

<p>如果打包程序正在运行,一切正常。 Cmd+R 可以很好地重新加载 JS。如果我在 JS 中出现语法错误并重新加载以获得红色错误屏幕,然后我再次重新加载它,我会遇到同样的崩溃。</p>

<p>不确定它是否相关,但我在崩溃消息之前的日志中也看到了这条消息:</p>

<pre><code>WARNING: Logging before InitGoogleLogging() is written to STDERR
</code></pre>

<p>崩溃的回溯如下:</p>

<pre><code>#00x000000011b7e0d42 in __pthread_kill ()
#10x000000011b818457 in pthread_kill ()
#20x000000011b57288f in abort ()
#30x0000000116ce4079 in google::logging_fail() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:1464
#40x0000000116ce406a in google::LogMessage::Fail() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:1478
#50x0000000116ce1b6a in google::LogMessage::SendToLog() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:1432
#60x0000000116ce2abf in google::LogMessage::Flush() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:1301
#70x0000000116ceba78 in google::LogMessageFatal::~LogMessageFatal() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:2013
#80x0000000116ce45b5 in google::LogMessageFatal::~LogMessageFatal() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:2012
#90x0000000116d2ee96 in facebook::react::JSCExecutor::~JSCExecutor() at .../node_modules/react-native/ReactCommon/cxxreact/JSCExecutor.cpp:158
#10 0x0000000116d2f245 in facebook::react::JSCExecutor::~JSCExecutor() at .../node_modules/react-native/ReactCommon/cxxreact/JSCExecutor.cpp:157
#11 0x0000000116d2f269 in facebook::react::JSCExecutor::~JSCExecutor() at .../node_modules/react-native/ReactCommon/cxxreact/JSCExecutor.cpp:157
#12 0x0000000116d4526d in std::__1::default_delete&lt;facebook::react::JSExecutor&gt;::operator()(facebook::react::JSExecutor*) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2537
#13 0x0000000116d45245 in std::__1::unique_ptr&lt;facebook::react::JSExecutor, std::__1::default_delete&lt;facebook::react::JSExecutor&gt; &gt;::reset(facebook::react::JSExecutor*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2736
#14 0x0000000116d451be in std::__1::unique_ptr&lt;facebook::react::JSExecutor, std::__1::default_delete&lt;facebook::react::JSExecutor&gt; &gt;::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2704
#15 0x0000000116d451a5 in std::__1::unique_ptr&lt;facebook::react::JSExecutor, std::__1::default_delete&lt;facebook::react::JSExecutor&gt; &gt;::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2704
#16 0x0000000116d45197 in facebook::react::NativeToJsBridge::~NativeToJsBridge() at .../node_modules/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp:91
#17 0x0000000116d453c5 in facebook::react::NativeToJsBridge::~NativeToJsBridge() at .../node_modules/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp:88
#18 0x0000000116d453e9 in facebook::react::NativeToJsBridge::~NativeToJsBridge() at .../node_modules/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp:88
#19 0x0000000116d3da8e in std::__1::default_delete&lt;facebook::react::NativeToJsBridge&gt;::operator()(facebook::react::NativeToJsBridge*) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2537
#20 0x0000000116d3da69 in std::__1::unique_ptr&lt;facebook::react::NativeToJsBridge, std::__1::default_delete&lt;facebook::react::NativeToJsBridge&gt; &gt;::reset(facebook::react::NativeToJsBridge*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2736
#21 0x0000000116d3da06 in std::__1::unique_ptr&lt;facebook::react::NativeToJsBridge, std::__1::default_delete&lt;facebook::react::NativeToJsBridge&gt; &gt;::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2704
#22 0x0000000116d3d9f6 in std::__1::unique_ptr&lt;facebook::react::NativeToJsBridge, std::__1::default_delete&lt;facebook::react::NativeToJsBridge&gt; &gt;::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2704
#23 0x0000000116d3d9ee in facebook::react::Instance::~Instance() at .../node_modules/react-native/ReactCommon/cxxreact/Instance.cpp:31
#24 0x0000000116d3dad5 in facebook::react::Instance::~Instance() at .../node_modules/react-native/ReactCommon/cxxreact/Instance.cpp:27
#25 0x0000000116b92f21 in std::__1::default_delete&lt;facebook::react::Instance&gt;::operator()(facebook::react::Instance*) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2537
#26 0x0000000116b92efc in std::__1::__shared_ptr_pointer&lt;facebook::react::Instance*, std::__1::default_delete&lt;facebook::react::Instance&gt;, std::__1::allocator&lt;facebook::react::Instance&gt; &gt;::__on_zero_shared() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3780
#27 0x000000011777b43e in std::__1::__shared_weak_count::__release_shared() ()
#28 0x0000000116b9a86c in std::__1::shared_ptr&lt;facebook::react::Instance&gt;::~shared_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4605
#29 0x0000000116b8b335 in std::__1::shared_ptr&lt;facebook::react::Instance&gt;::~shared_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4603
#30 0x0000000116b8b27a in ::-() at .../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:131
#31 0x000000011729d9bc in object_cxxDestructFromClass(objc_object*, objc_class*) ()
#32 0x00000001172a9d34 in objc_destructInstance ()
#33 0x00000001172a9d66 in object_dispose ()
#34 0x0000000116c48b8e in - at .../node_modules/react-native/React/Base/RCTBridge.m:207
#35 0x00000001172b3b8e in objc_object::sidetable_release(bool) ()
#36 0x00000001172b42fa in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#37 0x00000001185e5ef6 in _CFAutoreleasePoolPop ()
#38 0x0000000118621aec in __CFRunLoopRun ()
#39 0x0000000118621016 in CFRunLoopRunSpecific ()
#40 0x000000011d46ea24 in GSEventRunModal ()
#41 0x000000011303b0d4 in UIApplicationMain ()
#42 0x0000000110d78800 in main at .../main.m:24
#43 0x000000011b4ca65d in start ()
</code></pre>

<p>Xcode:8.3.2<br/>
模拟器:iPhone 7 - iOS 10.3<br/>
react 原生:0.47.1</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我也面临这个问题,似乎是一个悬而未决的问题:</p>

<p> <a href="https://github.com/facebook/react-native/issues/14288" rel="noreferrer noopener nofollow">https://github.com/facebook/react-native/issues/14288</a> </p>

<p>昨天我在不同的网络上进行测试,它确实有效。</p></p>
                                   
                                                <p style="font-size: 20px;">关于错误重新加载 JS 时,iOS React Native 应用程序在 JSCExecutor.cpp 中崩溃,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/45557269/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/45557269/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: 错误重新加载 JS 时,iOS React Native 应用程序在 JSCExecutor.cpp 中崩溃