From d71a0be6fa0ed4d38d58f1bce30e532581a7bfca Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 15 Feb 2021 20:59:41 -0800 Subject: [PATCH] Release fix for race condition on startSurface Summary: This bug doesn't reproduce anymore in v301+. MC has been enabled since december https://www.internalfb.com/intern/logview/details/facebook_android_javascripterrors/419f8892e7b1a02f205810219ddfc299/trends?selected-logview-tab=All%20Traces&drillstate={%22start%22:%22Thu,%2028%20Jan%202021%2000:59:54%20-0800%22,%22end%22:%22Thu,%2011%20Feb%202021%2000:59:54%20-0800%22,%22constraints%22:[{%22col%22:%22mid%22,%22op%22:%22==%22,%22vals%22:[%22419f8892e7b1a02f205810219ddfc299%22]}],%22context%22:%22facebook_android_javascripterrors%22,%22metric%22:%22count%22} changelog: [internal] internal Reviewed By: ShikaSD Differential Revision: D26398484 fbshipit-source-id: ca85ca211f1a38aa2691f150956a27c878d243bc --- .../facebook/react/ReactInstanceManager.java | 19 ++++--------------- .../react/config/ReactFeatureFlags.java | 6 ------ 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 0a317af7e85..69c52b585b6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -803,9 +803,7 @@ public class ReactInstanceManager { @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); @@ -826,12 +824,7 @@ public class ReactInstanceManager { // 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); } @@ -840,8 +833,7 @@ public class ReactInstanceManager { // 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); } } @@ -1110,10 +1102,7 @@ public class ReactInstanceManager { 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); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 68afd39bb41..c195ab8e7bc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -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;