Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when opening and closing the editor: C++ Exception: NSt3__112system_errorE #20499

Closed
guarani opened this issue Apr 10, 2023 · 42 comments
Closed
Labels
Gutenberg Editing and display of Gutenberg blocks. [Pri] Medium [Type] Crash
Milestone

Comments

@guarani
Copy link
Contributor

guarani commented Apr 10, 2023

Sentry issues:

Reference: Sentry search for NSt3__112system_errorE across both the JP and WP apps.

Potential solution

The crash should be addressed with #20956. More context.

Reproduction Steps

Copied from #20499 (comment).

  1. Navigate to the post list screen.
  2. Focus the search input and query for several posts.
  3. Keep the search input focused.1
  4. Open and close a post.
  5. Repeat step 4 until the app crashes.2

Footnotes

  1. May not be necessary, but keyboard show/hide event are in numerous Sentry crash logs.

  2. Crashing occurs very infrequently.

@guarani
Copy link
Contributor Author

guarani commented Apr 10, 2023

This might be related to React Native because it appears in the Stack Trace I downloaded from Sentry, e.g.:

Thread 9 name: com.facebook.react.JavaScript
0   libsystem_kernel.dylib          0x3aef6567c         __psynch_cvwait
1   libsystem_pthread.dylib         0x3cfe34068         _pthread_cond_wait
2   JavaScriptCore                  0x35a738ce8         WTF::ParkingLot::parkConditionallyImpl
3   JavaScriptCore                  0x35a6f9638         WTF::Condition::waitUntilUnchecked<T>
4   JavaScriptCore                  0x35b177188         JSC::Heap::lastChanceToFinalize
5   JavaScriptCore                  0x35b7f8608         JSC::VM::~VM
6   JavaScriptCore                  0x35b68a068         JSC::JSLockHolder::~JSLockHolder
7   JavaScriptCore                  0x35ab857e4         JSGlobalContextRelease
8   WordPress                       0x2042d69c0         facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:392)
9   WordPress                       0x2042d6ac0         [inlined] facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:384)
10  WordPress                       0x2042d6ac0         facebook::jsc::JSCRuntime::~JSCRuntime (JSCRuntime.cpp:384)
11  WordPress                       0x203ca7bd0         [inlined] std::__1::__shared_count::__release_shared (shared_ptr.h:177)
12  WordPress                       0x203ca7bd0         [inlined] std::__1::__shared_weak_count::__release_shared (shared_ptr.h:219)
13  WordPress                       0x203ca7bd0         std::__1::shared_ptr<T>::~shared_ptr (shared_ptr.h:959)
14  WordPress                       0x203ed5128         [inlined] std::__1::shared_ptr<T>::~shared_ptr (shared_ptr.h:957)
15  WordPress                       0x203ed5128         reanimated::RuntimeManager::~RuntimeManager (RuntimeManager.h:36)
16  WordPress                       0x203ed7168         reanimated::NativeReanimatedModule::~NativeReanimatedModule (NativeReanimatedModule.h:26)
17  WordPress                       0x203ca7bd0         [inlined] std::__1::__shared_count::__release_shared (shared_ptr.h:177)
18  WordPress                       0x203ca7bd0         [inlined] std::__1::__shared_weak_count::__release_shared (shared_ptr.h:219)
19  WordPress                       0x203ca7bd0         std::__1::shared_ptr<T>::~shared_ptr (shared_ptr.h:959)
20  WordPress                       0x2042d9320         [inlined] std::__1::shared_ptr<T>::~shared_ptr (shared_ptr.h:957)
21  WordPress                       0x2042d9320         [inlined] facebook::jsc::detail::HostObjectProxyBase::~HostObjectProxyBase (JSCRuntime.cpp:703)
22  WordPress                       0x2042d9320         [inlined] facebook::jsc::JSCRuntime::createObject::HostObjectProxy::~HostObjectProxy (JSCRuntime.cpp:720)
23  WordPress                       0x2042d9320         [inlined] facebook::jsc::JSCRuntime::createObject::HostObjectProxy::~HostObjectProxy (JSCRuntime.cpp:720)
24  WordPress                       0x2042d9320         facebook::jsc::JSCRuntime::createObject::HostObjectProxy::finalize (JSCRuntime.cpp:825)

