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
This commit is contained in:
David Vacca
2020-12-04 19:55:54 -08:00
committed by Facebook GitHub Bot
parent 74a756846f
commit b636397a0d
@@ -41,6 +41,7 @@ import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Process;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import com.facebook.common.logging.FLog;
@@ -794,12 +795,15 @@ public class ReactInstanceManager {
mDevSupportManager.showDevOptionsDialog();
}
@ThreadConfined(UI)
private void clearReactRoot(ReactRoot reactRoot) {
UiThreadUtil.assertOnUiThread();
if (ReactFeatureFlags.enableStartSurfaceRaceConditionFix) {
reactRoot.getState().compareAndSet(ReactRoot.STATE_STARTED, ReactRoot.STATE_STOPPED);
}
reactRoot.getRootViewGroup().removeAllViews();
reactRoot.getRootViewGroup().setId(View.NO_ID);
ViewGroup rootViewGroup = reactRoot.getRootViewGroup();
rootViewGroup.removeAllViews();
rootViewGroup.setId(View.NO_ID);
}
/**
@@ -1222,6 +1226,7 @@ public class ReactInstanceManager {
}
}
@ThreadConfined(UI)
private void tearDownReactContext(ReactContext reactContext) {
FLog.d(ReactConstants.TAG, "ReactInstanceManager.tearDownReactContext()");
UiThreadUtil.assertOnUiThread();