WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.35k stars 4.13k forks source link

Drag and drop blocks: Crashes on iOS related to JSI #41686

Open fluiddot opened 2 years ago

fluiddot commented 2 years ago

Description

On WP-iOS 19.9.0.0, we identified a crash caused by react-native-reanimated and JSI when opening and closing the editor several times. This issue was hard to reproduce, as it looked like that only happened on specific devices and/or OS versions, but we managed to reproduce it almost consistently and released a hotfix (WP-iOS 19.9.1.0) to address it (reference).

However, after releasing the hotfix, we noticed that we're still getting crashes related to JSI, although the number is quite lower than the original issue. There's no clue yet about what's causing the crash, so we'd need to investigate it further.

Crash reports

UPDATE: We have identified another issue with Reanimated on Android that might be related to this one:

Step-by-step reproduction instructions

We haven't found yet a way to reproduce it, hence no reproduction instructions can be provided.

Expected behaviour

We shouldn't get crash reports related to the react-native-reanimated library or JSI.

Actual behaviour

We are receiving crash reports related to react-native-reanimated and JSI.

Screenshots or screen recording (optional)

N/A

WordPress information

Device information

hypest commented 2 years ago

πŸ‘‹ @fluiddot! Is this in progress perhaps? Asking so we move the status accordingly. Thanks!

fluiddot commented 2 years ago

πŸ‘‹ @fluiddot! Is this in progress perhaps? Asking so we move the status accordingly. Thanks!

@hypest Nope, this task hasn't been tackled yet. However, it would be great if we could take a look sooner than later, as it's causing some of the top 5 crashes in the WordPress-iOS app. Actually, I'm thinking to focus on this over other tasks I'm currently working on related to integration tests, wdyt?

hypest commented 2 years ago

Thanks Carlos! Yeah, makes sense to focus on this since this is a crash situation. πŸ‘

fluiddot commented 2 years ago

I performed a deeper analysis of the crashes in an effort to better identify the culprit:

EXC_BAD_ACCESS - Attempted to dereference garbage pointer

Stacktraces

The following one is the most frequent stack trace I found so dar, which occurs during destruction:

