mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Throw JS exception when calling a method if bufferedRuntimeExecutor is not initialized (#46735)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46735 We had some crash on Android where we call [`callFunctionOnModule`](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp#L258) when the `bufferedRuntimeExecutor_` might not be initialized. This can happen when navigating away from RN surface and quickly navigate to another one or across refreshes. There could be a scheduled JS function from the previous surface/instance that might try to call a native module while the new instance is being created. This change prevent the crash and replace it with a soft crash, that should show a RedBox on the screen. ## Changelog [Internal] - Throw JS exception when calling a method if buffereRuntimeExecutor is not initialized ## Facebook Have a look at T201983945 that generated the crash report Reviewed By: cortinico Differential Revision: D63638633 fbshipit-source-id: ba331f5173963265232d0810c2d12895cea3d528
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c441de5a47
commit
6d6dd99ec9
@@ -255,6 +255,12 @@ void ReactInstance::callFunctionOnModule(
|
||||
const std::string& moduleName,
|
||||
const std::string& methodName,
|
||||
folly::dynamic&& args) {
|
||||
if (bufferedRuntimeExecutor_ == nullptr) {
|
||||
LOG(ERROR)
|
||||
<< "Calling callFunctionOnModule with null BufferedRuntimeExecutor";
|
||||
return;
|
||||
}
|
||||
|
||||
bufferedRuntimeExecutor_->execute([this,
|
||||
moduleName = moduleName,
|
||||
methodName = methodName,
|
||||
|
||||
Reference in New Issue
Block a user