From 70f732dc8a903f892656d29ff81da21fbf040b32 Mon Sep 17 00:00:00 2001 From: Ishan Khot Date: Wed, 20 May 2020 16:31:18 -0700 Subject: [PATCH] Revert D21583122: Android-specific LayoutAnimation integration Differential Revision: D21583122 Original commit changeset: 82eacb7192f7 fbshipit-source-id: 5bcc392cdb3b11c755395beba4032a21c1bf2668 --- .../com/facebook/react/fabric/Binding.java | 2 - .../react/fabric/FabricUIManager.java | 25 +-------- .../java/com/facebook/react/fabric/jni/BUCK | 1 - .../com/facebook/react/fabric/jni/Binding.cpp | 55 ++----------------- .../com/facebook/react/fabric/jni/Binding.h | 28 +++------- 5 files changed, 15 insertions(+), 96 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java index d0abc11e6dc..81ab4e76829 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java @@ -70,8 +70,6 @@ public class Binding { boolean isRTL, boolean doLeftAndRightSwapInRTL); - public native void driveCxxAnimations(); - public void register( @NonNull JavaScriptContextHolder jsContext, @NonNull FabricUIManager fabricUIManager, 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 8fa0963db2a..d628acaa839 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -142,8 +142,6 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { */ private volatile boolean mDestroyed = false; - private boolean mDriveCxxAnimations = false; - private long mRunStartTime = 0l; private long mBatchedExecutionTime = 0l; private long mDispatchViewUpdatesTime = 0l; @@ -969,20 +967,6 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { // TODO T31905686: Remove this method and add support for multi-threading performance counters } - // Called from Binding.cpp - @DoNotStrip - @AnyThread - public void onAnimationStarted() { - mDriveCxxAnimations = true; - } - - // Called from Binding.cpp - @DoNotStrip - @AnyThread - public void onAllAnimationsComplete() { - mDriveCxxAnimations = false; - } - @Override public Map getPerformanceCounters() { HashMap performanceCounters = new HashMap<>(); @@ -1018,18 +1002,11 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { return; } - // Drive any animations from C++. - // There is a race condition here between getting/setting - // `mDriveCxxAnimations` which shouldn't matter; it's safe to call - // the mBinding method, unless mBinding has gone away. - if (mDriveCxxAnimations && mBinding != null) { - mBinding.driveCxxAnimations(); - } - try { dispatchPreMountItems(frameTimeNanos); tryDispatchMountItems(); + } catch (Exception ex) { FLog.e(TAG, "Exception thrown when executing UIFrameGuarded", ex); stop(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK index 7fc222b4702..5143028cdc1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK @@ -29,7 +29,6 @@ rn_xplat_cxx_library( deps = [ react_native_xplat_target("better:better"), react_native_xplat_target("config:config"), - react_native_xplat_target("fabric/animations:animations"), react_native_xplat_target("fabric/uimanager:uimanager"), react_native_xplat_target("fabric/scheduler:scheduler"), react_native_xplat_target("fabric/componentregistry:componentregistry"), 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 025d035502e..54830fe1ac3 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 @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -73,10 +72,6 @@ std::shared_ptr Binding::getScheduler() { return scheduler_; } -LayoutAnimationDriver *Binding::getAnimationDriver() { - return (animationDriver_ ? animationDriver_.get() : nullptr); -} - void Binding::startSurface( jint surfaceId, jni::alias_ref moduleName, @@ -96,8 +91,7 @@ void Binding::startSurface( moduleName->toStdString(), initialProps->consume(), {}, - context, - getAnimationDriver()); + context); } void Binding::startSurfaceWithConstraints( @@ -143,8 +137,7 @@ void Binding::startSurfaceWithConstraints( moduleName->toStdString(), initialProps->consume(), constraints, - context, - getAnimationDriver()); + context); } void Binding::renderTemplateToSurface(jint surfaceId, jstring uiTemplate) { @@ -283,23 +276,19 @@ void Binding::installFabricUIManager( collapseDeleteCreateMountingInstructions_ = reactNativeConfig_->getBool( "react_fabric:enabled_collapse_delete_create_mounting_instructions"); + disableVirtualNodePreallocation_ = reactNativeConfig_->getBool( + "react_fabric:disable_virtual_node_preallocation"); + disablePreallocateViews_ = reactNativeConfig_->getBool( "react_fabric:disabled_view_preallocation_android"); - bool enableLayoutAnimations_ = reactNativeConfig_->getBool( - "react_fabric:enabled_layout_animations_android"); - auto toolbox = SchedulerToolbox{}; toolbox.contextContainer = contextContainer; toolbox.componentRegistryFactory = componentsRegistry->buildRegistryFunction; toolbox.runtimeExecutor = runtimeExecutor; toolbox.synchronousEventBeatFactory = synchronousBeatFactory; toolbox.asynchronousEventBeatFactory = asynchronousBeatFactory; - - if (enableLayoutAnimations_) { - animationDriver_ = std::make_unique(this); - } - scheduler_ = std::make_shared(toolbox, getAnimationDriver(), this); + scheduler_ = std::make_shared(toolbox, nullptr, this); } void Binding::uninstallFabricUIManager() { @@ -881,37 +870,6 @@ void Binding::setPixelDensity(float pointScaleFactor) { pointScaleFactor_ = pointScaleFactor; } -void Binding::onAnimationStarted() { - jni::global_ref localJavaUIManager = getJavaUIManager(); - if (!localJavaUIManager) { - LOG(ERROR) << "Binding::animationsStarted: JavaUIManager disappeared"; - return; - } - - static auto layoutAnimationsStartedJNI = - jni::findClassStatic(UIManagerJavaDescriptor) - ->getMethod("onAnimationStarted"); - - layoutAnimationsStartedJNI(localJavaUIManager); -} -void Binding::onAllAnimationsComplete() { - jni::global_ref localJavaUIManager = getJavaUIManager(); - if (!localJavaUIManager) { - LOG(ERROR) << "Binding::allAnimationsComplete: JavaUIManager disappeared"; - return; - } - - static auto allAnimationsCompleteJNI = - jni::findClassStatic(UIManagerJavaDescriptor) - ->getMethod("onAllAnimationsComplete"); - - allAnimationsCompleteJNI(localJavaUIManager); -} - -void Binding::driveCxxAnimations() { - scheduler_->animationTick(); -} - void Binding::schedulerDidRequestPreliminaryViewAllocation( const SurfaceId surfaceId, const ShadowView &shadowView) { @@ -1036,7 +994,6 @@ void Binding::registerNatives() { makeNativeMethod("stopSurface", Binding::stopSurface), makeNativeMethod("setConstraints", Binding::setConstraints), makeNativeMethod("setPixelDensity", Binding::setPixelDensity), - makeNativeMethod("driveCxxAnimations", Binding::driveCxxAnimations), makeNativeMethod( "uninstallFabricUIManager", Binding::uninstallFabricUIManager)}); } 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 504fc83b252..c5c216c39ab 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 @@ -8,12 +8,10 @@ #pragma once #include -#include #include #include #include #include -#include #include #include #include "ComponentFactoryDelegate.h" @@ -24,9 +22,7 @@ namespace react { class Instance; -class Binding : public jni::HybridClass, - public SchedulerDelegate, - public LayoutAnimationStatusDelegate { +class Binding : public jni::HybridClass, public SchedulerDelegate { public: constexpr static const char *const kJavaDescriptor = "Lcom/facebook/react/fabric/Binding;"; @@ -77,28 +73,26 @@ class Binding : public jni::HybridClass, void stopSurface(jint surfaceId); void schedulerDidFinishTransaction( - MountingCoordinator::Shared const &mountingCoordinator) override; + MountingCoordinator::Shared const &mountingCoordinator); void schedulerDidRequestPreliminaryViewAllocation( const SurfaceId surfaceId, - const ShadowView &shadowView) override; + const ShadowView &shadowView); void schedulerDidDispatchCommand( const ShadowView &shadowView, std::string const &commandName, - folly::dynamic const args) override; + folly::dynamic const args); + + void setPixelDensity(float pointScaleFactor); void schedulerDidSetJSResponder( SurfaceId surfaceId, const ShadowView &shadowView, const ShadowView &initialShadowView, - bool blockNativeResponder) override; + bool blockNativeResponder); - void schedulerDidClearJSResponder() override; - - void setPixelDensity(float pointScaleFactor); - - void driveCxxAnimations(); + void schedulerDidClearJSResponder(); void uninstallFabricUIManager(); @@ -106,12 +100,6 @@ class Binding : public jni::HybridClass, jni::global_ref javaUIManager_; std::mutex javaUIManagerMutex_; - // LayoutAnimations - virtual void onAnimationStarted() override; - virtual void onAllAnimationsComplete() override; - LayoutAnimationDriver *getAnimationDriver(); - std::unique_ptr animationDriver_; - std::shared_ptr scheduler_; std::mutex schedulerMutex_;