我刚刚将 React Native 集成到现有的 iOS 应用程序中。当我转到初始化 React Native 的屏幕时,如果打包程序没有运行,我会看到通常的红色屏幕,上面写着“不存在捆绑 URL”。如果我点击底部的“重新加载 JS”按钮(或按 Cmd+R)两次,我会收到以下崩溃:
JSCExecutor.cpp:158] Check failed: *m_isDestroyed JSCExecutor::destroy() must be called before its destructor!
我正在使用 this 之类的代码初始化 RN ,创建一个 RCTRootView 。
如果打包程序正在运行,一切正常。 Cmd+R 可以很好地重新加载 JS。如果我在 JS 中出现语法错误并重新加载以获得红色错误屏幕,然后我再次重新加载它,我会遇到同样的崩溃。
不确定它是否相关,但我在崩溃消息之前的日志中也看到了这条消息:
WARNING: Logging before InitGoogleLogging() is written to STDERR
崩溃的回溯如下:
#0 0x000000011b7e0d42 in __pthread_kill ()
#1 0x000000011b818457 in pthread_kill ()
#2 0x000000011b57288f in abort ()
#3 0x0000000116ce4079 in google::logging_fail() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:1464
#4 0x0000000116ce406a in google:ogMessage::Fail() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:1478
#5 0x0000000116ce1b6a in google:ogMessage::SendToLog() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:1432
#6 0x0000000116ce2abf in google:ogMessage::Flush() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:1301
#7 0x0000000116ceba78 in google:ogMessageFatal::~LogMessageFatal() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:2013
#8 0x0000000116ce45b5 in google:ogMessageFatal::~LogMessageFatal() at .../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc:2012
#9 0x0000000116d2ee96 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<facebook::react::JSExecutor>:perator()(facebook::react::JSExecutor*) const [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2537
#13 0x0000000116d45245 in std::__1::unique_ptr<facebook::react::JSExecutor, std::__1::default_delete<facebook::react::JSExecutor> >::reset(facebook::react::JSExecutor*) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2736
#14 0x0000000116d451be in std::__1::unique_ptr<facebook::react::JSExecutor, std::__1::default_delete<facebook::react::JSExecutor> >::~unique_ptr() [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2704
#15 0x0000000116d451a5 in std::__1::unique_ptr<facebook::react::JSExecutor, std::__1::default_delete<facebook::react::JSExecutor> >::~unique_ptr() [inlined] 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<facebook::react::NativeToJsBridge>:perator()(facebook::react::NativeToJsBridge*) const [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2537
#20 0x0000000116d3da69 in std::__1::unique_ptr<facebook::react::NativeToJsBridge, std::__1::default_delete<facebook::react::NativeToJsBridge> >::reset(facebook::react::NativeToJsBridge*) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2736
#21 0x0000000116d3da06 in std::__1::unique_ptr<facebook::react::NativeToJsBridge, std::__1::default_delete<facebook::react::NativeToJsBridge> >::~unique_ptr() [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2704
#22 0x0000000116d3d9f6 in std::__1::unique_ptr<facebook::react::NativeToJsBridge, std::__1::default_delete<facebook::react::NativeToJsBridge> >::~unique_ptr() [inlined] 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<facebook::react::Instance>:perator()(facebook::react::Instance*) const [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2537
#26 0x0000000116b92efc in std::__1::__shared_ptr_pointer<facebook::react::Instance*, std::__1::default_delete<facebook::react::Instance>, std::__1::allocator<facebook::react::Instance> >::__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<facebook::react::Instance>::~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<facebook::react::Instance>::~shared_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4603
#30 0x0000000116b8b27a in ::-[RCTCxxBridge .cxx_destruct]() 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 -[RCTBridge dealloc] 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 ()
Xcode:8.3.2
模拟器:iPhone 7 - iOS 10.3
react 原生:0.47.1
Best Answer-推荐答案 strong>
我也面临这个问题,似乎是一个悬而未决的问题:
https://github.com/facebook/react-native/issues/14288
昨天我在不同的网络上进行测试,它确实有效。
关于错误重新加载 JS 时,iOS React Native 应用程序在 JSCExecutor.cpp 中崩溃,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/45557269/
|