@guarani
Copy link
Contributor Author

guarani commented Apr 10, 2023

👋 @geriux, do you have any context on this crash? I saw your name in the Activity tab of the Sentry issue for this crash. I bumped into this on Snetry during my release rotation because it's the top crash in 22.0, so I created this GitHub issue to help triage.

@geriux
Copy link
Contributor

geriux commented Apr 11, 2023

👋 @geriux, do you have any context on this crash? I saw your name in the Activity tab of the Sentry issue for this crash. I bumped into this on Snetry during my release rotation because it's the top crash in 22.0, so I created this GitHub issue to help triage.

It looks like it is related to this issue WordPress/gutenberg#41686 and the Reanimated library. After some investigations, we couldn't find a quick solution but we had some ideas like starting using Hermes on iOS or updating the Reanimated library to the latest version. I think we should revisit this as it is one of the top issues.

@guarani
Copy link
Contributor Author

guarani commented Apr 11, 2023

Thanks for the context, @geriux!

@guarani
Copy link
Contributor Author

guarani commented Apr 11, 2023

As for next steps, should someone be assigned to this issue? I should remove the Needs Triage label once it has an assignee (see internal ref PCYsg-vRg-p2).

@geriux
Copy link
Contributor

geriux commented Apr 12, 2023

Maybe we should add it to the Maintenance Week board?

@guarani
Copy link
Contributor Author

guarani commented Apr 12, 2023

Good idea!
@tiagomar I understand that you're maintaining the maintenance board (see React Native board). Would this be a good candidate as @geriux suggested above?

@guarani guarani changed the title App crash report from Sentry Crash when dragging and dropping blocks Apr 12, 2023
@guarani
Copy link
Contributor Author

guarani commented Apr 12, 2023

I assessed this as priority due to Medium severity (assuming drag & drop is a low priority feature) and Medium impact (unsure about it, but maybe 6-24% of users affected given the 101 events in last 24 hours).

@guarani
Copy link
Contributor Author

guarani commented Apr 12, 2023

Do you think https://a8c.sentry.io/issues/3322079168 is a duplicate of the Sentry issue mentioned at the top of this issue, @geriux? I found them to have the same error, C++ Exception NSt3__112system_errorE but when viewing either of them, I couldn't get Sentry to list the other under the Similar Issues in order to merge them.

@tiagomar
Copy link
Contributor

Thanks for the ping @guarani! Yes, I think it is. I have just added this one to the board.

@geriux
Copy link
Contributor

geriux commented Apr 13, 2023

Do you think https://a8c.sentry.io/issues/3322079168 is a duplicate of the Sentry issue mentioned at the top of this issue, @geriux? I found them to have the same error, C++ Exception NSt3__112system_errorE but when viewing either of them, I couldn't get Sentry to list the other under the Similar Issues in order to merge them.

Yeah, that's the same as the other one. That's weird that it doesn't show an option to merge them 🤔

But I can see in that issue that it also happens when the editor is closed.

@guarani
Copy link
Contributor Author

guarani commented Apr 14, 2023

I just realized that the two Sentry issues are in different Sentry projects (WP vs. JP) so can't be merged 🤦:

Screenshot 2023-04-14 at 10 19 35

I linked both back to this GitHub issue 👍

@geriux
Copy link
Contributor

geriux commented Apr 14, 2023

I just realized that the two Sentry issues are in different Sentry projects (WP vs. JP) so can't be merged 🤦:

😅 nice catch! Cool, thank you!

@dcalhoun
Copy link
Member

@guarani I removed the "Requires Triage" label as it appears this issue was prioritized and placed on the maintenance board. Please correct me if I am wrong. Thanks!

@guarani
Copy link
Contributor Author

guarani commented Apr 19, 2023

Good call about removing the "Requires Triage" label, @dcalhoun!

@fluiddot
Copy link
Contributor

This PR might fix this issue in 22.4, although we'd need to confirm this by checking if we receive this Sentry event in version 22.4. So far during the beta testing, no issue was reported 🤞 .

@fluiddot
Copy link
Contributor