Click here to display the stack trace ``` 0 WordPress 0x201dc9e58 [inlined] std::__1::__function::__value_func::~__value_func (functional:1846) 1 WordPress 0x201dc9e58 [inlined] std::__1::__function::__value_func::~__value_func (functional:1842) 2 WordPress 0x201dc9e58 [inlined] std::__1::function::~function (functional:2547) 3 WordPress 0x201dc9e58 [inlined] std::__1::function::~function (functional:2547) 4 WordPress 0x201dc9e58 [inlined] std::__1::allocator::destroy (memory:921) 5 WordPress 0x201dc9e58 [inlined] std::__1::allocator_traits::destroy (allocator_traits.h:307) 6 WordPress 0x201dc9e58 std::__1::__deque_base::clear (deque:1249) 7 WordPress 0x201dc9da8 std::__1::__deque_base::~__deque_base (deque:1186) 8 WordPress 0x201dc9d08 [inlined] std::__1::deque::~deque (deque:1268) 9 WordPress 0x201dc9d08 [inlined] std::__1::deque::~deque (deque:1268) 10 WordPress 0x201dc9d08 [inlined] std::__1::queue::~queue (queue:206) 11 WordPress 0x201dc9d08 [inlined] std::__1::queue::~queue (queue:206) 12 WordPress 0x201dc9d08 [inlined] reanimated::Queue::~Queue (Scheduler.h:20) 13 WordPress 0x201dc9d08 [inlined] reanimated::Queue::~Queue (Scheduler.h:20) 14 WordPress 0x201dc9d08 reanimated::Scheduler::~Scheduler (Scheduler.cpp:31) 15 WordPress 0x201b6ffdc [inlined] std::__1::__shared_count::__release_shared (memory:2506) 16 WordPress 0x201b6ffdc [inlined] std::__1::__shared_weak_count::__release_shared (memory:2548) 17 WordPress 0x201b6ffdc std::__1::shared_ptr::~shared_ptr (memory:3238) 18 WordPress 0x201db6dd0 [inlined] std::__1::shared_ptr::~shared_ptr (memory:3236) 19 WordPress 0x201db6dd0 reanimated::REAIOSErrorHandler::~REAIOSErrorHandler (REAIOSErrorHandler.h:20) 20 WordPress 0x201b6ffdc [inlined] std::__1::__shared_count::__release_shared (memory:2506) 21 WordPress 0x201b6ffdc [inlined] std::__1::__shared_weak_count::__release_shared (memory:2548) 22 WordPress 0x201b6ffdc std::__1::shared_ptr::~shared_ptr (memory:3238) 23 WordPress 0x201daa350 [inlined] std::__1::shared_ptr::~shared_ptr (memory:3236) 24 WordPress 0x201daa350 reanimated::RuntimeManager::~RuntimeManager (RuntimeManager.h:36) 25 WordPress 0x201dac32c reanimated::NativeReanimatedModule::~NativeReanimatedModule (NativeReanimatedModule.h:25) 26 WordPress 0x201b6ffdc [inlined] std::__1::__shared_count::__release_shared (memory:2506) 27 WordPress 0x201b6ffdc [inlined] std::__1::__shared_weak_count::__release_shared (memory:2548) 28 WordPress 0x201b6ffdc std::__1::shared_ptr::~shared_ptr (memory:3238) 29 WordPress 0x202190150 [inlined] std::__1::shared_ptr::~shared_ptr (memory:3236) 30 WordPress 0x202190150 [inlined] facebook::jsc::detail::HostObjectProxyBase::~HostObjectProxyBase (JSCRuntime.cpp:695) 31 WordPress 0x202190150 [inlined] facebook::jsc::JSCRuntime::createObject::HostObjectProxy::~HostObjectProxy (JSCRuntime.cpp:712) 32 WordPress 0x202190150 [inlined] facebook::jsc::JSCRuntime::createObject::HostObjectProxy::~HostObjectProxy (JSCRuntime.cpp:712) 33 WordPress 0x202190150 facebook::jsc::JSCRuntime::createObject::HostObjectProxy::finalize (JSCRuntime.cpp:817) 34 JavaScriptCore 0x35dcec8ac JSC::JSCallbackObject::destroy 35 JavaScriptCore 0x35e332654 JSC::PreciseAllocation::sweep 36 JavaScriptCore 0x35e32a6e8 JSC::MarkedSpace::lastChanceToFinalize 37 JavaScriptCore 0x35e2f5890 JSC::Heap::lastChanceToFinalize 38 JavaScriptCore 0x35e972fc0 JSC::VM::~VM 39 JavaScriptCore 0x35e7fb4d0 JSC::JSLockHolder::~JSLockHolder 40 JavaScriptCore 0x35dcfed4c JSGlobalContextRelease 41 WordPress 0x20218d758 facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:391) 42 WordPress 0x20218d858 [inlined] facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:383) 43 WordPress 0x20218d858 facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:383) 44 WordPress 0x201b6ffdc [inlined] std::__1::__shared_count::__release_shared (memory:2506) 45 WordPress 0x201b6ffdc [inlined] std::__1::__shared_weak_count::__release_shared (memory:2548) 46 WordPress 0x201b6ffdc std::__1::shared_ptr::~shared_ptr (memory:3238) 47 WordPress 0x20219ab38 [inlined] std::__1::shared_ptr::~shared_ptr (memory:3236) 48 WordPress 0x20219ab38 facebook::react::JSIExecutor::~JSIExecutor (JSIExecutor.h:71) 49 WordPress 0x20219aa24 [inlined] facebook::react::JSIExecutor::~JSIExecutor (JSIExecutor.h:71) 50 WordPress 0x20219aa24 facebook::react::JSIExecutor::~JSIExecutor (JSIExecutor.h:71) 51 WordPress 0x201e29494 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 52 WordPress 0x201e29494 [inlined] std::__1::function::operator() (functional:2560) 53 WordPress 0x201e29494 facebook::react::tryAndReturnError (RCTCxxUtils.mm:74) 54 WordPress 0x201e35404 facebook::react::RCTMessageThread::tryFunc (RCTMessageThread.mm:69) 55 WordPress 0x201e35748 facebook::react::RCTMessageThread::runOnQueueSync (RCTMessageThread.mm:92) 56 WordPress 0x2021752d0 facebook::react::NativeToJsBridge::destroy (NativeToJsBridge.cpp:285) 57 WordPress 0x20216b3ec facebook::react::Instance::~Instance (Instance.cpp:39) 58 WordPress 0x201e2698c [inlined] std::__1::default_delete::operator() (memory:1428) 59 WordPress 0x201e2698c std::__1::__shared_ptr_pointer::__on_zero_shared (memory:2596) 60 WordPress 0x201e2350c [inlined] std::__1::__shared_count::__release_shared (memory:2506) 61 WordPress 0x201e2350c [inlined] std::__1::__shared_weak_count::__release_shared (memory:2548) 62 WordPress 0x201e2350c [inlined] std::__1::shared_ptr::~shared_ptr (memory:3238) 63 WordPress 0x201e2350c [inlined] std::__1::shared_ptr::~shared_ptr (memory:3236) 64 WordPress 0x201e2350c [inlined] std::__1::shared_ptr::reset (memory:3333) 65 WordPress 0x201e2350c __26-[RCTCxxBridge invalidate]_block_invoke (RCTCxxBridge.mm:1333) 66 WordPress 0x201e29494 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 67 WordPress 0x201e29494 [inlined] std::__1::function::operator() (functional:2560) 68 WordPress 0x201e29494 facebook::react::tryAndReturnError (RCTCxxUtils.mm:74) 69 WordPress 0x201e1e65c -[RCTCxxBridge _tryAndHandleError:] (RCTCxxBridge.mm:376) 70 Foundation 0x34a3e9f1c __NSThreadPerformPerform 71 CoreFoundation 0x34747f410 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 72 CoreFoundation 0x34749019c __CFRunLoopDoSource0 73 CoreFoundation 0x3473c9690 __CFRunLoopDoSources0 74 CoreFoundation 0x3473cf058 __CFRunLoopRun 75 CoreFoundation 0x3473e2bc4 CFRunLoopRunSpecific 76 WordPress 0x201e1e590 +[RCTCxxBridge runRunLoop] (RCTCxxBridge.mm:367) 77 Foundation 0x34a415438 __NSThread__start__ 78 libsystem_pthread.dylib 0x42977b9a8 _pthread_start ```

