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

Reloading a dev app rapidly crashes the app #44755

Open
hannojg opened this issue Jun 3, 2024 · 14 comments
Open

Reloading a dev app rapidly crashes the app #44755

hannojg opened this issue Jun 3, 2024 · 14 comments
Labels
Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@hannojg
Copy link
Contributor

hannojg commented Jun 3, 2024

Description

When repeatedly reloading the app pressing "r" in the metro bundler the app crashes

Steps to reproduce

  1. Run the example application on iOS [Note: I think this should be reproducible with the react-native example app]
    1.1 cd ReproducerApp
    1.2 yarn
    1.3 yarn pods
    1.4 Open the iOS project and build xed ios
  2. Make sure its on new arch & bridgleless
  3. In the metro bundler spam the "r" button for reload (you might need to spam it many many times)
  4. You'll get a crash

Note: The effect is amplified in a real world app with more elements.

React Native Version

0.74.1

Affected Platforms

Runtime - iOS

Areas

Fabric - The New Renderer

Output of npx react-native info

Note: This command is broken and doesn't work asof RN 0.74.1

OS: macOS Sonoma 14.4.1
Node Version: v20.13.0
react-native version: 0.74.1

Stacktrace or Logs

com.facebook.react.runtime.JavaScript (22)
#0	0x00000001048dc304 in facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7::operator()() const at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp:290
#1	0x00000001048dc2dc in decltype(std::declval<facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7&>()()) std::__1::__invoke[abi:ue170006]<facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7&>(facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:340
#2	0x00000001048dc294 in void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7&>(facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:415
#3	0x00000001048dc270 in std::__1::__function::__alloc_func<facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7, std::__1::allocator<facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7>, void ()>::operator()[abi:ue170006]() at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:193
#4	0x00000001048daf84 in std::__1::__function::__func<facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7, std::__1::allocator<facebook::react::Scheduler::uiManagerDidFinishTransaction(std::__1::shared_ptr<facebook::react::MountingCoordinator const>, bool)::$_7>, void ()>::operator()() at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:364
#5	0x0000000104613a48 in std::__1::__function::__value_func<void ()>::operator()[abi:ue170006]() const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:518
#6	0x0000000104613968 in std::__1::function<void ()>::operator()() const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:1169
#7	0x0000000104d8f58c in facebook::react::RuntimeScheduler_Modern::updateRendering() at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp:321
#8	0x0000000104d8edb4 in facebook::react::RuntimeScheduler_Modern::executeTask(facebook::jsi::Runtime&, std::__1::shared_ptr<facebook::react::Task> const&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l>>>) at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp:306
#9	0x0000000104d8e868 in facebook::react::RuntimeScheduler_Modern::startWorkLoop(facebook::jsi::Runtime&, bool) at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp:245
#10	0x0000000104d978cc in facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1::operator()(facebook::jsi::Runtime&) const at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp:224
#11	0x0000000104d97894 in decltype(std::declval<facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1&>()(std::declval<facebook::jsi::Runtime&>())) std::__1::__invoke[abi:ue170006]<facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1&, facebook::jsi::Runtime&>(facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1&, facebook::jsi::Runtime&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:340
#12	0x0000000104d97844 in void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1&, facebook::jsi::Runtime&>(facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1&, facebook::jsi::Runtime&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:415
#13	0x0000000104d97818 in std::__1::__function::__alloc_func<facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1, std::__1::allocator<facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1>, void (facebook::jsi::Runtime&)>::operator()[abi:ue170006](facebook::jsi::Runtime&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:193
#14	0x0000000104d96694 in std::__1::__function::__func<facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1, std::__1::allocator<facebook::react::RuntimeScheduler_Modern::scheduleWorkLoop()::$_1>, void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:364
#15	0x0000000104684000 in std::__1::__function::__value_func<void (facebook::jsi::Runtime&)>::operator()[abi:ue170006](facebook::jsi::Runtime&) const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:518
#16	0x000000010468243c in std::__1::function<void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:1169
#17	0x0000000104c32284 in facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'()::operator()() const at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/ReactCommon/react/runtime/ReactInstance.cpp:70
#18	0x0000000104c32208 in decltype(std::declval<facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'()&>()()) std::__1::__invoke[abi:ue170006]<facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'()&>(facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'()&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:340
#19	0x0000000104c321c0 in void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'()&>(facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'()&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:415
#20	0x0000000104c3219c in std::__1::__function::__alloc_func<facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(), std::__1::allocator<facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'()>, void ()>::operator()[abi:ue170006]() at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:193
#21	0x0000000104c30ef4 in std::__1::__function::__func<facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(), std::__1::allocator<facebook::react::ReactInstance::ReactInstance(std::__1::unique_ptr<facebook::react::JSRuntime, std::__1::default_delete<facebook::react::JSRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1::shared_ptr<facebook::react::TimerManager>, std::__1::function<void (facebook::react::MapBuffer)>, facebook::react::jsinspector_modern::PageTarget*)::$_0::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'()>, void ()>::operator()() at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:364
#22	0x0000000104613a48 in std::__1::__function::__value_func<void ()>::operator()[abi:ue170006]() const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:518
#23	0x0000000104613968 in std::__1::function<void ()>::operator()() const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:1169
#24	0x0000000104664ad4 in facebook::react::tryAndReturnError(std::__1::function<void ()> const&) at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/React/CxxModule/RCTCxxUtils.mm:73
#25	0x000000010468cfb0 in facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/React/CxxBridge/RCTMessageThread.mm:68
#26	0x0000000104691e40 in facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1::operator()() const at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/React/CxxBridge/RCTMessageThread.mm:81
#27	0x0000000104691de4 in decltype(std::declval<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&>()()) std::__1::__invoke[abi:ue170006]<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&>(facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:340
#28	0x0000000104691d9c in void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&>(facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:415
#29	0x0000000104691d78 in std::__1::__function::__alloc_func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1, std::__1::allocator<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1>, void ()>::operator()[abi:ue170006]() at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:193
#30	0x0000000104690a88 in std::__1::__function::__func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1, std::__1::allocator<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1>, void ()>::operator()() at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:364
#31	0x0000000104613a48 in std::__1::__function::__value_func<void ()>::operator()[abi:ue170006]() const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:518
#32	0x0000000104613968 in std::__1::function<void ()>::operator()() const at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk/usr/include/c++/v1/__functional/function.h:1169
#33	0x000000010468cd74 in invocation function for block in facebook::react::RCTMessageThread::runAsync(std::__1::function<void ()>) at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/React/CxxBridge/RCTMessageThread.mm:44
#34	0x000000018040ec50 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ ()
#35	0x000000018040e398 in __CFRunLoopDoBlocks ()
#36	0x0000000180409264 in __CFRunLoopRun ()
#37	0x0000000180408514 in CFRunLoopRunSpecific ()
#38	0x0000000104c1a228 in +[RCTJSThreadManager runRunLoop] at /Users/hannomargelo/Documents/Github/react-native-worklets-core/package/example/node_modules/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTJSThreadManager.mm:102
#39	0x0000000180e10be4 in __NSThread__start__ ()
#40	0x0000000106fab414 in _pthread_start ()