This PR might fix this issue in 22.4, although we'd need to confirm this by checking if we receive this Sentry event in version 22.4. So far during the beta testing, no issue was reported 🤞 .

I checked the Sentry events again now that version 22.4 is released, and seems the issue is still reported 😞. We'd need to investigate another solution.

@fluiddot fluiddot removed their assignment May 31, 2023
@dcalhoun dcalhoun self-assigned this Jun 13, 2023
@fluiddot
Copy link
Contributor

👋 @fluiddot, based on WordPress/gutenberg#52320, it looks like this might be fixed in 22.8. I've changed the status here to Monitoring and will check back to see if the issue persists or not.
Please let me know if that sounds like a plan 👍

Sounds great, thanks @guarani for updating its status.

@guarani
Copy link
Contributor Author

guarani commented Jul 20, 2023

Just looping back here to say that there's been no reoccurrence of this crash in the 22.8 beta so far. However, it's too early to tell if this is fixed because this crash only happened once in the 22.7 beta before happening 244 times once 22.7 was in production.

@staskus
Copy link
Contributor

staskus commented Jul 25, 2023

Unfortunately, there're new events for both JPiOS 22.8 and WPiOS 22.8.

We need to review the new reports and look for further solutions.

@fluiddot
Copy link
Contributor

Unfortunately, there're new events for both JPiOS 22.8 and WPiOS 22.8.

😞

We need to review the new reports and look for further solutions.

The fix we incorporated for this was related to being able to identify a similar crash when upgrading React Native. It was a long shot using the same fix for the current React Native version, but we had to try. Hopefully, with the RN upgrade that includes a newer version of the Reanimated library, and the fact that we'll be also enabling Hermes, maybe the crash situation improve. The main problem with this crash is that we aren't able to reproduce it consistently. In any case, since we identified a reproduction case, we could confirm if it's reproducible in the new RN version.

@staskus
Copy link
Contributor

staskus commented Jul 25, 2023

Thanks for a quick reply, @fluiddot!

Hopefully, with the RN upgrade that includes a newer version of the Reanimated library, and the fact that we'll be also enabling Hermes, maybe the crash situation improve.

Just to clarify, these updates were shipped together with 22.8? Or are there any further updates incoming that could potentially reduce occurrences of this crash?

@fluiddot
Copy link
Contributor

Just to clarify, these updates were shipped together with 22.8? Or are there any further updates incoming that could potentially reduce occurrences of this crash?

No, sorry. The changes I mentioned (i.e. the React Native upgrade) that could reduce occurrences aren't merged yet, they will be part of next version 23.0.

@staskus staskus added this to the 23.0 milestone Jul 25, 2023
@staskus
Copy link
Contributor

staskus commented Jul 25, 2023

No, sorry. The changes I mentioned (i.e. the React Native upgrade) that could reduce occurrences aren't merged yet, they will be part of next version 23.0.

Got it, thanks for the update! We'll continue monitoring the issue in upcoming releases then.

@staskus staskus self-assigned this Jul 26, 2023
@staskus
Copy link
Contributor

staskus commented Jul 26, 2023

Testing on trunk

💣 Managed to reproduce the crash consistently by automating these steps:

graph LR
A(Select the search bar)
A --> B(Open post)
B --> C(Dismiss post)
C --> A
Loading

After a couple of minutes I consistently get the crash matching the Sentry reports:

