From 4134d8db01d9d500ecd02ac38720a2a86472a1f9 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 19 Oct 2023 04:53:25 -0700 Subject: [PATCH] remove redundant method from MountItemDispatcher (#41061) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41061 changelog: [internal] Method `dispatchCommandMountItem` only calls `addViewCommandMountItem` without adding anything on top of it. The name is inaccurate because it doesn't dispatch mount item, it queues it. Let's remove one of them to simplify the API. Reviewed By: javache Differential Revision: D50408576 fbshipit-source-id: 3a4871c38e7b081a5e27aba211d61254075e76cd --- .../facebook/react/fabric/FabricUIManager.java | 6 +++--- .../fabric/mounting/MountItemDispatcher.java | 16 ++++------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index e20d13c0f22b80..c0d9fa2e0ae1dd 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -1023,7 +1023,7 @@ public void dispatchCommand( final int reactTag, final int commandId, @Nullable final ReadableArray commandArgs) { - mMountItemDispatcher.dispatchCommandMountItem( + mMountItemDispatcher.addViewCommandMountItem( MountItemFactory.createDispatchCommandMountItem( surfaceId, reactTag, commandId, commandArgs)); } @@ -1039,10 +1039,10 @@ public void dispatchCommand( // For Fabric Interop, we check if the commandId is an integer. If it is, we use the integer // overload of dispatchCommand. Otherwise, we use the string overload. // and the events won't be correctly dispatched. - mMountItemDispatcher.dispatchCommandMountItem( + mMountItemDispatcher.addViewCommandMountItem( createDispatchCommandMountItemForInterop(surfaceId, reactTag, commandId, commandArgs)); } else { - mMountItemDispatcher.dispatchCommandMountItem( + mMountItemDispatcher.addViewCommandMountItem( MountItemFactory.createDispatchCommandMountItem( surfaceId, reactTag, commandId, commandArgs)); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java index f8bd78bf302b29..edf67153d4294f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java @@ -7,14 +7,12 @@ package com.facebook.react.fabric.mounting; -import static com.facebook.infer.annotation.ThreadConfined.ANY; import static com.facebook.infer.annotation.ThreadConfined.UI; import static com.facebook.react.fabric.FabricUIManager.ENABLE_FABRIC_LOGS; import static com.facebook.react.fabric.FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT; import android.os.SystemClock; import android.view.View; -import androidx.annotation.AnyThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; @@ -62,10 +60,8 @@ public MountItemDispatcher(MountingManager mountingManager, ItemDispatchListener mItemDispatchListener = listener; } - @AnyThread - @ThreadConfined(ANY) - public void dispatchCommandMountItem(DispatchCommandMountItem command) { - addViewCommandMountItem(command); + public void addViewCommandMountItem(DispatchCommandMountItem mountItem) { + mViewCommandMountItems.add(mountItem); } public void addMountItem(MountItem mountItem) { @@ -88,10 +84,6 @@ public void addPreAllocateMountItem(MountItem mountItem) { } } - public void addViewCommandMountItem(DispatchCommandMountItem mountItem) { - mViewCommandMountItems.add(mountItem); - } - /** * Try to dispatch MountItems. In case of the exception, we will retry 10 times before giving up. */ @@ -159,7 +151,7 @@ public void dispatchMountItems(Queue mountItems) { mountItem.incrementRetries(); // In case we haven't retried executing this item yet, execute in the next batch of // items - dispatchCommandMountItem(mountItem); + addViewCommandMountItem(mountItem); } } else { printMountItem( @@ -214,7 +206,7 @@ private boolean dispatchMountItems() { // the current batch of mount items has finished executing. if (command.getRetries() == 0) { command.incrementRetries(); - dispatchCommandMountItem(command); + addViewCommandMountItem(command); } else { // It's very common for commands to be executed on views that no longer exist - for // example, a blur event on TextInput being fired because of a navigation event away