mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Allow native module loads during react instance init
Summary: ## Context Right now, the ReactInstance construtor eagerly initializes native modules. ## Problem When these modules initialize, they may load other modules. But, all those loads will fail, because the react instance is in the process of being constructed. ## Changes Eagerly initialize modules after the react instance is created. That way, these native module requires work. Changelog: [Internal] Reviewed By: javache Differential Revision: D58537536 fbshipit-source-id: d0e424df708ec35b014f5cecda11e8756e8f4346
This commit is contained in:
committed by
Facebook GitHub Bot
parent
74d030de70
commit
e78742a9d8
+3
@@ -1073,6 +1073,9 @@ public class ReactHostImpl implements ReactHost {
|
||||
getOrCreateReactHostInspectorTarget());
|
||||
mReactInstance = instance;
|
||||
|
||||
// eagerly initailize turbo modules
|
||||
instance.initializeEagerTurboModules();
|
||||
|
||||
MemoryPressureListener memoryPressureListener =
|
||||
createMemoryPressureListener(instance);
|
||||
mMemoryPressureListener = memoryPressureListener;
|
||||
|
||||
+7
-5
@@ -198,11 +198,6 @@ final class ReactInstance {
|
||||
getJSCallInvokerHolder(),
|
||||
getNativeMethodCallInvokerHolder());
|
||||
|
||||
// Eagerly initialize TurboModules
|
||||
for (String moduleName : mTurboModuleManager.getEagerInitModuleNames()) {
|
||||
mTurboModuleManager.getModule(moduleName);
|
||||
}
|
||||
|
||||
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
|
||||
// Set up Fabric
|
||||
@@ -300,6 +295,13 @@ final class ReactInstance {
|
||||
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
|
||||
void initializeEagerTurboModules() {
|
||||
// Eagerly initialize TurboModules
|
||||
for (String moduleName : mTurboModuleManager.getEagerInitModuleNames()) {
|
||||
mTurboModuleManager.getModule(moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized void loadLibraryIfNeeded() {
|
||||
if (!sIsLibraryLoaded) {
|
||||
SoLoader.loadLibrary("rninstance");
|
||||
|
||||
Reference in New Issue
Block a user