Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -3052,7 +3052,6 @@ public final class com/facebook/react/runtime/ReactSurfaceView : com/facebook/re
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactSurfaceImpl;)V
public fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
public fun getJSModuleName ()Ljava/lang/String;
public fun getUIManagerType ()I
public fun handleException (Ljava/lang/Throwable;)V
public fun hasActiveReactContext ()Z
public fun hasActiveReactInstance ()Z
Expand All @@ -3061,7 +3060,6 @@ public final class com/facebook/react/runtime/ReactSurfaceView : com/facebook/re
public fun onChildStartedNativeGesture (Landroid/view/View;Landroid/view/MotionEvent;)V
public fun requestChildFocus (Landroid/view/View;Landroid/view/View;)V
public fun requestDisallowInterceptTouchEvent (Z)V
public fun setIsFabric (Z)V
}

public abstract class com/facebook/react/runtime/cxxreactpackage/CxxReactPackage {
Expand Down Expand Up @@ -5506,7 +5504,6 @@ public final class com/facebook/react/views/scroll/ReactHorizontalScrollContaine
public static final field Companion Lcom/facebook/react/views/scroll/ReactHorizontalScrollContainerViewManager$Companion;
public static final field REACT_CLASS Ljava/lang/String;
public fun <init> ()V
public synthetic fun createViewInstance (ILcom/facebook/react/uimanager/ThemedReactContext;Lcom/facebook/react/uimanager/ReactStylesDiffMap;Lcom/facebook/react/uimanager/StateWrapper;)Landroid/view/View;
public synthetic fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Landroid/view/View;
public fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Lcom/facebook/react/views/view/ReactViewGroup;
public fun getName ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import com.facebook.react.internal.ChoreographerProvider;
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags;
import com.facebook.react.modules.appearance.AppearanceModule;
import com.facebook.react.modules.appregistry.AppRegistry;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.core.ReactChoreographer;
Expand Down Expand Up @@ -767,10 +766,7 @@ public void destroy() {
synchronized (mReactContextLock) {
if (mCurrentReactContext != null) {
for (ReactRoot reactRoot : mAttachedReactRoots) {
// Fabric surfaces must be cleaned up when React Native is destroyed.
if (reactRoot.getUIManagerType() == UIManagerType.FABRIC) {
detachRootViewFromInstance(reactRoot, mCurrentReactContext);
}
detachRootViewFromInstance(reactRoot, mCurrentReactContext);
}

mCurrentReactContext.destroy();
Expand Down Expand Up @@ -1271,9 +1267,7 @@ private void attachRootViewToInstance(final ReactRoot reactRoot) {

Systrace.beginSection(TRACE_TAG_REACT, "attachRootViewToInstance");

@Nullable
UIManager uiManager =
UIManagerHelper.getUIManager(mCurrentReactContext, reactRoot.getUIManagerType());
@Nullable UIManager uiManager = UIManagerHelper.getUIManager(mCurrentReactContext, FABRIC);

// If we can't get a UIManager something has probably gone horribly wrong
if (uiManager == null) {
Expand All @@ -1284,28 +1278,16 @@ private void attachRootViewToInstance(final ReactRoot reactRoot) {

@Nullable Bundle initialProperties = reactRoot.getAppProperties();

final int rootTag;
if (reactRoot.getUIManagerType() == FABRIC) {
rootTag =
uiManager.startSurface(
reactRoot.getRootViewGroup(),
reactRoot.getJSModuleName(),
initialProperties == null
? new WritableNativeMap()
: Arguments.fromBundle(initialProperties),
reactRoot.getWidthMeasureSpec(),
reactRoot.getHeightMeasureSpec());
reactRoot.setShouldLogContentAppeared(true);
} else {
rootTag =
uiManager.addRootView(
reactRoot.getRootViewGroup(),
initialProperties == null
? new WritableNativeMap()
: Arguments.fromBundle(initialProperties));
reactRoot.setRootViewTag(rootTag);
reactRoot.runApplication();
}
final int rootTag =
uiManager.startSurface(
reactRoot.getRootViewGroup(),
reactRoot.getJSModuleName(),
initialProperties == null
? new WritableNativeMap()
: Arguments.fromBundle(initialProperties),
reactRoot.getWidthMeasureSpec(),
reactRoot.getHeightMeasureSpec());
reactRoot.setShouldLogContentAppeared(true);

Systrace.beginAsyncSection(TRACE_TAG_REACT, "pre_rootView.onAttachedToReactInstance", rootTag);
UiThreadUtil.runOnUiThread(
Expand All @@ -1326,36 +1308,29 @@ private void detachRootViewFromInstance(ReactRoot reactRoot, ReactContext reactC
return;
}

@UIManagerType int uiManagerType = reactRoot.getUIManagerType();
if (uiManagerType == UIManagerType.FABRIC) {
// Stop surface in Fabric.
// Calling FabricUIManager.stopSurface causes the C++ Binding.stopSurface
// to be called synchronously over the JNI, which causes an empty tree
// to be committed via the Scheduler, which will cause mounting instructions
// to be queued up and synchronously executed to delete and remove
// all the views in the hierarchy.
final int surfaceId = reactRoot.getRootViewTag();
if (surfaceId != View.NO_ID) {
UIManager uiManager = UIManagerHelper.getUIManager(reactContext, uiManagerType);
if (uiManager != null) {
uiManager.stopSurface(surfaceId);
} else {
FLog.w(ReactConstants.TAG, "Failed to stop surface, UIManager has already gone away");
}
@UIManagerType int uiManagerType = FABRIC;
// Stop surface in Fabric.
// Calling FabricUIManager.stopSurface causes the C++ Binding.stopSurface
// to be called synchronously over the JNI, which causes an empty tree
// to be committed via the Scheduler, which will cause mounting instructions
// to be queued up and synchronously executed to delete and remove
// all the views in the hierarchy.
final int surfaceId = reactRoot.getRootViewTag();
if (surfaceId != View.NO_ID) {
UIManager uiManager = UIManagerHelper.getUIManager(reactContext, uiManagerType);
if (uiManager != null) {
uiManager.stopSurface(surfaceId);
} else {
ReactSoftExceptionLogger.logSoftException(
TAG,
new RuntimeException(
"detachRootViewFromInstance called with ReactRootView with invalid id"));
FLog.w(ReactConstants.TAG, "Failed to stop surface, UIManager has already gone away");
}

clearReactRoot(reactRoot);
} else {
reactContext
.getCatalystInstance()
.getJSModule(AppRegistry.class)
.unmountApplicationComponentAtRootTag(reactRoot.getRootViewTag());
ReactSoftExceptionLogger.logSoftException(
TAG,
new RuntimeException(
"detachRootViewFromInstance called with ReactRootView with invalid id"));
}

clearReactRoot(reactRoot);
}

@ThreadConfined(UI)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import static com.facebook.infer.annotation.ThreadConfined.UI;
import static com.facebook.react.uimanager.BlendModeHelper.needsIsolatedLayer;
import static com.facebook.react.uimanager.common.UIManagerType.FABRIC;
import static com.facebook.react.uimanager.common.UIManagerType.LEGACY;
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT;

import android.annotation.SuppressLint;
Expand Down Expand Up @@ -52,6 +51,7 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.common.annotations.internal.LegacyArchitecture;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.modules.appregistry.AppRegistry;
Expand All @@ -70,7 +70,6 @@
import com.facebook.react.uimanager.RootViewUtil;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.common.UIManagerType;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -117,7 +116,6 @@ public interface ReactRootViewEventListener {
private int mLastHeight = 0;
private int mLastOffsetX = Integer.MIN_VALUE;
private int mLastOffsetY = Integer.MIN_VALUE;
private @UIManagerType int mUIManagerType = LEGACY;
private final AtomicInteger mState = new AtomicInteger(STATE_STOPPED);

public ReactRootView(Context context) {
Expand Down Expand Up @@ -308,9 +306,7 @@ protected void dispatchDraw(Canvas canvas) {
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {

BlendMode mixBlendMode = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
&& ViewUtil.getUIManagerType(this) == UIManagerType.FABRIC
&& needsIsolatedLayer(this)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && needsIsolatedLayer(this)) {
mixBlendMode = (BlendMode) child.getTag(R.id.mix_blend_mode);
if (mixBlendMode != null) {
Paint p = new Paint();
Expand Down Expand Up @@ -475,7 +471,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
}

private boolean isFabric() {
return getUIManagerType() == FABRIC;
return true;
}

@Override
Expand Down Expand Up @@ -647,9 +643,7 @@ private void updateRootLayoutSpecs(
final ReactContext reactApplicationContext = getCurrentReactContext();

if (reactApplicationContext != null) {
@Nullable
UIManager uiManager =
UIManagerHelper.getUIManager(reactApplicationContext, getUIManagerType());
@Nullable UIManager uiManager = UIManagerHelper.getUIManager(reactApplicationContext, FABRIC);
// Ignore calling updateRootLayoutSpecs if UIManager is not properly initialized.
if (uiManager != null) {
// In Fabric only, get position of view within screen
Expand Down Expand Up @@ -892,15 +886,18 @@ public void handleException(final Throwable t) {
getCurrentReactContext().handleException(e);
}

@LegacyArchitecture
@Deprecated
public void setIsFabric(boolean isFabric) {
mUIManagerType = isFabric ? FABRIC : LEGACY;
/* noop */
}

@Override
public @UIManagerType int getUIManagerType() {
return mUIManagerType;
return FABRIC;
}

@LegacyArchitecture
@Nullable
public ReactInstanceManager getReactInstanceManager() {
return mReactInstanceManager;
Expand Down
Loading
Loading