The next one is a bit different and in fact, it doesn't look like that is happening upon editor closing. However, per the last user events, it occurred some seconds after closing the editor.

Click here to display the stack trace ``` 0 WordPress 0x2019f48fc std::__1::__hash_table::find (__hash_table:2394) 1 WordPress 0x201a1e8d4 reanimated::ShareableValue::adapt (ShareableValue.cpp:194) 2 WordPress 0x2019ecfbc reanimated::FrozenObject::FrozenObject (FrozenObject.cpp:19) 3 WordPress 0x201a20eb0 [inlined] std::__1::make_unique (memory:2099) 4 WordPress 0x201a20eb0 reanimated::RemoteObject::RemoteObject (RemoteObject.h:28) 5 WordPress 0x201a1d9d0 [inlined] reanimated::RemoteObject::RemoteObject (RemoteObject.h:28) 6 WordPress 0x201a1d9d0 [inlined] std::__1::__shared_ptr_emplace::__shared_ptr_emplace (memory:2627) 7 WordPress 0x201a1d9d0 [inlined] std::__1::__shared_ptr_emplace::__shared_ptr_emplace (memory:2621) 8 WordPress 0x201a1d9d0 [inlined] std::__1::allocate_shared (memory:3385) 9 WordPress 0x201a1d9d0 [inlined] std::__1::make_shared (memory:3394) 10 WordPress 0x201a1d9d0 reanimated::ShareableValue::adapt (ShareableValue.cpp:158) 11 WordPress 0x201a1e8d4 reanimated::ShareableValue::adapt (ShareableValue.cpp:194) 12 WordPress 0x2019fbcb4 reanimated::NativeReanimatedModule::makeRemote (NativeReanimatedModule.cpp:119) 13 WordPress 0x201ddf394 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 14 WordPress 0x201ddf394 std::__1::function::operator() (functional:2560) 15 WordPress 0x201ddf0dc facebook::jsc::JSCRuntime::createFunctionFromHostFunction::HostFunctionMetadata::call (JSCRuntime.cpp:1158) 16 JavaScriptCore 0x33304dc74 JSC::JSCallbackObject::callImpl 17 JavaScriptCore 0x3336b3b88 JSC::LLInt::setUpCall 18 JavaScriptCore 0x332fc32b8 llint_entry 19 JavaScriptCore 0x332fc3224 [inlined] llint_entry 20 JavaScriptCore 0x332fc3224 [inlined] llint_entry 21 JavaScriptCore 0x332fc3224 llint_entry 22 JavaScriptCore 0x332fc32cc llint_entry 23 JavaScriptCore 0x332fc3224 [inlined] llint_entry 24 JavaScriptCore 0x332fc3224 [inlined] llint_entry 25 JavaScriptCore 0x332fc3224 [inlined] llint_entry 26 JavaScriptCore 0x332fc3224 [inlined] llint_entry 27 JavaScriptCore 0x332fc3224 llint_entry 28 JavaScriptCore 0x332fa1104 vmEntryToJavaScript 29 JavaScriptCore 0x3335ce92c JSC::Interpreter::executeCall 30 JavaScriptCore 0x3338793ec JSC::boundThisNoArgsFunctionCall 31 JavaScriptCore 0x332fc5bac llint_entry 32 JavaScriptCore 0x332fc32cc llint_entry 33 JavaScriptCore 0x332fc3224 [inlined] llint_entry 34 JavaScriptCore 0x332fc3224 llint_entry 35 JavaScriptCore 0x332fa1104 vmEntryToJavaScript 36 JavaScriptCore 0x3335ce92c JSC::Interpreter::executeCall 37 JavaScriptCore 0x3338793ec JSC::boundThisNoArgsFunctionCall 38 JavaScriptCore 0x332fc5bac llint_entry 39 JavaScriptCore 0x332fc32cc [inlined] llint_entry 40 JavaScriptCore 0x332fc32cc [inlined] llint_entry 41 JavaScriptCore 0x332fc32cc [inlined] llint_entry 42 JavaScriptCore 0x332fc32cc [inlined] llint_entry 43 JavaScriptCore 0x332fc32cc [inlined] llint_entry 44 JavaScriptCore 0x332fc32cc llint_entry 45 JavaScriptCore 0x332fc3224 [inlined] llint_entry 46 JavaScriptCore 0x332fc3224 [inlined] llint_entry 47 JavaScriptCore 0x332fc3224 [inlined] llint_entry 48 JavaScriptCore 0x332fc3224 llint_entry 49 JavaScriptCore 0x332fc32cc [inlined] llint_entry 50 JavaScriptCore 0x332fc32cc [inlined] llint_entry 51 JavaScriptCore 0x332fc32cc [inlined] llint_entry 52 JavaScriptCore 0x332fc32cc [inlined] llint_entry 53 JavaScriptCore 0x332fc32cc [inlined] llint_entry 54 JavaScriptCore 0x332fc32cc llint_entry 55 JavaScriptCore 0x332fc3224 llint_entry 56 JavaScriptCore 0x332fc32cc llint_entry 57 JavaScriptCore 0x332fc3224 [inlined] llint_entry 58 JavaScriptCore 0x332fc3224 [inlined] llint_entry 59 JavaScriptCore 0x332fc3224 [inlined] llint_entry 60 JavaScriptCore 0x332fc3224 llint_entry 61 JavaScriptCore 0x332fc32cc [inlined] llint_entry 62 JavaScriptCore 0x332fc32cc llint_entry 63 JavaScriptCore 0x332fc3224 [inlined] llint_entry 64 JavaScriptCore 0x332fc3224 [inlined] llint_entry 65 JavaScriptCore 0x332fc3224 [inlined] llint_entry 66 JavaScriptCore 0x332fc3224 llint_entry 67 JavaScriptCore 0x332fc32cc llint_entry 68 JavaScriptCore 0x332fc4820 llint_entry 69 JavaScriptCore 0x332fc32cc [inlined] llint_entry 70 JavaScriptCore 0x332fc32cc llint_entry 71 JavaScriptCore 0x332fc4820 [inlined] llint_entry 72 JavaScriptCore 0x332fc4820 llint_entry 73 JavaScriptCore 0x332fc3224 llint_entry 74 JavaScriptCore 0x332fc32cc llint_entry 75 JavaScriptCore 0x332fc3224 llint_entry 76 JavaScriptCore 0x332fa1104 vmEntryToJavaScript 77 JavaScriptCore 0x3335ce92c JSC::Interpreter::executeCall 78 JavaScriptCore 0x3338793ec JSC::boundThisNoArgsFunctionCall 79 JavaScriptCore 0x332fa12b4 vmEntryToNative 80 JavaScriptCore 0x3335ce95c JSC::Interpreter::executeCall 81 JavaScriptCore 0x3337d4768 JSC::profiledCall 82 JavaScriptCore 0x33305acd8 JSObjectCallAsFunction 83 WordPress 0x201ddd584 facebook::jsc::JSCRuntime::call (JSCRuntime.cpp:1260) 84 WordPress 0x201de91b0 [inlined] facebook::jsi::Function::call (jsi-inl.h:228) 85 WordPress 0x201de91b0 [inlined] facebook::jsi::Function::call (jsi-inl.h:233) 86 WordPress 0x201de91b0 facebook::jsi::Function::call (jsi-inl.h:241) 87 WordPress 0x201de9014 [inlined] facebook::react::JSIExecutor::callFunction::lambda::operator() (JSIExecutor.cpp:256) 88 WordPress 0x201de9014 [inlined] std::__1::__invoke (type_traits:3694) 89 WordPress 0x201de9014 [inlined] std::__1::__invoke_void_return_wrapper::__call (__functional_base:348) 90 WordPress 0x201de9014 [inlined] std::__1::__function::__alloc_func::operator() (functional:1558) 91 WordPress 0x201de9014 std::__1::__function::__func::operator() (functional:1732) 92 WordPress 0x201a5bd4c [inlined] std::__1::__invoke (type_traits:3694) 93 WordPress 0x201a5bd4c std::__1::__invoke_void_return_wrapper::__call (__functional_base:348) 94 WordPress 0x201de6430 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 95 WordPress 0x201de6430 [inlined] std::__1::function::operator() (functional:2560) 96 WordPress 0x201de6430 facebook::react::JSIExecutor::callFunction (JSIExecutor.cpp:254) 97 WordPress 0x201dc43b8 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 98 WordPress 0x201dc43b8 [inlined] std::__1::function::operator() (functional:2560) 99 WordPress 0x201dc43b8 [inlined] facebook::react::NativeToJsBridge::runOnExecutorQueue::lambda::operator() (NativeToJsBridge.cpp:310) 100 WordPress 0x201dc43b8 [inlined] std::__1::__invoke (type_traits:3694) 101 WordPress 0x201dc43b8 [inlined] std::__1::__invoke_void_return_wrapper::__call (__functional_base:348) 102 WordPress 0x201dc43b8 [inlined] std::__1::__function::__alloc_func::operator() (functional:1558) 103 WordPress 0x201dc43b8 std::__1::__function::__func::operator() (functional:1732) 104 WordPress 0x201a7ab60 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 105 WordPress 0x201a7ab60 [inlined] std::__1::function::operator() (functional:2560) 106 WordPress 0x201a7ab60 facebook::react::tryAndReturnError (RCTCxxUtils.mm:74) 107 WordPress 0x201a86ad0 facebook::react::RCTMessageThread::tryFunc (RCTMessageThread.mm:69) 108 WordPress 0x201a86884 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 109 WordPress 0x201a86884 [inlined] std::__1::function::operator() (functional:2560) 110 WordPress 0x201a86884 facebook::react::RCTMessageThread::runAsync (RCTMessageThread.mm:45) 111 CoreFoundation 0x32132264c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ 112 CoreFoundation 0x3213218e0 __CFRunLoopDoBlocks 113 CoreFoundation 0x32131c420 __CFRunLoopRun 114 CoreFoundation 0x32131b814 CFRunLoopRunSpecific 115 WordPress 0x201a6fc5c +[RCTCxxBridge runRunLoop] (RCTCxxBridge.mm:367) 116 Foundation 0x3239bcdac __NSThread__start__ 117 libsystem_pthread.dylib 0x3b05c1c70 _pthread_start ```

