Skip to content

Commit c8d823b

Browse files
samklinefacebook-github-bot
authored andcommitted
Reset ReactInstanceManager state on failure to allow retries (#32901)
Summary: This fixes #32898 by reseting ReactInstanceManager state when `createReactContext` throws. By resetting the state, we allow future attempts at creating the React context. ## Changelog [Android] [Fixed] - Fixed empty screen after retrying a BundleDownloader failure in dev mode Pull Request resolved: #32901 Test Plan: Go through the steps to reproduce listed in #32898 and see that the React Native application starts. Reviewed By: cortinico Differential Revision: D33634178 Pulled By: ShikaSD fbshipit-source-id: e54d12d5f33c9c7c0ca213113871b88c2f1dc261
1 parent 3addafa commit c8d823b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -1103,14 +1103,22 @@ public void run() {
11031103
// create
11041104
mHasStartedCreatingInitialContext = true;
11051105

1106+
final ReactApplicationContext reactApplicationContext;
11061107
try {
11071108
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
11081109
ReactMarker.logMarker(VM_INIT);
1109-
final ReactApplicationContext reactApplicationContext =
1110+
reactApplicationContext =
11101111
createReactContext(
11111112
initParams.getJsExecutorFactory().create(),
11121113
initParams.getJsBundleLoader());
1113-
1114+
} catch (Exception e) {
1115+
// Reset state and bail out. This lets us try again later.
1116+
mHasStartedCreatingInitialContext = false;
1117+
mCreateReactContextThread = null;
1118+
mDevSupportManager.handleException(e);
1119+
return;
1120+
}
1121+
try {
11141122
mCreateReactContextThread = null;
11151123
ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
11161124
final Runnable maybeRecreateReactContextRunnable =

0 commit comments

Comments
 (0)