Stack trace
com.facebook.react.JavaScript (26)#0	0x00000001eefb2558 in __pthread_kill ()
#1	0x000000020fdf7118 in pthread_kill ()
#2	0x00000001b7597178 in abort ()
#3	0x00000001b75ef0a4 in __assert_rtn ()
#4	0x00000001030eab14 in facebook::jsc::JSCRuntime::cloneObject(facebook::jsi::Runtime::PointerValue const*) at /Users/povilasstaskus/Projects/WordPress-iOS/Pods/React-jsi/JSCRuntime.cpp:617
#5	0x0000000102855858 in facebook::jsi::Value::Value(facebook::jsi::Runtime&, facebook::jsi::Object const&) at /Users/povilasstaskus/Projects/WordPress-iOS/Pods/React-jsi/jsi/jsi.h:1005
#6	0x000000010285580c in facebook::jsi::Value facebook::jsi::detail::toValue<facebook::jsi::Object>(facebook::jsi::Runtime&, facebook::jsi::Object const&) at /Users/povilasstaskus/Projects/WordPress-iOS/Pods/React-jsi/jsi/jsi-inl.h:40
#7	0x00000001028a2804 in void facebook::jsi::Object::setProperty<facebook::jsi::Object&>(facebook::jsi::Runtime&, facebook::jsi::String const&, facebook::jsi::Object&) at /Users/povilasstaskus/Projects/WordPress-iOS/Pods/React-jsi/jsi/jsi-inl.h:117
#8	0x00000001028a223c in reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at /Users/povilasstaskus/Projects/WordPress-iOS/Pods/RNReanimated/Common/cpp/SharedItems/ShareableValue.cpp:387
#9	0x00000001028a218c in decltype(std::declval<reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2&>()(std::declval<facebook::jsi::Runtime&>(), std::declval<facebook::jsi::Value const&>(), std::declval<facebook::jsi::Value const*>(), std::declval<unsigned long>())) std::__1::__invoke[abi:v15006]<reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/include/c++/v1/__functional/invoke.h:394
#10	0x00000001028a2114 in facebook::jsi::Value std::__1::__invoke_void_return_wrapper<facebook::jsi::Value, false>::__call<reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/include/c++/v1/__functional/invoke.h:470
#11	0x00000001028a20c8 in std::__1::__function::__alloc_func<reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2, std::__1::allocator<reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()[abi:v15006](facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/include/c++/v1/__functional/function.h:185
#12	0x00000001028a0e4c in std::__1::__function::__func<reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2, std::__1::allocator<reanimated::ShareableValue::toJSValue(facebook::jsi::Runtime&)::$_2>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/include/c++/v1/__functional/function.h:359
#13	0x00000001030f259c in std::__1::__function::__value_func<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()[abi:v15006](facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/include/c++/v1/__functional/function.h:512
#14	0x00000001030f1fa0 in std::__1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/include/c++/v1/__functional/function.h:1197
#15	0x00000001030f179c in facebook::jsc::JSCRuntime::createFunctionFromHostFunction(facebook::jsi::PropNameID const&, unsigned int, std::__1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>)::HostFunctionMetadata::call(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) at /Users/povilasstaskus/Projects/WordPress-iOS/Pods/React-jsi/JSCRuntime.cpp:1166
#16	0x00000001c3c7b780 in <redacted> ()
#17	0x00000001c4620e28 in <redacted> ()
#18	0x00000001c46684d4 in <redacted> ()
#19	0x00000001c3c03aa0 in <redacted> ()
Code example (Edited PostListViewController.swift)
     private func editPost(apost: AbstractPost) {
      guard let post = apost as? Post else {
          return
      }
      
      iteratePresentingPost(post: post)
  }
  
  private func iteratePresentingPost(post: Post) {
      PostListEditorPresenter.handle(post: post, in: self, entryPoint: .postsList)
      
      DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
          self.dismiss(animated: false)
          
          DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
              self.searchController.searchBar.becomeFirstResponder()
              DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                  self.iteratePresentingPost(post: post)
              }
          }
      }
  }

Testing with updated RN version

After multiple runs confirming the crash is reproducible, I switched to a gutenberg/upgrade/react-native-0.71.11 branch.

✅ I wasn't able to reproduce this particular crash anymore on multiple long runs. The evidence points that when #20956 gets merged this particular issue will be resolved.

Unfortunately, two times I jumped on a different crash when repeating the same steps. It didn't happen reliably for me. I informed @fluiddot about it:

Unhandled JS Exception: TypeError: Cannot read property 'map' of undefined, js engine: hermes, stack:
 2023-07-26 17:51:48.751334+0300 Jetpack[97864:5674874] [native] Unable to find module for RedBox
