mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2ecdb69b74
commit
d71a0be6fa
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user