Additionally, If found other stack traces, less frequent, but also related to closing the editor:

Click here to display the stack trace ``` 0 WordPress 0x20361b4b4 [inlined] std::__1::__function::__value_func::__value_func (functional:1820) 1 WordPress 0x20361b4b4 [inlined] std::__1::__function::__value_func::__value_func (functional:1811) 2 WordPress 0x20361b4b4 std::__1::function::function (functional:2480) 3 WordPress 0x2038cf2dc [inlined] std::__1::function::function (functional:2480) 4 WordPress 0x2038cf2dc reanimated::Queue::pop (Scheduler.h:27) 5 WordPress 0x2038cf134 reanimated::Scheduler::triggerUI (Scheduler.cpp:16) 6 libdispatch.dylib 0x36507fe68 _dispatch_call_block_and_release 7 libdispatch.dylib 0x365081a2c _dispatch_client_callout 8 libdispatch.dylib 0x36508ff44 _dispatch_main_queue_drain 9 libdispatch.dylib 0x36508fb94 _dispatch_main_queue_callback_4CF 10 CoreFoundation 0x3656d57fc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 11 CoreFoundation 0x36568f700 __CFRunLoopRun 12 CoreFoundation 0x3656a2bc4 CFRunLoopRunSpecific 13 GraphicsServices 0x39d927370 GSEventRunModal 14 UIKitCore 0x36a48c644 -[UIApplication _run] 15 UIKitCore 0x36a20dd8c UIApplicationMain 16 WordPress 0x202aae7fc main (main.swift:7) 17 0x104ac1ce4 ```
Click here to display the stack trace ``` 0 WordPress 0x200fd0f98 [inlined] std::__1::shared_ptr::get (memory:2863) 1 WordPress 0x200fd0f98 [inlined] reanimated::MutableValue::set::lambda::operator() (MutableValue.cpp:68) 2 WordPress 0x200fd0f98 [inlined] std::__1::__invoke (type_traits:3694) 3 WordPress 0x200fd0f98 [inlined] std::__1::__invoke_void_return_wrapper::__call (__functional_base:348) 4 WordPress 0x200fd0f98 [inlined] std::__1::__function::__alloc_func::operator() (functional:1558) 5 WordPress 0x200fd0f98 std::__1::__function::__func::operator() (functional:1732) 6 WordPress 0x200ff7148 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 7 WordPress 0x200ff7148 [inlined] std::__1::function::operator() (functional:2560) 8 WordPress 0x200ff7148 reanimated::Scheduler::triggerUI (Scheduler.cpp:17) 9 libdispatch.dylib 0x339c7be68 _dispatch_call_block_and_release 10 libdispatch.dylib 0x339c7da2c _dispatch_client_callout 11 libdispatch.dylib 0x339c8bf44 _dispatch_main_queue_drain 12 libdispatch.dylib 0x339c8bb94 _dispatch_main_queue_callback_4CF 13 CoreFoundation 0x33a2d17fc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 14 CoreFoundation 0x33a28b700 __CFRunLoopRun 15 CoreFoundation 0x33a29ebc4 CFRunLoopRunSpecific 16 GraphicsServices 0x372523370 GSEventRunModal 17 UIKitCore 0x33f088644 -[UIApplication _run] 18 UIKitCore 0x33ee09d8c UIApplicationMain 19 WordPress 0x2001d67fc main (main.swift:7) 20 0x101ff5ce4 ```