2023-07-26 17:51:48.751822+0300 Jetpack[97864:5674874] [native] Unhandled JS Exception: TypeError: Cannot read property 'map' of undefined, js engine: hermes
2023-07-26 17:51:48.753797+0300 Jetpack[97864:5674874] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: TypeError: Cannot read property 'map' of undefined, js engine: hermes', reason: 'Unhandled JS Exception: TypeError: Cannot read property 'map' of undefined, js engine: hermes, stack:
anonymous@1:3209554
value@1:164730
anonymous@1:163142
value@1:164005
value@1:163104
'
*** First throw call stack:
(0x1b0070cb4 0x1a910c3d0 0x10ecafe48 0x10ebe56ac 0x10ebe5ef0 0x1b00d9c04 0x1b0087cb4 0x1b00876cc 0x10ecdb398 0x10ecdd44c 0x10ecdd09c 0x10d4a0520 0x10d4a2038 0x10d4aa0b0 0x10d4aadf4 0x10d4b7c74 0x20fdf0ddc 0x20fdf0b7c)
libc++abi: terminating due to uncaught exception of type NSException


#0	0x000000010d4a6d10 in dispatch_async ()
#1	0x000000010ecdce84 in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) ()
#2	0x000000010ed69aac in facebook::react::JsToNativeBridge::callNativeModules(facebook::react::JSExecutor&, folly::dynamic&&, bool) ()
#3	0x000000010edd9750 in facebook::react::JSIExecutor::callNativeModules(facebook::jsi::Value const&, bool) ()
#4	0x000000010edd98f8 in facebook::react::JSIExecutor::invokeCallback(double, folly::dynamic const&) ()
#5	0x000000010ed6b04c in std::__1::__function::__func<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>)::$_8, std::__1::allocator<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>)::$_8>, void ()>::operator()() ()
#6	0x000000010ecc8b30 in facebook::react::tryAndReturnError(std::__1::function<void ()> const&) ()
#7	0x000000010ecd43f0 in facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) ()
#8	0x000000010ecd41c8 in invocation function for block in facebook::react::RCTMessageThread::runAsync(std::__1::function<void ()>) ()
#9	0x00000001b00aa6e0 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ ()
#10	0x00000001b0111210 in __CFRunLoopDoBlocks ()
#11	0x00000001b00e1718 in __CFRunLoopRun ()
#12	0x00000001b00e63ec in CFRunLoopRunSpecific ()
#13	0x000000010ecbe690 in +[RCTCxxBridge runRunLoop] ()
#14	0x00000001aa37c544 in __NSThread__start__ ()
#15	0x000000020fdf16b8 in _pthread_start ()
#16	0x000000020fdf0b88 in thread_start ()

@staskus staskus changed the title C++ Exception: NSt3__112system_errorE Crash when opening and closing the editor: C++ Exception: NSt3__112system_errorE Jul 27, 2023
@staskus
Copy link
Contributor

staskus commented Aug 3, 2023

Should be fixed by [Gutenberg] Upgrade React Native 0.71.11 on 23.0.

@staskus staskus closed this as completed Aug 3, 2023
@guarani
Copy link
Contributor Author

guarani commented Aug 22, 2023

@SiobhyB, there's a small number of crashes in 23.0 and Sentry has marked this Regressed. Does this need attention? Let me know if there's someone else I should ping. I'm on release rotation and saw your name on the PR linked in the previous comment.

@guarani
Copy link
Contributor Author

guarani commented Aug 22, 2023

FWIW I followed these steps, #20499 (comment), but couldn't reproduce the crash (although since these steps weren't 100% reliable, that might be expected).

@SiobhyB
Copy link
Contributor

SiobhyB commented Aug 22, 2023

Thanks @guarani! We talked about this a little on Slack today here, also: p1692690454170439-slack-C05LL2TLPKQ. Our current thoughts for next steps are as follows:

  • Investigate an active Reanimated warning in the project to see if that helps to resolve the crash.
  • Dive deeper into the current drag and drop implementation.
  • Keep monitoring the rates for this crash to see if it has at least reduced in numbers since the React Native upgrade.

I'll go ahead to reopen this issue to reflect that it's currently under investigation and have added it to the Gutenberg Mobile Crash Focus board. 🙇‍♀️

@SiobhyB SiobhyB reopened this Aug 22, 2023
@guarani
Copy link
Contributor Author

guarani commented Aug 22, 2023

👋 Looks like you were already one step ahead! Thanks, @SiobhyB 🙇

@guarani
Copy link
Contributor Author