Reproducer

https://github.com/hannojg/crash-on-reload

Screenshots and Videos

Screen.Recording.2024-06-03.at.09.25.19.mov
@hannojg hannojg added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Jun 3, 2024
@github-actions github-actions bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. and removed Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Jun 3, 2024
@cipolleschi
Copy link
Contributor

cipolleschi commented Jun 3, 2024

@hannojg Thanks for the issue. I just tried myself with an app on 0.74.1 and I could not reproduce the issue:

Screen.Recording.2024-06-03.at.10.30.40.mov

@cipolleschi
Copy link
Contributor

I created a new app with 0.74.1 to reproduce your same scenario and environment. I can't repro the issue there either.

Screen.Recording.2024-06-03.at.10.48.24.mov

@hannojg
Copy link
Contributor Author

hannojg commented Jun 3, 2024

Hmm, this is odd, I can reliably reproduce this issue 🤔
Can you try the reproduction app? I just pushed a new commit that renders react components that are similar to our app where we experience the crash:

Screen.Recording.2024-06-03.at.12.35.48.mov

// Note: I wasn't able to reproduce the issue on a real device; not sure what could make the difference

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jun 3, 2024
@cipolleschi
Copy link
Contributor

uhm, you sure you pushed? I only see these commits:
Screenshot 2024-06-03 at 13 28 11

Perhaps you committed but not pushed to remote?

I just tried with the reproducer (which spins up a new app with 0.74.1) and can't repro it... :/

@hannojg
Copy link
Contributor Author

hannojg commented Jun 3, 2024

So sorry, forgot to push, its up now!

@cipolleschi
Copy link
Contributor

😞 😞 😞 😞 😞 😞 😞 😞

...no crashes...

Screen.Recording.2024-06-03.at.14.07.30.mov

@hannojg
Copy link
Contributor Author

hannojg commented Jun 3, 2024

Thanks for testing, so weird it's not reproducible on your end. I see that you use iOS 17.5, where I am using 17.4 (although I wouldn't know what difference that could make). Will upgrade tonight and try to reproduce tmrw on iOS 17.5 (any other ideas what could cause the difference?)