JSCRuntime destroyed with a dangling API object

Stacktrace

Click here to display the stack trace ``` 0 libsystem_kernel.dylib 0x302108ebc __pthread_kill 1 libsystem_pthread.dylib 0x301f66c18 pthread_kill$VARIANT$armv81 2 libsystem_c.dylib 0x301d99820 abort 3 libsystem_c.dylib 0x301d98c40 __assert_rtn 4 WordPress 0x2013257b0 facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:393) 5 WordPress 0x201325858 [inlined] facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:383) 6 WordPress 0x201325858 facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:383) 7 WordPress 0x200d07fdc [inlined] std::__1::__shared_count::__release_shared (memory:2506) 8 WordPress 0x200d07fdc [inlined] std::__1::__shared_weak_count::__release_shared (memory:2548) 9 WordPress 0x200d07fdc std::__1::shared_ptr::~shared_ptr (memory:3238) 10 WordPress 0x200f42358 [inlined] std::__1::shared_ptr::~shared_ptr (memory:3236) 11 WordPress 0x200f42358 reanimated::RuntimeManager::~RuntimeManager (RuntimeManager.h:36) 12 WordPress 0x200f4432c reanimated::NativeReanimatedModule::~NativeReanimatedModule (NativeReanimatedModule.h:25) 13 WordPress 0x200d07fdc [inlined] std::__1::__shared_count::__release_shared (memory:2506) 14 WordPress 0x200d07fdc [inlined] std::__1::__shared_weak_count::__release_shared (memory:2548) 15 WordPress 0x200d07fdc std::__1::shared_ptr::~shared_ptr (memory:3238) 16 WordPress 0x201328150 [inlined] std::__1::shared_ptr::~shared_ptr (memory:3236) 17 WordPress 0x201328150 [inlined] facebook::jsc::detail::HostObjectProxyBase::~HostObjectProxyBase (JSCRuntime.cpp:695) 18 WordPress 0x201328150 [inlined] facebook::jsc::JSCRuntime::createObject::HostObjectProxy::~HostObjectProxy (JSCRuntime.cpp:712) 19 WordPress 0x201328150 [inlined] facebook::jsc::JSCRuntime::createObject::HostObjectProxy::~HostObjectProxy (JSCRuntime.cpp:712) 20 WordPress 0x201328150 facebook::jsc::JSCRuntime::createObject::HostObjectProxy::finalize (JSCRuntime.cpp:817) 21 JavaScriptCore 0x31fe3ea60 JSC::JSCallbackObject::destroy 22 JavaScriptCore 0x3205d95e0 JSC::MarkedBlock::Handle::specializedSweep 23 JavaScriptCore 0x3205d6e74 JSC::MarkedBlock::Handle::finishSweepKnowingHeapCellType 24 JavaScriptCore 0x3205d6d20 JSC::JSDestructibleObjectHeapCellType::finishSweep 25 JavaScriptCore 0x3202b214c JSC::MarkedBlock::Handle::sweep 26 JavaScriptCore 0x32028ddf0 JSC::BlockDirectory::lastChanceToFinalize 27 JavaScriptCore 0x3202b3b5c JSC::MarkedSpace::lastChanceToFinalize 28 JavaScriptCore 0x320293758 JSC::Heap::lastChanceToFinalize 29 JavaScriptCore 0x320702678 JSC::VM::~VM 30 JavaScriptCore 0x320607a8c JSC::JSLockHolder::~JSLockHolder 31 JavaScriptCore 0x31fe4ce60 JSGlobalContextRelease 32 WordPress 0x201325758 facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:391) 33 WordPress 0x201325858 [inlined] facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:383) 34 WordPress 0x201325858 facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:383) 35 WordPress 0x200d07fdc [inlined] std::__1::__shared_count::__release_shared (memory:2506) 36 WordPress 0x200d07fdc [inlined] std::__1::__shared_weak_count::__release_shared (memory:2548) 37 WordPress 0x200d07fdc std::__1::shared_ptr::~shared_ptr (memory:3238) 38 WordPress 0x201332b38 [inlined] std::__1::shared_ptr::~shared_ptr (memory:3236) 39 WordPress 0x201332b38 facebook::react::JSIExecutor::~JSIExecutor (JSIExecutor.h:71) 40 WordPress 0x201332a24 [inlined] facebook::react::JSIExecutor::~JSIExecutor (JSIExecutor.h:71) 41 WordPress 0x201332a24 facebook::react::JSIExecutor::~JSIExecutor (JSIExecutor.h:71) 42 WordPress 0x200fc1494 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 43 WordPress 0x200fc1494 [inlined] std::__1::function::operator() (functional:2560) 44 WordPress 0x200fc1494 facebook::react::tryAndReturnError (RCTCxxUtils.mm:74) 45 WordPress 0x200fcd404 facebook::react::RCTMessageThread::tryFunc (RCTMessageThread.mm:69) 46 WordPress 0x200fcd748 facebook::react::RCTMessageThread::runOnQueueSync (RCTMessageThread.mm:92) 47 WordPress 0x20130d2d0 facebook::react::NativeToJsBridge::destroy (NativeToJsBridge.cpp:285) 48 WordPress 0x2013033ec facebook::react::Instance::~Instance (Instance.cpp:39) 49 WordPress 0x200fbe98c [inlined] std::__1::default_delete::operator() (memory:1428) 50 WordPress 0x200fbe98c std::__1::__shared_ptr_pointer::__on_zero_shared (memory:2596) 51 WordPress 0x200fbb50c [inlined] std::__1::__shared_count::__release_shared (memory:2506) 52 WordPress 0x200fbb50c [inlined] std::__1::__shared_weak_count::__release_shared (memory:2548) 53 WordPress 0x200fbb50c [inlined] std::__1::shared_ptr::~shared_ptr (memory:3238) 54 WordPress 0x200fbb50c [inlined] std::__1::shared_ptr::~shared_ptr (memory:3236) 55 WordPress 0x200fbb50c [inlined] std::__1::shared_ptr::reset (memory:3333) 56 WordPress 0x200fbb50c __26-[RCTCxxBridge invalidate]_block_invoke (RCTCxxBridge.mm:1333) 57 WordPress 0x200fc1494 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 58 WordPress 0x200fc1494 [inlined] std::__1::function::operator() (functional:2560) 59 WordPress 0x200fc1494 facebook::react::tryAndReturnError (RCTCxxUtils.mm:74) 60 WordPress 0x200fb665c -[RCTCxxBridge _tryAndHandleError:] (RCTCxxBridge.mm:376) 61 Foundation 0x302bd6234 __NSThreadPerformPerform 62 CoreFoundation 0x30238f7dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 63 CoreFoundation 0x30238f734 __CFRunLoopDoSource0 64 CoreFoundation 0x30238eecc __CFRunLoopDoSources0 65 CoreFoundation 0x30238a018 __CFRunLoopRun 66 CoreFoundation 0x3023898b8 CFRunLoopRunSpecific 67 WordPress 0x200fb6590 +[RCTCxxBridge runRunLoop] (RCTCxxBridge.mm:367) 68 Foundation 0x302bd60ac __NSThread__start__ 69 libsystem_pthread.dylib 0x301f6b1e8 _pthread_start ```