guarani commented Aug 24, 2023

Should we update the assignee on this GitHub issue and on both the Sentry issues? That could help other release rotation folks know this is being looked into.

@guarani
Copy link
Contributor Author

guarani commented Aug 25, 2023

👋 Hi @geriux, I noticed @SiobhyB is out of the office so looping you here in case it needs your attention 🙇

@geriux
Copy link
Contributor

geriux commented Aug 28, 2023

Thanks @guarani!

@fluiddot since you have worked on this one before, can you please take a look? Thanks!

@fluiddot
Copy link
Contributor

@fluiddot since you have worked on this one before, can you please take a look? Thanks!

Sure, I'll assign myself to the issue and take a look as soon as possible. Thanks!

@fluiddot fluiddot self-assigned this Aug 28, 2023
@staskus staskus removed their assignment Aug 28, 2023
@fluiddot
Copy link
Contributor

I've tried to reproduce the crash in version 23.0 by following the reproduction steps, but so far I haven't encountered the crash. Based on the user events, seems it's still related to closing the editor. After checking five different sessions, I noticed all were produced when opening a post/page from the dashboard screen. However, there's no clue that points to the potential culprit.

At this point, I don't have any leads to follow in order to debug the crash 😞.

Regarding the next steps outlined in #20499 (comment):

Investigate an active Reanimated warning in the project to see if that helps to resolve the crash.

This warning is only produced when running the integration tests in Jest. It's caused because the Reanimated worklets need the native library to work, hence a warning is displayed when running a worklet in a non-native environment.

Dive deeper into the current drag and drop implementation.

We can revisit the implementation but we'd need first to find a consistent flow to reproduce the crash. With that, we could identify areas in the implementation that could be tweaked in order to provide a fix. We could follow the approach shared in #20499 (comment) and try to automate the steps to lead to the crash 👀.

Keep monitoring the rates for this crash to see if it has at least reduced in numbers since the React Native upgrade.

We probably would need to wait another week to collect the crash metrics of version 23.0 with a higher adoption. In any case, so far, seems the number of events has been reduced:

  • In version 22.9, this crash affected 0.22 % of total users.
  • In version 23.0, this crash affected 0.06 % of total users.

@fluiddot
Copy link
Contributor

Another attempt to debug the crash

Following #20647 (comment), I decided to give another try to debug the crash, but in this case, forcing the scenario where GutenbergViewController is retained and the React Native environment isn't deallocated. I hypothesize that the crash is somehow related to the publishing flow and produced due to not deallocating Gutenberg/React Native.

NOTE: The Jetpack iOS version I used is 23.9. I checked out this tag and built the app locally.

Although not consistently, I managed to reproduce a crash with a different stack trace:

std::__1::__shared_ptr_emplace<T>::__on_zero_shared
reanimated::HostFunctionHandler::~HostFunctionHandler
std::__1::shared_ptr<T>::~shared_ptr[abi:v15006]
+[RCTCxxBridge runRunLoop]
__NSThread__start__

The stack trace differs from the one referenced in this issue:

