diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 609d4db5958..1e65d218dcb 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -4328,7 +4328,6 @@ public class com/facebook/react/uimanager/UIImplementation { public fun setJSResponder (IZ)V public fun setLayoutAnimationEnabledExperimental (Z)V public fun setLayoutUpdateListener (Lcom/facebook/react/uimanager/UIImplementation$LayoutUpdateListener;)V - public fun setViewHierarchyUpdateDebugListener (Lcom/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener;)V public fun setViewLocalData (ILjava/lang/Object;)V public fun synchronouslyUpdateViewOnUIThread (ILcom/facebook/react/uimanager/ReactStylesDiffMap;)V public fun updateInsetsPadding (IIIII)V @@ -4412,7 +4411,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b public fun setChildren (ILcom/facebook/react/bridge/ReadableArray;)V public fun setJSResponder (IZ)V public fun setLayoutAnimationEnabledExperimental (Z)V - public fun setViewHierarchyUpdateDebugListener (Lcom/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener;)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 @@ -4460,7 +4458,6 @@ public class com/facebook/react/uimanager/UIViewOperationQueue { public fun isEmpty ()Z public fun prependUIBlock (Lcom/facebook/react/uimanager/UIBlock;)V public fun profileNextBatch ()V - public fun setViewHierarchyUpdateDebugListener (Lcom/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener;)V } public abstract interface class com/facebook/react/uimanager/UIViewOperationQueue$UIOperation { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DidJSUpdateUiDuringFrameDetector.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DidJSUpdateUiDuringFrameDetector.kt index 10ab8c2ca54..acd449315f4 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DidJSUpdateUiDuringFrameDetector.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DidJSUpdateUiDuringFrameDetector.kt @@ -12,7 +12,6 @@ package com.facebook.react.modules.debug import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener -import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener /** * Debug object that listens to bridge busy/idle events and UiManagerModule dispatches and uses it @@ -21,8 +20,7 @@ import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugL * [getDidJSHitFrameAndCleanup] should be called once per frame via a * [android.view.Choreographer.FrameCallback]. */ -internal class DidJSUpdateUiDuringFrameDetector : - NotThreadSafeBridgeIdleDebugListener, NotThreadSafeViewHierarchyUpdateDebugListener { +internal class DidJSUpdateUiDuringFrameDetector : NotThreadSafeBridgeIdleDebugListener { private val transitionToIdleEvents = ArrayList(20) private val transitionToBusyEvents = ArrayList(20) private val viewHierarchyUpdateEnqueuedEvents = ArrayList(20) @@ -44,16 +42,6 @@ internal class DidJSUpdateUiDuringFrameDetector : // do nothing } - @Synchronized - override fun onViewHierarchyUpdateEnqueued() { - viewHierarchyUpdateEnqueuedEvents.add(System.nanoTime()) - } - - @Synchronized - override fun onViewHierarchyUpdateFinished() { - viewHierarchyUpdateFinishedEvents.add(System.nanoTime()) - } - /** * Designed to be called from a [android.view.Choreographer.FrameCallback.doFrame] call. * diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/FpsDebugFrameCallback.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/FpsDebugFrameCallback.kt index 8fd2bd42291..47510d94dc7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/FpsDebugFrameCallback.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/FpsDebugFrameCallback.kt @@ -61,8 +61,6 @@ internal class FpsDebugFrameCallback(private val reactContext: ReactContext) : // removeBridgeIdleDebugListener for Bridgeless @Suppress("DEPRECATION") if (!ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) { - val uiManagerModule = - reactContext.getNativeModule(com.facebook.react.uimanager.UIManagerModule::class.java) if (!reactContext.isBridgeless) { reactContext.catalystInstance.addBridgeIdleDebugListener(didJSUpdateUiDuringFrameDetector) isRunningOnFabric = false @@ -71,7 +69,6 @@ internal class FpsDebugFrameCallback(private val reactContext: ReactContext) : // for Fabric or point users to use RNDT. isRunningOnFabric = true } - uiManagerModule?.setViewHierarchyUpdateDebugListener(didJSUpdateUiDuringFrameDetector) } this.targetFps = targetFps UiThreadUtil.runOnUiThread { @@ -82,15 +79,10 @@ internal class FpsDebugFrameCallback(private val reactContext: ReactContext) : fun stop() { @Suppress("DEPRECATION") - if (!ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) { - val uiManagerModule = - reactContext.getNativeModule(com.facebook.react.uimanager.UIManagerModule::class.java) - if (!reactContext.isBridgeless) { - reactContext.catalystInstance.removeBridgeIdleDebugListener( - didJSUpdateUiDuringFrameDetector - ) - } - uiManagerModule?.setViewHierarchyUpdateDebugListener(null) + if ( + !ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE && !reactContext.isBridgeless + ) { + reactContext.catalystInstance.removeBridgeIdleDebugListener(didJSUpdateUiDuringFrameDetector) } UiThreadUtil.runOnUiThread { choreographer = Choreographer.getInstance() diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index 2cf717f3703..4576b857303 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -26,7 +26,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; import com.facebook.react.common.build.ReactBuildConfig; import com.facebook.react.modules.i18nmanager.I18nUtil; -import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.systrace.Systrace; import com.facebook.systrace.SystraceMessage; @@ -782,13 +781,6 @@ public class UIImplementation { mViewManagers.invalidate(); } - // NOTE: When converted to Kotlin this method should be `internal` due to - // visibility restriction for `NotThreadSafeViewHierarchyUpdateDebugListener` - public void setViewHierarchyUpdateDebugListener( - @Nullable NotThreadSafeViewHierarchyUpdateDebugListener listener) { - mOperationsQueue.setViewHierarchyUpdateDebugListener(listener); - } - protected final void removeShadowNode(ReactShadowNode nodeToRemove) { removeShadowNodeRecursive(nodeToRemove); nodeToRemove.dispose(); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 920096ea741..416fc3a261e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -45,7 +45,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; import com.facebook.react.common.build.ReactBuildConfig; import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.uimanager.common.ViewUtil; -import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcherImpl; import com.facebook.react.uimanager.events.RCTEventEmitter; @@ -699,13 +698,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule } } - // NOTE: When converted to Kotlin this method should be `internal` due to - // visibility restriction for `NotThreadSafeViewHierarchyUpdateDebugListener` - public void setViewHierarchyUpdateDebugListener( - @Nullable NotThreadSafeViewHierarchyUpdateDebugListener listener) { - mUIImplementation.setViewHierarchyUpdateDebugListener(listener); - } - @Override public EventDispatcher getEventDispatcher() { return mEventDispatcher; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index 6745ca88c5f..8d46ee3eb49 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -29,7 +29,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitecture; import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel; import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; import com.facebook.react.modules.core.ReactChoreographer; -import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.systrace.Systrace; import com.facebook.systrace.SystraceMessage; import com.facebook.yoga.YogaDirection; @@ -584,7 +583,6 @@ public class UIViewOperationQueue { @GuardedBy("mNonBatchedOperationsLock") private ArrayDeque mNonBatchedOperations = new ArrayDeque<>(); - private @Nullable NotThreadSafeViewHierarchyUpdateDebugListener mViewHierarchyUpdateDebugListener; private boolean mIsDispatchUIFrameCallbackEnqueued = false; private boolean mIsInIllegalUIState = false; private boolean mIsProfilingNextBatch = false; @@ -619,13 +617,6 @@ public class UIViewOperationQueue { return mNativeViewHierarchyManager; } - // NOTE: When converted to Kotlin this method should be `internal` due to - // visibility restriction for `NotThreadSafeViewHierarchyUpdateDebugListener` - public void setViewHierarchyUpdateDebugListener( - @Nullable NotThreadSafeViewHierarchyUpdateDebugListener listener) { - mViewHierarchyUpdateDebugListener = listener; - } - public void profileNextBatch() { mIsProfilingNextBatch = true; mProfiledBatchCommitStartTime = 0; @@ -833,10 +824,6 @@ public class UIViewOperationQueue { } } - if (mViewHierarchyUpdateDebugListener != null) { - mViewHierarchyUpdateDebugListener.onViewHierarchyUpdateEnqueued(); - } - Runnable runOperations = new Runnable() { @Override @@ -926,9 +913,6 @@ public class UIViewOperationQueue { // Clear layout animation, as animation only apply to current UI operations batch. mNativeViewHierarchyManager.clearLayoutAnimation(); - if (mViewHierarchyUpdateDebugListener != null) { - mViewHierarchyUpdateDebugListener.onViewHierarchyUpdateFinished(); - } } catch (Exception e) { mIsInIllegalUIState = true; throw e; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener.kt deleted file mode 100644 index abeda63335f..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.uimanager.debug - -import com.facebook.react.common.annotations.internal.LegacyArchitecture -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel - -/** - * A listener that is notified about view hierarchy update events. This listener should only be used - * for debug purposes and should not affect application state. - * - * NB: while [onViewHierarchyUpdateFinished] will always be called from the UI thread, there are no - * guarantees what thread onViewHierarchyUpdateEnqueued is called on. - */ -@Deprecated( - "NotThreadSafeViewHierarchyUpdateDebugListener will be deleted in the new architecture." -) -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -internal interface NotThreadSafeViewHierarchyUpdateDebugListener { - /** Called when `UIManagerModule` enqueues a UI batch to be dispatched to the main thread. */ - fun onViewHierarchyUpdateEnqueued() - - /** Called from the main thread after a UI batch has been applied to all root views. */ - fun onViewHierarchyUpdateFinished() -}