Skip to content

Commit

Permalink
Release fix for race condition on startSurface
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvacca authored and facebook-github-bot committed Feb 16, 2021
1 parent 2ecdb69 commit d71a0be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,7 @@ public void showDevOptionsDialog() {
@ThreadConfined(UI)
private void clearReactRoot(ReactRoot reactRoot) {
UiThreadUtil.assertOnUiThread();
if (ReactFeatureFlags.enableStartSurfaceRaceConditionFix) {
reactRoot.getState().compareAndSet(ReactRoot.STATE_STARTED, ReactRoot.STATE_STOPPED);
}
reactRoot.getState().compareAndSet(ReactRoot.STATE_STARTED, ReactRoot.STATE_STOPPED);
ViewGroup rootViewGroup = reactRoot.getRootViewGroup();
rootViewGroup.removeAllViews();
rootViewGroup.setId(View.NO_ID);
Expand All @@ -826,12 +824,7 @@ public void attachRootView(ReactRoot reactRoot) {
// Calling clearReactRoot is necessary to initialize the Id on reactRoot
// This is necessary independently if the RN Bridge has been initialized or not.
// Ideally reactRoot should be initialized with id == NO_ID
if (ReactFeatureFlags.enableStartSurfaceRaceConditionFix) {
if (mAttachedReactRoots.add(reactRoot)) {
clearReactRoot(reactRoot);
}
} else {
mAttachedReactRoots.add(reactRoot);
if (mAttachedReactRoots.add(reactRoot)) {
clearReactRoot(reactRoot);
}

Expand All @@ -840,8 +833,7 @@ public void attachRootView(ReactRoot reactRoot) {
// reactRoot reactRoot list.
ReactContext currentContext = getCurrentReactContext();
if (mCreateReactContextThread == null && currentContext != null) {
if (!ReactFeatureFlags.enableStartSurfaceRaceConditionFix
|| reactRoot.getState().compareAndSet(ReactRoot.STATE_STOPPED, ReactRoot.STATE_STARTED)) {
if (reactRoot.getState().compareAndSet(ReactRoot.STATE_STOPPED, ReactRoot.STATE_STARTED)) {
attachRootViewToInstance(reactRoot);
}
}
Expand Down Expand Up @@ -1110,10 +1102,7 @@ private void setupReactContext(final ReactApplicationContext reactContext) {

ReactMarker.logMarker(ATTACH_MEASURED_ROOT_VIEWS_START);
for (ReactRoot reactRoot : mAttachedReactRoots) {
if (!ReactFeatureFlags.enableStartSurfaceRaceConditionFix
|| reactRoot
.getState()
.compareAndSet(ReactRoot.STATE_STOPPED, ReactRoot.STATE_STARTED)) {
if (reactRoot.getState().compareAndSet(ReactRoot.STATE_STOPPED, ReactRoot.STATE_STARTED)) {
attachRootViewToInstance(reactRoot);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ public class ReactFeatureFlags {
/** Feature flag to configure eager initialization of Fabric */
public static boolean eagerInitializeFabric = false;

/**
* Fixes race-condition in the initialization of RN surface. TODO T78832286: remove this flag once
* we verify the fix is correct in production
*/
public static boolean enableStartSurfaceRaceConditionFix = false;

/** Enables Static ViewConfig in RN Android native code. */
public static boolean enableExperimentalStaticViewConfigs = false;

Expand Down

0 comments on commit d71a0be

Please sign in to comment.