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
10 changes: 0 additions & 10 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,6 @@ public final class com/facebook/react/bridge/ScrollEndedListeners {
}

public abstract interface class com/facebook/react/bridge/UIManager : com/facebook/react/bridge/PerformanceCounter {
public abstract fun addRootView (Landroid/view/View;Lcom/facebook/react/bridge/WritableMap;)I
public abstract fun addUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
public abstract fun dispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
public abstract fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
Expand All @@ -1378,8 +1377,6 @@ public abstract interface class com/facebook/react/bridge/UIManager : com/facebo
public abstract fun resolveCustomDirectEventName (Ljava/lang/String;)Ljava/lang/String;
public abstract fun resolveView (I)Landroid/view/View;
public abstract fun sendAccessibilityEvent (II)V
public abstract fun startSurface (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;II)I
public abstract fun stopSurface (I)V
public abstract fun sweepActiveTouchForTag (II)V
public abstract fun synchronouslyUpdateViewOnUIThread (ILcom/facebook/react/bridge/ReadableMap;)V
public abstract fun updateRootLayoutSpecs (IIIII)V
Expand Down Expand Up @@ -2248,7 +2245,6 @@ public class com/facebook/react/fabric/FabricUIManager : com/facebook/react/brid
public static final field TAG Ljava/lang/String;
public field mDevToolsReactPerfLogger Lcom/facebook/react/fabric/DevToolsReactPerfLogger;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/react/uimanager/ViewManagerRegistry;Lcom/facebook/react/uimanager/events/BatchEventDispatchedListener;)V
public fun addRootView (Landroid/view/View;Lcom/facebook/react/bridge/WritableMap;)I
public fun addUIBlock (Lcom/facebook/react/fabric/interop/UIBlock;)V
public fun addUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
public fun attachRootView (Lcom/facebook/react/fabric/SurfaceHandlerBinding;Landroid/view/View;)V
Expand Down Expand Up @@ -2286,9 +2282,7 @@ public class com/facebook/react/fabric/FabricUIManager : com/facebook/react/brid
public fun sendAccessibilityEvent (II)V
public fun sendAccessibilityEventFromJS (IILjava/lang/String;)V
public fun setJSResponder (IIIZ)V
public fun startSurface (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;II)I
public fun startSurface (Lcom/facebook/react/fabric/SurfaceHandlerBinding;Landroid/content/Context;Landroid/view/View;)V
public fun stopSurface (I)V
public fun stopSurface (Lcom/facebook/react/fabric/SurfaceHandlerBinding;)V
public fun sweepActiveTouchForTag (II)V
public fun synchronouslyUpdateViewOnUIThread (ILcom/facebook/react/bridge/ReadableMap;)V
Expand Down Expand Up @@ -4241,8 +4235,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
public static final field TAG Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/react/uimanager/ViewManagerResolver;I)V
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Ljava/util/List;I)V
public fun addRootView (Landroid/view/View;)I
public fun addRootView (Landroid/view/View;Lcom/facebook/react/bridge/WritableMap;)I
public fun addUIBlock (Lcom/facebook/react/uimanager/UIBlock;)V
public fun addUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
public fun clearJSResponder ()V
Expand Down Expand Up @@ -4287,8 +4279,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
public fun setJSResponder (IZ)V
public fun setLayoutAnimationEnabledExperimental (Z)V
public fun setViewLocalData (ILjava/lang/Object;)V
public fun startSurface (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;II)I
public fun stopSurface (I)V
public fun sweepActiveTouchForTag (II)V
public fun synchronouslyUpdateViewOnUIThread (ILcom/facebook/react/bridge/ReadableMap;)V
public fun updateInsetsPadding (IIIII)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
package com.facebook.react;

import static com.facebook.infer.annotation.ThreadConfined.UI;
import static com.facebook.react.bridge.ReactMarkerConstants.ATTACH_MEASURED_ROOT_VIEWS_END;
import static com.facebook.react.bridge.ReactMarkerConstants.ATTACH_MEASURED_ROOT_VIEWS_START;
import static com.facebook.react.bridge.ReactMarkerConstants.CHANGE_THREAD_PRIORITY;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_VIEW_MANAGERS_END;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_VIEW_MANAGERS_START;
Expand All @@ -20,7 +18,6 @@
import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_END;
import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_START;
import static com.facebook.react.bridge.ReactMarkerConstants.VM_INIT;
import static com.facebook.react.uimanager.common.UIManagerType.FABRIC;
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT;

