Permalink
Browse files

launch running setupReactContext in BG

Reviewed By: alexeylang

Differential Revision: D5185868

fbshipit-source-id: b7fcf289dca859d169eceb274f1fcd68e49a56d1
  • Loading branch information...
AaaChiuuu authored and facebook-github-bot committed Jul 15, 2017
1 parent 636a21b commit a3142f50ede98e7ad4a1f93cb135dd2c07a26b1f
@@ -146,7 +146,6 @@
private final JSCConfig mJSCConfig;
private final boolean mLazyNativeModulesEnabled;
private final boolean mLazyViewManagersEnabled;
private final boolean mSetupReactContextInBackgroundEnabled;
private final boolean mUseSeparateUIBackgroundThread;
private final int mMinNumShakes;
@@ -221,7 +220,6 @@ public static ReactInstanceManagerBuilder builder() {
boolean lazyNativeModulesEnabled,
boolean lazyViewManagersEnabled,
@Nullable DevBundleDownloadListener devBundleDownloadListener,
boolean setupReactContextInBackgroundEnabled,
boolean useSeparateUIBackgroundThread,
int minNumShakes,
boolean splitPackagesEnabled,
@@ -254,7 +252,6 @@ public static ReactInstanceManagerBuilder builder() {
mJSCConfig = jscConfig;
mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
mLazyViewManagersEnabled = lazyViewManagersEnabled;
mSetupReactContextInBackgroundEnabled = setupReactContextInBackgroundEnabled;
mUseSeparateUIBackgroundThread = useSeparateUIBackgroundThread;
mMinNumShakes = minNumShakes;
@@ -806,9 +803,7 @@ public void run() {
initParams.getJsExecutorFactory().create(),
initParams.getJsBundleLoader());
if (mSetupReactContextInBackgroundEnabled) {
mCreateReactContextThread = null;
}
mCreateReactContextThread = null;
ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
final Runnable maybeRecreateReactContextRunnable = new Runnable() {
@Override
@@ -822,28 +817,16 @@ public void run() {
Runnable setupReactContextRunnable = new Runnable() {
@Override
public void run() {
if (!mSetupReactContextInBackgroundEnabled) {
mCreateReactContextThread = null;
}
try {
setupReactContext(reactApplicationContext);
if (!mSetupReactContextInBackgroundEnabled) {
maybeRecreateReactContextRunnable.run();
}
} catch (Exception e) {
mDevSupportManager.handleException(e);
}
}
};
if (mSetupReactContextInBackgroundEnabled) {
reactApplicationContext.runOnNativeModulesQueueThread(setupReactContextRunnable);
UiThreadUtil.runOnUiThread(maybeRecreateReactContextRunnable);
} else {
UiThreadUtil.runOnUiThread(setupReactContextRunnable);
}
reactApplicationContext.runOnNativeModulesQueueThread(setupReactContextRunnable);
UiThreadUtil.runOnUiThread(maybeRecreateReactContextRunnable);
} catch (Exception e) {
mDevSupportManager.handleException(e);
}
@@ -857,9 +840,6 @@ private void setupReactContext(ReactApplicationContext reactContext) {
ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_END);
ReactMarker.logMarker(SETUP_REACT_CONTEXT_START);
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext");
if (!mSetupReactContextInBackgroundEnabled) {
UiThreadUtil.assertOnUiThread();
}
mCurrentReactContext = Assertions.assertNotNull(reactContext);
CatalystInstance catalystInstance =
Assertions.assertNotNull(reactContext.getCatalystInstance());
@@ -913,10 +893,6 @@ private void attachRootViewToInstance(
CatalystInstance catalystInstance) {
Log.d(ReactConstants.TAG, "ReactInstanceManager.attachRootViewToInstance()");
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachRootViewToInstance");
if (!mSetupReactContextInBackgroundEnabled) {
UiThreadUtil.assertOnUiThread();
}
UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
final int rootTag = uiManagerModule.addRootView(rootView);
rootView.setRootViewTag(rootTag);
@@ -11,13 +11,13 @@
import android.app.Application;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.devsupport.RedBoxHandler;
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.devsupport.RedBoxHandler;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.uimanager.UIImplementationProvider;
@@ -44,7 +44,6 @@
protected boolean mLazyNativeModulesEnabled;
protected boolean mLazyViewManagersEnabled;
protected @Nullable DevBundleDownloadListener mDevBundleDownloadListener;
protected boolean mSetupReactContextInBackground;
protected boolean mUseSeparateUIBackgroundThread;
protected int mMinNumShakes = 1;
protected boolean mEnableSplitPackage;
@@ -193,17 +192,12 @@ public ReactInstanceManagerBuilder setLazyViewManagersEnabled(boolean lazyViewMa
return this;
}
public ReactInstanceManagerBuilder setDevBundleDownloadListener(@Nullable DevBundleDownloadListener listener) {
public ReactInstanceManagerBuilder setDevBundleDownloadListener(
@Nullable DevBundleDownloadListener listener) {
mDevBundleDownloadListener = listener;
return this;
}
public ReactInstanceManagerBuilder setSetupReactContextInBackgroundEnabled(
boolean setupReactContextInBackground) {
mSetupReactContextInBackground = setupReactContextInBackground;
return this;
}
public ReactInstanceManagerBuilder setUseSeparateUIBackgroundThread(
boolean useSeparateUIBackgroundThread) {
mUseSeparateUIBackgroundThread = useSeparateUIBackgroundThread;
@@ -272,7 +266,6 @@ public ReactInstanceManager build() {
mLazyNativeModulesEnabled,
mLazyViewManagersEnabled,
mDevBundleDownloadListener,
mSetupReactContextInBackground,
mUseSeparateUIBackgroundThread,
mMinNumShakes,
mEnableSplitPackage,

0 comments on commit a3142f5

Please sign in to comment.