Skip to content

Commit b636397

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Add annotations and thread safety checks in the initialization / teardown methods of ReactInstanceManager
Summary: Add annotations and thread safety checks in the initialization / teardown methods of ReactInstanceManager changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D25321380 fbshipit-source-id: 113a7c224ae04009cda9e15676208abcef6af211
1 parent 74a7568 commit b636397

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import android.os.Bundle;
4242
import android.os.Process;
4343
import android.view.View;
44+
import android.view.ViewGroup;
4445
import androidx.annotation.Nullable;
4546
import androidx.core.view.ViewCompat;
4647
import com.facebook.common.logging.FLog;
@@ -794,12 +795,15 @@ public void showDevOptionsDialog() {
794795
mDevSupportManager.showDevOptionsDialog();
795796
}
796797

798+
@ThreadConfined(UI)
797799
private void clearReactRoot(ReactRoot reactRoot) {
800+
UiThreadUtil.assertOnUiThread();
798801
if (ReactFeatureFlags.enableStartSurfaceRaceConditionFix) {
799802
reactRoot.getState().compareAndSet(ReactRoot.STATE_STARTED, ReactRoot.STATE_STOPPED);
800803
}
801-
reactRoot.getRootViewGroup().removeAllViews();
802-
reactRoot.getRootViewGroup().setId(View.NO_ID);
804+
ViewGroup rootViewGroup = reactRoot.getRootViewGroup();
805+
rootViewGroup.removeAllViews();
806+
rootViewGroup.setId(View.NO_ID);
803807
}
804808

805809
/**
@@ -1222,6 +1226,7 @@ private void detachViewFromInstance(ReactRoot reactRoot, CatalystInstance cataly
12221226
}
12231227
}
12241228

1229+
@ThreadConfined(UI)
12251230
private void tearDownReactContext(ReactContext reactContext) {
12261231
FLog.d(ReactConstants.TAG, "ReactInstanceManager.tearDownReactContext()");
12271232
UiThreadUtil.assertOnUiThread();

0 commit comments

Comments
 (0)