import android.annotation.SuppressLint;
Expand All @@ -42,7 +39,6 @@
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.ThreadConfined;
import com.facebook.infer.annotation.ThreadSafe;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.bridge.JSExceptionHandler;
Expand All @@ -54,10 +50,8 @@
import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.react.bridge.ReactNoCrashSoftException;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.bridge.UIManagerProvider;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.SurfaceDelegateFactory;
Expand All @@ -82,8 +76,6 @@
import com.facebook.react.packagerconnection.RequestHandler;
import com.facebook.react.uimanager.DisplayMetricsHolder;
import com.facebook.react.uimanager.ReactRoot;
import com.facebook.react.uimanager.ReactStage;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
import com.facebook.soloader.SoLoader;
Expand Down Expand Up @@ -766,7 +758,7 @@ public void destroy() {
synchronized (mReactContextLock) {
if (mCurrentReactContext != null) {
for (ReactRoot reactRoot : mAttachedReactRoots) {
detachRootViewFromInstance(reactRoot, mCurrentReactContext);
detachRootViewFromInstance(reactRoot);
}

mCurrentReactContext.destroy();
Expand Down Expand Up @@ -910,14 +902,6 @@ public void attachRootView(ReactRoot reactRoot) {
} else {
FLog.e(ReactConstants.TAG, "ReactRoot was attached multiple times");
}

// If react context is being created in the background, JS application will be started
// automatically when creation completes, as reactRoot is part of the attached
// reactRoot list.
ReactContext currentContext = getCurrentReactContext();
if (mCreateReactContextThread == null && currentContext != null) {
attachRootViewToInstance(reactRoot);
}
}
}

Expand All @@ -935,11 +919,7 @@ public void detachRootView(ReactRoot reactRoot) {
if (!mAttachedReactRoots.remove(reactRoot)) {
return;
}

ReactContext reactContext = mCurrentReactContext;
if (reactContext != null && reactContext.hasActiveReactInstance()) {
detachRootViewFromInstance(reactRoot, reactContext);
}
clearReactRoot(reactRoot);
}

/** Uses configured {@link ReactPackage} instances to create all view managers. */
Expand Down Expand Up @@ -1217,12 +1197,6 @@ private void setupReactContext(final ReactApplicationContext reactContext) {

mDevSupportManager.onNewReactContextCreated(reactContext);
mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);

ReactMarker.logMarker(ATTACH_MEASURED_ROOT_VIEWS_START);
for (ReactRoot reactRoot : mAttachedReactRoots) {
attachRootViewToInstance(reactRoot);
}
ReactMarker.logMarker(ATTACH_MEASURED_ROOT_VIEWS_END);
}

// There is a race condition here - `finalListeners` can contain null entries
Expand Down Expand Up @@ -1260,48 +1234,7 @@ private void setupReactContext(final ReactApplicationContext reactContext) {
ReactMarker.logMarker(ReactMarkerConstants.REACT_BRIDGE_LOADING_END);
}

private void attachRootViewToInstance(final ReactRoot reactRoot) {
FLog.d(ReactConstants.TAG, "ReactInstanceManager.attachRootViewToInstance()");
if (!reactRoot.getState().compareAndSet(ReactRoot.STATE_STOPPED, ReactRoot.STATE_STARTED)) {
// Already started
return;
}

Systrace.beginSection(TRACE_TAG_REACT, "attachRootViewToInstance");

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

// If we can't get a UIManager something has probably gone horribly wrong
if (uiManager == null) {
throw new IllegalStateException(
"Unable to attach a rootView to ReactInstance when UIManager is not properly"
+ " initialized.");
}

@Nullable Bundle initialProperties = reactRoot.getAppProperties();

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(
() -> {
Systrace.endAsyncSection(
TRACE_TAG_REACT, "pre_rootView.onAttachedToReactInstance", rootTag);
reactRoot.onStage(ReactStage.ON_ATTACH_TO_INSTANCE);
});
Systrace.endSection(TRACE_TAG_REACT);
}

private void detachRootViewFromInstance(ReactRoot reactRoot, ReactContext reactContext) {
private void detachRootViewFromInstance(ReactRoot reactRoot) {
FLog.d(ReactConstants.TAG, "ReactInstanceManager.detachRootViewFromInstance()");
UiThreadUtil.assertOnUiThread();

Expand All @@ -1310,27 +1243,6 @@ private void detachRootViewFromInstance(ReactRoot reactRoot, ReactContext reactC
return;
}

// 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, FABRIC);
if (uiManager != null) {
uiManager.stopSurface(surfaceId);
} else {
FLog.w(ReactConstants.TAG, "Failed to stop surface, UIManager has already gone away");
}
} else {
ReactSoftExceptionLogger.logSoftException(
TAG,
new RuntimeException(
"detachRootViewFromInstance called with ReactRootView with invalid id"));
}

clearReactRoot(reactRoot);
}

Expand All @@ -1344,7 +1256,7 @@ private void tearDownReactContext(ReactContext reactContext) {

synchronized (mAttachedReactRoots) {
for (ReactRoot reactRoot : mAttachedReactRoots) {
detachRootViewFromInstance(reactRoot, reactContext);
detachRootViewFromInstance(reactRoot);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,13 @@
package com.facebook.react.bridge

import android.view.View
import androidx.annotation.AnyThread
import androidx.annotation.UiThread
import com.facebook.infer.annotation.ThreadConfined
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.uimanager.events.EventDispatcher

@OptIn(UnstableReactNativeAPI::class)
public interface UIManager : PerformanceCounter {
/** Registers a new root view. @Deprecated call startSurface instead */
@UiThread
@ThreadConfined(ThreadConfined.UI)
@Deprecated("")
public fun <T : View> addRootView(rootView: T, initialProps: WritableMap?): Int

/** Registers a new root view with width and height. */
@AnyThread
public fun <T : View?> startSurface(
rootView: T,
moduleName: String,
initialProps: WritableMap?,
widthMeasureSpec: Int,
heightMeasureSpec: Int,
): Int

/**
* Stop a surface from running in JS and clears up native memory usage. Assumes that the native
* View hierarchy has already been cleaned up. Fabric-only.
*/
@AnyThread public fun stopSurface(surfaceId: Int)

/**
* Updates the layout specs of the RootShadowNode based on the Measure specs received by
* parameters. offsetX and offsetY are the position of the RootView within the screen.
Expand Down
Loading
Loading