From 49a911fab4db41dc44dfd56e1f4fef2b9c309e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Thu, 13 Jun 2024 12:49:25 -0700 Subject: [PATCH] Back out "Revert D58459930: [react-native][PR] Add ReactMarkerConstants.CONTENT_APPEARED support on Android" Summary: Changelog: [ANDROID] [ADDED] - Add the ReactMarkerConstants.CONTENT_APPEARED support on Android in bridgeless mode. This re-applies https://github.com/facebook/react-native/pull/43620 which was reverted because a CI job started failing because we forgot to update `packages/react-native/ReactAndroid/api/ReactAndroid.api`. Reviewed By: cortinico Differential Revision: D58535868 fbshipit-source-id: 9eec33c5e798850a7434a6c391abf2fc3fc9d0a6 --- .../src/main/java/com/facebook/react/ReactRootView.java | 6 ++---- .../main/java/com/facebook/react/runtime/ReactHostImpl.java | 4 +++- .../java/com/facebook/react/runtime/ReactSurfaceView.kt | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 2bc4bab1bfb..58570c0bcfc 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -434,10 +434,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { if (mShouldLogContentAppeared) { mShouldLogContentAppeared = false; - - if (mJSModuleName != null) { - ReactMarker.logMarker(ReactMarkerConstants.CONTENT_APPEARED, mJSModuleName, mRootViewTag); - } + String jsModuleName = getJSModuleName(); + ReactMarker.logMarker(ReactMarkerConstants.CONTENT_APPEARED, jsModuleName, mRootViewTag); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java index baa00162754..1c0116d367e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java @@ -375,7 +375,9 @@ public class ReactHostImpl implements ReactHost { public ReactSurface createSurface( Context context, String moduleName, @Nullable Bundle initialProps) { ReactSurfaceImpl surface = new ReactSurfaceImpl(context, moduleName, initialProps); - surface.attachView(new ReactSurfaceView(context, surface)); + ReactSurfaceView surfaceView = new ReactSurfaceView(context, surface); + surfaceView.setShouldLogContentAppeared(true); + surface.attachView(surfaceView); surface.attach(this); return surface; } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt index 3ae5aba924b..bc979de9c32 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt @@ -134,6 +134,8 @@ public class ReactSurfaceView(context: Context?, private val surface: ReactSurfa // This surface view is always on Fabric. @UIManagerType override fun getUIManagerType(): Int = UIManagerType.FABRIC + override fun getJSModuleName(): String = surface.moduleName + override fun dispatchJSTouchEvent(event: MotionEvent) { val eventDispatcher = surface.eventDispatcher if (eventDispatcher != null) {