C++ exception - PostPostViewController - NSt3__112system_errorE

Stacktrace

Click here to display the stack trace ``` libsystem_kernel 0x1b85744fc mach_msg_trap libsystem_kernel 0x1b8573880 mach_msg CoreFoundation 0x18a327e54 __CFRunLoopServiceMachPort CoreFoundation 0x18a321cf4 __CFRunLoopRun CoreFoundation 0x18a321304 CFRunLoopRunSpecific Foundation 0x18b610d88 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] Foundation 0x18b610c54 -[NSRunLoop(NSRunLoop) runUntilDate:] UIKitCore 0x18ce54300 -[UIEventFetcher threadMain] Foundation 0x18b782308 __NSThread__start__ libsystem_pthread 0x1d601cbf8 _pthread_start ```

C++ exception - UICompatibilityInputViewController - N8facebook3jsi7JSErrorE

Stacktrace

Click here to display the stack trace ``` libsystem_kernel 0x1b5c904fc mach_msg_trap libsystem_kernel 0x1b5c8f880 mach_msg CoreFoundation 0x187b17eac __CFRunLoopServiceMachPort CoreFoundation 0x187b11d4c __CFRunLoopRun CoreFoundation 0x187b1135c CFRunLoopRunSpecific Foundation 0x188dfefd8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] Foundation 0x188dfeea4 -[NSRunLoop(NSRunLoop) runUntilDate:] UIKitCore 0x18a641128 -[UIEventFetcher threadMain] Foundation 0x188f70328 __NSThread__start__ libsystem_pthread 0x1d3700bf8 _pthread_start ```

