Revert D21583122: Android-specific LayoutAnimation integration

Differential Revision:
D21583122

Original commit changeset: 82eacb7192f7

fbshipit-source-id: 5bcc392cdb3b11c755395beba4032a21c1bf2668
This commit is contained in:
Ishan Khot 2020-05-20 16:31:18 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 08031477e7
Коммит 70f732dc8a
5 изменённых файлов: 15 добавлений и 96 удалений

Просмотреть файл

@ -70,8 +70,6 @@ public class Binding {
boolean isRTL,
boolean doLeftAndRightSwapInRTL);
public native void driveCxxAnimations();
public void register(
@NonNull JavaScriptContextHolder jsContext,
@NonNull FabricUIManager fabricUIManager,

Просмотреть файл

@ -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<String, Long> getPerformanceCounters() {
HashMap<String, Long> 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();

Просмотреть файл

@ -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"),

Просмотреть файл

@ -15,7 +15,6 @@
#include <fbjni/fbjni.h>
#include <jsi/JSIDynamic.h>
#include <jsi/jsi.h>
#include <react/animations/LayoutAnimationDriver.h>
#include <react/componentregistry/ComponentDescriptorFactory.h>
#include <react/components/scrollview/ScrollViewProps.h>
#include <react/core/EventBeat.h>
@ -73,10 +72,6 @@ std::shared_ptr<Scheduler> Binding::getScheduler() {
return scheduler_;
}
LayoutAnimationDriver *Binding::getAnimationDriver() {
return (animationDriver_ ? animationDriver_.get() : nullptr);
}
void Binding::startSurface(
jint surfaceId,
jni::alias_ref<jstring> 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<LayoutAnimationDriver>(this);
}
scheduler_ = std::make_shared<Scheduler>(toolbox, getAnimationDriver(), this);
scheduler_ = std::make_shared<Scheduler>(toolbox, nullptr, this);
}
void Binding::uninstallFabricUIManager() {
@ -881,37 +870,6 @@ void Binding::setPixelDensity(float pointScaleFactor) {
pointScaleFactor_ = pointScaleFactor;
}
void Binding::onAnimationStarted() {
jni::global_ref<jobject> localJavaUIManager = getJavaUIManager();
if (!localJavaUIManager) {
LOG(ERROR) << "Binding::animationsStarted: JavaUIManager disappeared";
return;
}
static auto layoutAnimationsStartedJNI =
jni::findClassStatic(UIManagerJavaDescriptor)
->getMethod<void()>("onAnimationStarted");
layoutAnimationsStartedJNI(localJavaUIManager);
}
void Binding::onAllAnimationsComplete() {
jni::global_ref<jobject> localJavaUIManager = getJavaUIManager();
if (!localJavaUIManager) {
LOG(ERROR) << "Binding::allAnimationsComplete: JavaUIManager disappeared";
return;
}
static auto allAnimationsCompleteJNI =
jni::findClassStatic(UIManagerJavaDescriptor)
->getMethod<void()>("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)});
}

Просмотреть файл

@ -8,12 +8,10 @@
#pragma once
#include <fbjni/fbjni.h>
#include <react/animations/LayoutAnimationDriver.h>
#include <react/jni/JMessageQueueThread.h>
#include <react/jni/ReadableNativeMap.h>
#include <react/scheduler/Scheduler.h>
#include <react/scheduler/SchedulerDelegate.h>
#include <react/uimanager/LayoutAnimationStatusDelegate.h>
#include <memory>
#include <mutex>
#include "ComponentFactoryDelegate.h"
@ -24,9 +22,7 @@ namespace react {
class Instance;
class Binding : public jni::HybridClass<Binding>,
public SchedulerDelegate,
public LayoutAnimationStatusDelegate {
class Binding : public jni::HybridClass<Binding>, public SchedulerDelegate {
public:
constexpr static const char *const kJavaDescriptor =
"Lcom/facebook/react/fabric/Binding;";
@ -77,28 +73,26 @@ class Binding : public jni::HybridClass<Binding>,
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<Binding>,
jni::global_ref<jobject> javaUIManager_;
std::mutex javaUIManagerMutex_;
// LayoutAnimations
virtual void onAnimationStarted() override;
virtual void onAllAnimationsComplete() override;
LayoutAnimationDriver *getAnimationDriver();
std::unique_ptr<LayoutAnimationDriver> animationDriver_;
std::shared_ptr<Scheduler> scheduler_;
std::mutex schedulerMutex_;