Skip to content

Commit

Permalink
Android TM: create TurboModuleManager earlier
Browse files Browse the repository at this point in the history
Summary: Some TM lookup from native will fail assertion if done too early, because TM Manager is not initialized yet.

Reviewed By: mdvacca

Differential Revision: D15872776

fbshipit-source-id: 7616c1424816f73a45aa1d9723e7807ae10392a7
  • Loading branch information
fkgozali authored and facebook-github-bot committed Jun 18, 2019
1 parent 2df9073 commit e6f28bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.facebook.react.bridge.CatalystInstanceImpl;
import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.bridge.JSIModulePackage;
import com.facebook.react.bridge.JSIModuleType;
import com.facebook.react.bridge.JavaJSExecutor;
import com.facebook.react.bridge.JavaScriptExecutor;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
Expand All @@ -71,6 +72,7 @@
import com.facebook.react.common.LifecycleState;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.devsupport.DevSupportManagerFactory;
import com.facebook.react.devsupport.ReactInstanceManagerDevHelper;
import com.facebook.react.devsupport.RedBoxHandler;
Expand Down Expand Up @@ -1006,6 +1008,11 @@ private void setupReactContext(final ReactApplicationContext reactContext) {
Assertions.assertNotNull(reactContext.getCatalystInstance());

catalystInstance.initialize();

if (ReactFeatureFlags.useTurboModules) {
catalystInstance.setTurboModuleManager(catalystInstance.getJSIModule(JSIModuleType.TurboModuleManager));
}

mDevSupportManager.onNewReactContextCreated(reactContext);
mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);
moveReactContextToCurrentLifecycleState();
Expand Down Expand Up @@ -1158,7 +1165,6 @@ private ReactApplicationContext createReactContext(
catalystInstance.addJSIModules(mJSIModulePackage
.getJSIModules(reactContext, catalystInstance.getJavaScriptContextHolder()));
}

if (mBridgeIdleDebugListener != null) {
catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);
}
Expand All @@ -1172,7 +1178,6 @@ private ReactApplicationContext createReactContext(

reactContext.initializeWithInstance(catalystInstance);


return reactContext;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ void callFunction(
* to CatalystInstance so that getNativeModule, hasNativeModule, and
* getNativeModules can also return TurboModules.
*/
void setTurboModuleRegistry(TurboModuleRegistry getter);
void setTurboModuleManager(JSIModule getter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ public void run() {
}
}

public void setTurboModuleRegistry(TurboModuleRegistry getter) {
mTurboModuleRegistry = getter;
public void setTurboModuleManager(JSIModule getter) {
mTurboModuleRegistry = (TurboModuleRegistry)getter;
}

private void decrementPendingJSCalls() {
Expand Down

0 comments on commit e6f28bb

Please sign in to comment.