Don't try to clone an object backed by a different Runtime

Stacktrace

Click here to display the stack trace ``` 0 libsystem_kernel.dylib 0x39d0e5b38 __pthread_kill 1 libsystem_pthread.dylib 0x410b453b8 pthread_kill 2 libsystem_c.dylib 0x343bae520 abort 3 libsystem_c.dylib 0x343c05994 __assert_rtn 4 WordPress 0x2015f92fc facebook::jsc::JSCRuntime::cloneObject (JSCRuntime.cpp:616) 5 WordPress 0x2015b7fd8 facebook::jsc::JSCRuntime::cloneObject (JSCRuntime.cpp:616) 6 WordPress 0x2011feae4 [inlined] facebook::jsi::Value::Value (jsi.h:995) 7 WordPress 0x2011feae4 [inlined] facebook::jsi::detail::toValue (jsi-inl.h:40) 8 WordPress 0x2011feae4 facebook::jsi::Object::setProperty (jsi-inl.h:117) 9 WordPress 0x2011fe3f8 [inlined] reanimated::ShareableValue::toJSValue::lambda::operator() (ShareableValue.cpp:387) 10 WordPress 0x2011fe3f8 [inlined] std::__1::__invoke (type_traits:3694) 11 WordPress 0x2011fe3f8 [inlined] std::__1::__invoke_void_return_wrapper::__call (__functional_base:317) 12 WordPress 0x2011fe3f8 [inlined] std::__1::__function::__alloc_func::operator() (functional:1558) 13 WordPress 0x2011fe3f8 std::__1::__function::__func::operator() (functional:1732) 14 WordPress 0x2015bb394 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 15 WordPress 0x2015bb394 std::__1::function::operator() (functional:2560) 16 WordPress 0x2015bb0dc facebook::jsc::JSCRuntime::createFunctionFromHostFunction::HostFunctionMetadata::call (JSCRuntime.cpp:1158) 17 JavaScriptCore 0x3441be024 JSC::callJSNonFinalObjectCallbackObject 18 JavaScriptCore 0x3449ff4e8 JSC::handleHostCall 19 JavaScriptCore 0x344a32ac0 llint_link_call 20 JavaScriptCore 0x344141d38 llint_function_for_construct_arity_checkTagGateAfter 21 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 22 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 23 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 24 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 25 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 26 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 27 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 28 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 29 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 30 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 31 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 32 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 33 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 34 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 35 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 36 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 37 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 38 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 39 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 40 JavaScriptCore 0x34413e4f4 [inlined] llint_function_for_construct_arity_checkTagGateAfter 41 JavaScriptCore 0x34413e4f4 llint_function_for_construct_arity_checkTagGateAfter 42 JavaScriptCore 0x34413e734 llint_function_for_construct_arity_checkTagGateAfter 43 JavaScriptCore 0x34411442c vmEntryToJavaScriptTrampoline 44 JavaScriptCore 0x34490c638 JSC::Interpreter::executeProgram 45 JavaScriptCore 0x344bd3984 JSC::evaluate 46 JavaScriptCore 0x3441b53ac JSEvaluateScript 47 WordPress 0x2015b7648 facebook::jsc::JSCRuntime::evaluateJavaScript (JSCRuntime.cpp:429) 48 WordPress 0x2015c1af4 facebook::react::JSIExecutor::loadBundle (JSIExecutor.cpp:159) 49 WordPress 0x20159f570 [inlined] facebook::react::NativeToJsBridge::loadBundle::lambda::operator() (NativeToJsBridge.cpp:146) 50 WordPress 0x20159f570 [inlined] std::__1::__invoke (type_traits:3694) 51 WordPress 0x20159f570 [inlined] std::__1::__invoke_void_return_wrapper::__call (__functional_base:348) 52 WordPress 0x20159f570 [inlined] std::__1::__function::__alloc_func::operator() (functional:1558) 53 WordPress 0x20159f570 std::__1::__function::__func::operator() (functional:1732) 54 WordPress 0x2015a03b8 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 55 WordPress 0x2015a03b8 [inlined] std::__1::function::operator() (functional:2560) 56 WordPress 0x2015a03b8 [inlined] facebook::react::NativeToJsBridge::runOnExecutorQueue::lambda::operator() (NativeToJsBridge.cpp:310) 57 WordPress 0x2015a03b8 [inlined] std::__1::__invoke (type_traits:3694) 58 WordPress 0x2015a03b8 [inlined] std::__1::__invoke_void_return_wrapper::__call (__functional_base:348) 59 WordPress 0x2015a03b8 [inlined] std::__1::__function::__alloc_func::operator() (functional:1558) 60 WordPress 0x2015a03b8 std::__1::__function::__func::operator() (functional:1732) 61 WordPress 0x201256b60 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 62 WordPress 0x201256b60 [inlined] std::__1::function::operator() (functional:2560) 63 WordPress 0x201256b60 facebook::react::tryAndReturnError (RCTCxxUtils.mm:74) 64 WordPress 0x201262ad0 facebook::react::RCTMessageThread::tryFunc (RCTMessageThread.mm:69) 65 WordPress 0x201262884 [inlined] std::__1::__function::__value_func::operator() (functional:1885) 66 WordPress 0x201262884 [inlined] std::__1::function::operator() (functional:2560) 67 WordPress 0x201262884 facebook::react::RCTMessageThread::runAsync (RCTMessageThread.mm:45) 68 CoreFoundation 0x32d9025a0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ 69 CoreFoundation 0x32d9034fc __CFRunLoopDoBlocks 70 CoreFoundation 0x32d89b3d4 __CFRunLoopRun 71 CoreFoundation 0x32d8aebc4 CFRunLoopRunSpecific 72 WordPress 0x20124bc5c +[RCTCxxBridge runRunLoop] (RCTCxxBridge.mm:367) 73 Foundation 0x3308e1438 __NSThread__start__ 74 libsystem_pthread.dylib 0x410b3f9a8 _pthread_start ```
fluiddot commented 2 years ago

