From 585dfff22b4df70ce3ae195ce394fdfcf6a79d2f Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 21 Oct 2019 11:45:43 -0700 Subject: [PATCH] Disable preallocation of views in Mounting layer of fabric Summary: This diff adds an experiment to disable the preallocation of views on the mounting layer of Fabric Changelog: Add a ReactNativeConfig to configure the preallocation of views in the mounting layer of Fabric Reviewed By: shergin Differential Revision: D17949681 fbshipit-source-id: 0af63df22aff9e94289bc8a8217c79222f1fd61c --- .../java/com/facebook/react/fabric/jni/Binding.cpp | 10 ++++++++-- .../main/java/com/facebook/react/fabric/jni/Binding.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) 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 6f5921ae3a8..e1f5b6af696 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 @@ -238,6 +238,8 @@ void Binding::installFabricUIManager( reactNativeConfig_ = config; shouldCollateRemovesAndDeletes_ = reactNativeConfig_->getBool("react_fabric:enable_removedelete_collation_android"); + disablePreallocateViews_ = reactNativeConfig_->getBool("react_fabric:disabled_view_preallocation_android"); + auto toolbox = SchedulerToolbox{}; toolbox.contextContainer = contextContainer; toolbox.componentRegistryFactory = componentsRegistry->buildRegistryFunction; @@ -602,7 +604,7 @@ void Binding::schedulerDidFinishTransaction( switch (mutation.type) { case ShadowViewMutation::Create: { - if (mutation.newChildShadowView.props->revision > 1 || + if (disablePreallocateViews_ || mutation.newChildShadowView.props->revision > 1 || deletedViewTags.find(mutation.newChildShadowView.tag) != deletedViewTags.end()) { mountItems[position++] = @@ -683,7 +685,7 @@ void Binding::schedulerDidFinishTransaction( mountItems[position++] = createInsertMountItem(localJavaUIManager, mutation); - if (mutation.newChildShadowView.props->revision > 1 || + if (disablePreallocateViews_ || mutation.newChildShadowView.props->revision > 1 || deletedViewTags.find(mutation.newChildShadowView.tag) != deletedViewTags.end()) { mountItems[position++] = @@ -780,6 +782,10 @@ void Binding::schedulerDidRequestPreliminaryViewAllocation( const SurfaceId surfaceId, const ShadowView &shadowView) { + if (disablePreallocateViews_) { + return; + } + jni::global_ref localJavaUIManager = getJavaUIManager(); if (!localJavaUIManager) { LOG(ERROR) << "Binding::schedulerDidRequestPreliminaryViewAllocation: JavaUIManager disappeared"; 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 1840e023a7e..826b8fab714 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 @@ -105,6 +105,7 @@ class Binding : public jni::HybridClass, public SchedulerDelegate { std::shared_ptr reactNativeConfig_{nullptr}; bool shouldCollateRemovesAndDeletes_{false}; + bool disablePreallocateViews_{false}; }; } // namespace react