@cipolleschi
Copy link
Contributor

that could be something, actually. I'm using Xcode 15.4 and Apple made several changes in Xcode 15 for C++, in every version basically... So perhaps that fixes?
Today I don't have any extra time to install iOS 17.4 and try with that, but I can give it a shot tomorrow.

@cortinico cortinico removed Needs: Triage 🔍 Needs: Attention Issues where the author has responded to feedback. labels Jun 4, 2024
@hannojg
Copy link
Contributor Author

hannojg commented Jun 5, 2024

I upgraded to Xcode 15.4 and tested with iOS 17.5 and I am still able to reproduce it 😅

Screenshot 2024-06-05 at 08 24 27

@cipolleschi
Copy link
Contributor

😭 I'm very sad and sorry. But I can't reproduce it. And it is a completely new app, with the reproducer. :(

@HarshitMadhav
Copy link

@hannojg @cipolleschi Hey! I cloned the above repo and I was able to reproduce this issue for iOS

Screen.Recording.2024-06-06.at.12.40.10.AM.1.1.1.1.mov

@coado
Copy link
Contributor

coado commented Sep 4, 2024

I was able to reproduce it, so I will try to investigate this one.

metro-crash-recording1080p.mov

@coado
Copy link
Contributor

coado commented Sep 10, 2024

@cipolleschi For now I can tell that the problem occurs, because of the race condition that happens when there are two reloads one after the other. When the reload starts the RCTSurfacePresenter is suspended which deallocates the scheduler with its delegate on the UI thread. In unfortunate situation it may happen right after the delegate_ != nullptr check, but before delegate->schedulerShouldRenderTransactions(mountingCoordinator) in Scheduler::uiManagerDidFinishTransaction on the JS thread when the previous reload is committing.

I am thinking about the possible solution as it would require checking during the commit to see if there is another reload that just happened and potentially dropping the commit. It would require some locks to stop deallocation from the UI thread during a commit on the JS thread or drop stale commits if there is a new reload and deallocation has already happened.

We could also debounce reloads as it would be the easiest and the least invasive solution.

@cipolleschi
Copy link
Contributor

I like the debounce solution. We can isolate it in a single location in the codebase and mitigate the issue to the point that it does not present itself anymore.

facebook-github-bot pushed a commit that referenced this issue Sep 18, 2024
Summary:
Regarding the [issue](#44755) where the app sometimes crashes due to race condition when two reloads overlap in unfortunate way. This PR fixes it in some way by introducing throttling on reload command. For now I set it to 700ms as I was still able to reproduce it on 500-550ms for provided repro in the issue. The problem may still happen for bigger apps where reload may take more time to finish.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [FIXED] - throttle reload command

Pull Request resolved: #46416

Test Plan: I've tested on provided repro and a smaller app trying to brake it.

Reviewed By: huntie

Differential Revision: D62847076

Pulled By: cipolleschi

fbshipit-source-id: 6471f792d6b692e87e3e98a699443a88c6ef43cd
blakef pushed a commit that referenced this issue Sep 23, 2024
Summary:
Regarding the [issue](#44755) where the app sometimes crashes due to race condition when two reloads overlap in unfortunate way. This PR fixes it in some way by introducing throttling on reload command. For now I set it to 700ms as I was still able to reproduce it on 500-550ms for provided repro in the issue. The problem may still happen for bigger apps where reload may take more time to finish.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [FIXED] - throttle reload command

Pull Request resolved: #46416

Test Plan: I've tested on provided repro and a smaller app trying to brake it.

Reviewed By: huntie

Differential Revision: D62847076

Pulled By: cipolleschi

fbshipit-source-id: 6471f792d6b692e87e3e98a699443a88c6ef43cd
Kudo added a commit to expo/expo that referenced this issue Oct 2, 2024
# Why

fix ios reload crash, e.g. `Updates.reloadAsync()` on new architecture
mode.
close ENG-13646

# How

fundamentally, the issue is from react-native core and could relate to
facebook/react-native#44755. this pr is trying
to send `RCTTriggerReloadCommandListeners` from main thread. that would
highly reduce the possibility of having the crash.
Kudo added a commit to expo/expo that referenced this issue Oct 2, 2024
fix ios reload crash, e.g. `Updates.reloadAsync()` on new architecture
mode.
close ENG-13646

fundamentally, the issue is from react-native core and could relate to
facebook/react-native#44755. this pr is trying
to send `RCTTriggerReloadCommandListeners` from main thread. that would
highly reduce the possibility of having the crash.

(cherry picked from commit ba9b2da)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

5 participants