In relation to the previous comment, my plan is to go ahead with the fix provided in this PR on both platforms, which hopefully could help to address the crashes 🀞.

geriux commented 2 years ago

In relation to the previous comment, my plan is to go ahead with the fix provided in this PR on both platforms, which hopefully could help to address the crashes 🀞.

That's a great idea, I think that by adding the weakModule reference might help with this 🀞

fluiddot commented 2 years ago

In relation to the https://github.com/WordPress/gutenberg/issues/41686#issuecomment-1158877608, my plan is to go ahead with https://github.com/software-mansion/react-native-reanimated/pull/3185 on both platforms, which hopefully could help to address the crashes 🀞.

Looks like the C++ side of Reanimated differs by platform, so the fix that was already released for Android might require extra work and potentially won't provide a solution.

In fact, after applying the fix related to using a weak pointer, on iOS, we've managed to reproduce the crash JSCRuntime destroyed with a dangling API object consistently on development mode:

  1. Open the WP-iOS app with the Metro server connected.
  2. Open a post/page that already contains some blocks.
  3. Long-press over a block to start dragging.
  4. While dragging a block, close the editor using a different finger.
  5. Observe that the app crashes throwing the following error and stack trace.
Screenshot 2022-06-23 at 16 50 51

Interestingly enough, this issue can't be reproduced on production, although, per the stack trace and error message looks very similar to the ones that are listed in this issue's description.

@geriux and I have tried to track down the culprit, but couldn't manage to find a specific part that is causing the crash. Our gut feeling is that Reanimated is affected by some kind of race condition during the Reanimated native module deallocation, which ultimately produces an exception on random occasions. Looks like this type of crash is also encountered by other users of the library, here are some examples:


At this point, we could try upgrading the library to a newer version although we haven't found any specific entry in the new version changelogs for these issues. Alternatively, as mentioned in this comment, it might be worth trying to enable Hermes on iOS, in case it helps in addressing the issue.

arinjay commented 2 years ago

@fluiddot were you able to reduce the crashes by enabling hermes on iOS?

dcalhoun commented 2 years ago

were you able to reduce the crashes by enabling hermes on iOS?

Hey @arinjay. πŸ‘‹πŸ» We have not yet enabled Hermes for iOS. We hope to in the future, but I do not believe we have set a schedule for that work at this time.

fluiddot commented 1 year ago

Don't try to clone an object backed by a different Runtime

  • Sentry event: https://sentry.io/share/issue/5070bdca207a4c4c93af5e2123e5653c/
  • Affected app version: 19.5.0.4 and newer
  • Stacktrace insights: The error message states that it's trying to clone an object backed by a different runtime. This error is a bit odd as we're not using different runtimes, so no clue here about the culprit.
  • User action insights: Looks like it's happening upon opening the editor per the last user actions.
  • Potential workaround: I found a GitHub comment that outlines a similar stack trace, it states that upgrading to Reanimated 2.6.0 might solve the issue. Another possible culprit might be our version of the React Navigation library, which uses Reanimated and might produce a conflict between using v1 and v2 of Reanimated.

FYI I created https://github.com/wordpress-mobile/gutenberg-mobile/issues/5862 to track this issue individually.

fluiddot commented 9 months ago

We are still receiving events related to this crash in the last versions. In fact, it's one of the top 5 crashes on iOS. We've tried different avenues to debug it but the lack of reproduction steps made it difficult to identify the culprit. For this reason, I'd advocate keeping the [Priority] High label.