reanimated::ShareableValue::~ShareableValue
std::__1::shared_ptr<T>::~shared_ptr[abi:v15006]
std::__1::allocator_traits<T>::destroy[abi:v15006]<T>
_ZNSt3__112__hash_tableINS_17__hash_value_typeINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_10shared_ptrIN10reanimated14ShareableValueEEEEENS_22__unordered_map_hasherIS7_SC_NS_4hashIS7_EENS_8equal_toIS7_EELb1EEENS_21__unordered_map_equal...
_ZNSt3__112__hash_tableINS_17__hash_value_typeINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_10shared_ptrIN10reanimated14ShareableValueEEEEENS_22__unordered_map_hasherIS7_SC_NS_4hashIS7_EENS_8equal_toIS7_EELb1EEENS_21__unordered_map_equal...
reanimated::FrozenObject::~FrozenObject
facebook::hermes::debugger::Debugger::jsiValueFromHermesValue
facebook::jsi::JSError::~JSError
facebook::jsi::JSError::~JSError
facebook::jsi::JSError::~JSError
facebook::hermes::debugger::Debugger::jsiValueFromHermesValue
facebook::hermes::debugger::Debugger::jsiValueFromHermesValue
std::__1::shared_ptr<T>::~shared_ptr[abi:v15006]
reanimated::RuntimeManager::~RuntimeManager
reanimated::NativeReanimatedModule::~NativeReanimatedModule
std::__1::shared_ptr<T>::~shared_ptr[abi:v15006]
facebook::jsi::DecoratedHostObject::~DecoratedHostObject
facebook::hermes::debugger::Debugger::jsiValueFromHermesValue
facebook::jsi::JSError::~JSError
facebook::jsi::JSError::~JSError
facebook::jsi::JSError::~JSError
facebook::hermes::debugger::Debugger::jsiValueFromHermesValue
facebook::hermes::debugger::Debugger::jsiValueFromHermesValue
std::__1::shared_ptr<T>::~shared_ptr[abi:v15006]
facebook::react::(anonymous namespace)::DecoratedRuntime::~DecoratedRuntime
std::__1::shared_ptr<T>::~shared_ptr[abi:v15006]
facebook::react::JSIExecutor::~JSIExecutor
facebook::react::HermesExecutor::~HermesExecutor
facebook::react::tryAndReturnError
facebook::react::RCTMessageThread::tryFunc
facebook::react::RCTMessageThread::runOnQueueSync
facebook::react::NativeToJsBridge::destroy
facebook::react::Instance::~Instance
std::__1::__shared_ptr_pointer<T>::__on_zero_shared
std::__1::shared_ptr<T>::reset[abi:v15006]
__26-[RCTCxxBridge invalidate]_block_invoke
facebook::react::tryAndReturnError
-[RCTCxxBridge _tryAndHandleError:]
CFRunLoopRunSpecific
+[RCTCxxBridge runRunLoop]
_pthread_start

NOTE: The stack trace referenced in #20499 (comment) no longer applies, as it was from a past version where React Native used JSC, instead of Hermes.

As you can see above, the stack trace has references to what seems destroy/deallocation methods.

Here are the steps I followed to produce the crash:

  1. Navigate to the Post list.
  2. Create a post.
  3. Add a couple of Image blocks with images.
  4. Set a title and save the post.
  5. In the Post list screen, tap on the Search bar.
  6. Type the title of the draft post.
  7. Select the post.
  8. Tap on the three dots button (...).
  9. Tap on the Post Settings option.
  10. Tap on the Tags option.
  11. Navigate back two times to go back to the editor.
  12. Long-press over one of the Image blocks.
  13. With a second finger, close the editor while dragging the block with the first one.
  14. Observe the crash.

During testing, I managed to reproduce the original crash (Sentry event) but unfortunately, I couldn't force the same crash again and I'm not sure the steps I performed.

Another factor that made me think about this hypothesis is that the Sentry breadcrumb, in most of the events, shows publish actions made by the user. The solution provided in #22265 updated PrepublishingViewController, so there's the chance that either in the Tags screen or another one, GutenbergViewController is retained and hence not deallocated.

In this regard, I also performed another set of testing by commenting this line, as it's the one in charge of destroying the React Native environment.

I managed to reproduce a crash with the following steps:

  1. Create a new post.
  2. Add an Image block.
  3. Set an Image.
  4. Duplicate the Image block.
  5. Long-press over the bottom Image block.
  6. Drag the block up until the content starts scrolling.
  7. With a second finger, tap on the back button to close the editor.
  8. Select the "Discard" option and keep the first finger over the screen.
  9. Wait until the editor closes.
  10. Observe the crash.

The stack trace also differed from the original one, but again, it referenced destroy/deallocation methods.


Unfortunately, this attempt although I felt it was promising, I didn't manage to narrow down the culprit. I hope that in version 24.0 and with #22265, we might see a decrease in this crash.

@fluiddot fluiddot removed their assignment Jan 30, 2024
@guarani
Copy link
Contributor Author

guarani commented Apr 3, 2024

I'm marking this resolved in 24.5.0.2, betting on the assumption that the RN upgrade in 24.5 fixed this 🤞

@guarani guarani closed this as completed Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks. [Pri] Medium [Type] Crash
Projects
None yet
Development

No branches or pull requests

7 participants