diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java index 8b5b7263fcc..136da3a752a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java @@ -21,7 +21,6 @@ import com.facebook.react.fabric.mounting.LayoutMetricsConversions; import com.facebook.react.fabric.mounting.MountingManager; import com.facebook.react.fabric.mounting.mountitems.BatchMountItem; import com.facebook.react.fabric.mounting.mountitems.CreateMountItem; -import com.facebook.react.fabric.mounting.mountitems.DeleteMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchIntCommandMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchStringCommandMountItem; @@ -29,7 +28,6 @@ import com.facebook.react.fabric.mounting.mountitems.InsertMountItem; import com.facebook.react.fabric.mounting.mountitems.MountItem; import com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem; import com.facebook.react.fabric.mounting.mountitems.RemoveDeleteMultiMountItem; -import com.facebook.react.fabric.mounting.mountitems.RemoveMountItem; import com.facebook.react.fabric.mounting.mountitems.SendAccessibilityEvent; import com.facebook.react.fabric.mounting.mountitems.UpdateEventEmitterMountItem; import com.facebook.react.fabric.mounting.mountitems.UpdateLayoutMountItem; @@ -112,7 +110,6 @@ public class FabricJSIModuleProvider implements JSIModuleProvider { FabricEventEmitter.class.getClass(); BatchMountItem.class.getClass(); CreateMountItem.class.getClass(); - DeleteMountItem.class.getClass(); DispatchCommandMountItem.class.getClass(); DispatchIntCommandMountItem.class.getClass(); DispatchStringCommandMountItem.class.getClass(); @@ -120,7 +117,6 @@ public class FabricJSIModuleProvider implements JSIModuleProvider { MountItem.class.getClass(); PreAllocateViewMountItem.class.getClass(); RemoveDeleteMultiMountItem.class.getClass(); - RemoveMountItem.class.getClass(); SendAccessibilityEvent.class.getClass(); UpdateEventEmitterMountItem.class.getClass(); UpdateLayoutMountItem.class.getClass(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 4bfbd111794..515228bc606 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -56,7 +56,6 @@ import com.facebook.react.fabric.events.FabricEventEmitter; import com.facebook.react.fabric.mounting.MountingManager; import com.facebook.react.fabric.mounting.mountitems.BatchMountItem; import com.facebook.react.fabric.mounting.mountitems.CreateMountItem; -import com.facebook.react.fabric.mounting.mountitems.DeleteMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchIntCommandMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchStringCommandMountItem; @@ -64,7 +63,6 @@ import com.facebook.react.fabric.mounting.mountitems.InsertMountItem; import com.facebook.react.fabric.mounting.mountitems.MountItem; import com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem; import com.facebook.react.fabric.mounting.mountitems.RemoveDeleteMultiMountItem; -import com.facebook.react.fabric.mounting.mountitems.RemoveMountItem; import com.facebook.react.fabric.mounting.mountitems.SendAccessibilityEvent; import com.facebook.react.fabric.mounting.mountitems.UpdateEventEmitterMountItem; import com.facebook.react.fabric.mounting.mountitems.UpdateLayoutMountItem; @@ -367,14 +365,6 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { isLayoutable); } - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem removeMountItem(int reactTag, int parentReactTag, int index) { - return new RemoveMountItem(reactTag, parentReactTag, index); - } - @DoNotStrip @SuppressWarnings("unused") @AnyThread @@ -383,14 +373,6 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { return new InsertMountItem(reactTag, parentReactTag, index); } - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem deleteMountItem(int reactTag) { - return new DeleteMountItem(reactTag); - } - @DoNotStrip @SuppressWarnings("unused") @AnyThread diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 3bb5ad4e167..715cf1bea97 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -280,8 +280,6 @@ void Binding::installFabricUIManager( // Keep reference to config object and cache some feature flags here reactNativeConfig_ = config; - shouldCollateRemovesAndDeletes_ = reactNativeConfig_->getBool( - "react_fabric:enable_removedelete_collation_android"); collapseDeleteCreateMountingInstructions_ = reactNativeConfig_->getBool( "react_fabric:enabled_collapse_delete_create_mounting_instructions"); @@ -491,31 +489,6 @@ local_ref createUpdateStateMountItem( (javaStateWrapper != nullptr ? javaStateWrapper.get() : nullptr)); } -local_ref createRemoveMountItem( - const jni::global_ref &javaUIManager, - const ShadowViewMutation &mutation) { - static auto removeInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod(jint, jint, jint)>( - "removeMountItem"); - - return removeInstruction( - javaUIManager, - mutation.oldChildShadowView.tag, - mutation.parentShadowView.tag, - mutation.index); -} - -local_ref createDeleteMountItem( - const jni::global_ref &javaUIManager, - const ShadowViewMutation &mutation) { - static auto deleteInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod(jint)>("deleteMountItem"); - - return deleteInstruction(javaUIManager, mutation.oldChildShadowView.tag); -} - local_ref createRemoveAndDeleteMultiMountItem( const jni::global_ref &javaUIManager, const std::vector &metadata) { @@ -685,8 +658,7 @@ void Binding::schedulerDidFinishTransaction( oldChildShadowView.layoutMetrics == EmptyLayoutMetrics; // Handle accumulated removals/deletions - if (shouldCollateRemovesAndDeletes_ && - mutation.type != ShadowViewMutation::Remove && + if (mutation.type != ShadowViewMutation::Remove && mutation.type != ShadowViewMutation::Delete) { if (toRemove.size() > 0) { mountItems[position++] = @@ -708,39 +680,29 @@ void Binding::schedulerDidFinishTransaction( } case ShadowViewMutation::Remove: { if (!isVirtual) { - if (shouldCollateRemovesAndDeletes_) { - toRemove.push_back( - RemoveDeleteMetadata{mutation.oldChildShadowView.tag, - mutation.parentShadowView.tag, - mutation.index, - true, - false}); - } else { - mountItems[position++] = - createRemoveMountItem(localJavaUIManager, mutation); - } + toRemove.push_back( + RemoveDeleteMetadata{mutation.oldChildShadowView.tag, + mutation.parentShadowView.tag, + mutation.index, + true, + false}); } break; } case ShadowViewMutation::Delete: { - if (shouldCollateRemovesAndDeletes_) { - // It is impossible to delete without removing node first - const auto &it = std::find_if( - std::begin(toRemove), - std::end(toRemove), - [&mutation](const auto &x) { - return x.tag == mutation.oldChildShadowView.tag; - }); + // It is impossible to delete without removing node first + const auto &it = std::find_if( + std::begin(toRemove), + std::end(toRemove), + [&mutation](const auto &x) { + return x.tag == mutation.oldChildShadowView.tag; + }); - if (it != std::end(toRemove)) { - it->shouldDelete = true; - } else { - toRemove.push_back(RemoveDeleteMetadata{ - mutation.oldChildShadowView.tag, -1, -1, false, true}); - } + if (it != std::end(toRemove)) { + it->shouldDelete = true; } else { - mountItems[position++] = - createDeleteMountItem(localJavaUIManager, mutation); + toRemove.push_back(RemoveDeleteMetadata{ + mutation.oldChildShadowView.tag, -1, -1, false, true}); } deletedViewTags.insert(mutation.oldChildShadowView.tag); @@ -840,7 +802,7 @@ void Binding::schedulerDidFinishTransaction( } // Handle remaining removals and deletions - if (shouldCollateRemovesAndDeletes_ && toRemove.size() > 0) { + if (toRemove.size() > 0) { mountItems[position++] = createRemoveAndDeleteMultiMountItem(localJavaUIManager, toRemove); toRemove.clear(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h index e42883d35ca..3d1d439f5e5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h @@ -125,7 +125,6 @@ class Binding : public jni::HybridClass, float pointScaleFactor_ = 1; std::shared_ptr reactNativeConfig_{nullptr}; - bool shouldCollateRemovesAndDeletes_{false}; bool collapseDeleteCreateMountingInstructions_{false}; bool disablePreallocateViews_{false}; bool disableVirtualNodePreallocation_{false}; diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index fa3ee13304b..47d6582698f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -281,19 +281,17 @@ public class MountingManager { ViewGroupManager viewGroupManager = getViewGroupManager(viewState); // Verify that the view we're about to remove has the same tag we expect - if (tag != -1) { - View view = viewGroupManager.getChildAt(parentView, index); - if (view != null && view.getId() != tag) { - throw new IllegalStateException( - "Tried to delete view [" - + tag - + "] of parent [" - + parentTag - + "] at index " - + index - + ", but got view tag " - + view.getId()); - } + View view = viewGroupManager.getChildAt(parentView, index); + if (view != null && view.getId() != tag) { + throw new IllegalStateException( + "Tried to delete view [" + + tag + + "] of parent [" + + parentTag + + "] at index " + + index + + ", but got view tag " + + view.getId()); } try { diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DeleteMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DeleteMountItem.java deleted file mode 100644 index 312dcc1ca4e..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DeleteMountItem.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its 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.fabric.mounting.mountitems; - -import androidx.annotation.NonNull; -import com.facebook.react.fabric.mounting.MountingManager; - -public class DeleteMountItem implements MountItem { - - private int mReactTag; - - public DeleteMountItem(int reactTag) { - mReactTag = reactTag; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - mountingManager.deleteView(mReactTag); - } - - @Override - public String toString() { - return "DeleteMountItem [" + mReactTag + "]"; - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/RemoveMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/RemoveMountItem.java deleted file mode 100644 index 3b6fd921100..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/RemoveMountItem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its 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.fabric.mounting.mountitems; - -import androidx.annotation.NonNull; -import com.facebook.react.fabric.mounting.MountingManager; - -public class RemoveMountItem implements MountItem { - - private int mReactTag; - private int mParentReactTag; - private int mIndex; - - public RemoveMountItem(int reactTag, int parentReactTag, int index) { - mReactTag = reactTag; - mParentReactTag = parentReactTag; - mIndex = index; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - mountingManager.removeViewAt(-1, mParentReactTag, mIndex); - } - - public int getParentReactTag() { - return mParentReactTag; - } - - public int getIndex() { - return mIndex; - } - - @Override - public String toString() { - return "RemoveMountItem [" - + mReactTag - + "] - parentTag: " - + mParentReactTag - + " - index: " - + mIndex; - } -}