Skip to content

Commit

Permalink
Reset ReactInstanceManager state on failure
Browse files Browse the repository at this point in the history
When `ReactInstanceManager.createReactContext` fails, reset state to allow reloads; fixes facebook#32898
  • Loading branch information
samkline committed Jan 16, 2022
1 parent 1b31d6b commit e553d9a
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1058,14 +1058,22 @@ public void run() {
// create
mHasStartedCreatingInitialContext = true;

final ReactApplicationContext reactApplicationContext;
try {
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
ReactMarker.logMarker(VM_INIT);
final ReactApplicationContext reactApplicationContext =
createReactContext(
initParams.getJsExecutorFactory().create(),
initParams.getJsBundleLoader());

reactApplicationContext =
createReactContext(
initParams.getJsExecutorFactory().create(),
initParams.getJsBundleLoader());
} catch (Exception e) {
// Reset state and bail out. This lets us try again later.
mHasStartedCreatingInitialContext = false;
mCreateReactContextThread = null;
mDevSupportManager.handleException(e);
return;
}
try {
mCreateReactContextThread = null;
ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
final Runnable maybeRecreateReactContextRunnable =
Expand Down

0 comments on commit e553d9a

Please sign in to comment.