From 8ca18f0b602a08cd9a5c9f6681bb5dc74e0d34f7 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 2 Jun 2021 12:48:42 -0700 Subject: [PATCH] Don't PreAllocate virtual views Summary: Virtual views that are flattened and don't "FormsView" on-screen should not be preallocated. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D28811419 fbshipit-source-id: 949dcbf4cf3791355c58af785603b35fa50f3f02 --- .../src/main/java/com/facebook/react/fabric/jni/Binding.cpp | 6 +++++- ReactCommon/react/renderer/mounting/ShadowView.cpp | 2 ++ ReactCommon/react/renderer/mounting/ShadowView.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) 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 2945893c05d..73e43c2a18b 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 @@ -561,6 +561,9 @@ void Binding::installFabricUIManager( disablePreallocateViews_ = reactNativeConfig_->getBool( "react_fabric:disabled_view_preallocation_android"); + disableVirtualNodePreallocation_ = reactNativeConfig_->getBool( + "react_fabric:disable_virtual_node_preallocation"); + auto toolbox = SchedulerToolbox{}; toolbox.contextContainer = contextContainer; toolbox.componentRegistryFactory = componentsRegistry->buildRegistryFunction; @@ -1141,7 +1144,8 @@ void Binding::schedulerDidRequestPreliminaryViewAllocation( bool isLayoutableShadowNode = shadowView.layoutMetrics != EmptyLayoutMetrics; - if (disableVirtualNodePreallocation_ && !isLayoutableShadowNode) { + if (disableVirtualNodePreallocation_ && + !shadowView.traits.check(ShadowNodeTraits::Trait::FormsView)) { return; } diff --git a/ReactCommon/react/renderer/mounting/ShadowView.cpp b/ReactCommon/react/renderer/mounting/ShadowView.cpp index 203a1fc95b3..3b4b54f1439 100644 --- a/ReactCommon/react/renderer/mounting/ShadowView.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowView.cpp @@ -25,6 +25,7 @@ ShadowView::ShadowView(const ShadowNode &shadowNode) componentHandle(shadowNode.getComponentHandle()), surfaceId(shadowNode.getSurfaceId()), tag(shadowNode.getTag()), + traits(shadowNode.getTraits()), props(shadowNode.getProps()), eventEmitter(shadowNode.getEventEmitter()), layoutMetrics(layoutMetricsFromShadowNode(shadowNode)), @@ -65,6 +66,7 @@ std::vector getDebugProps( return { {"surfaceId", getDebugDescription(object.surfaceId, options)}, {"tag", getDebugDescription(object.tag, options)}, + {"traits", getDebugDescription(object.traits, options)}, {"componentName", object.componentName}, {"props", getDebugDescription(object.props, options)}, {"eventEmitter", getDebugDescription(object.eventEmitter, options)}, diff --git a/ReactCommon/react/renderer/mounting/ShadowView.h b/ReactCommon/react/renderer/mounting/ShadowView.h index 3631551ae19..614399b2fb0 100644 --- a/ReactCommon/react/renderer/mounting/ShadowView.h +++ b/ReactCommon/react/renderer/mounting/ShadowView.h @@ -43,6 +43,7 @@ struct ShadowView final { ComponentHandle componentHandle{}; SurfaceId surfaceId{}; Tag tag{}; + ShadowNodeTraits traits{}; Props::Shared props{}; EventEmitter::Shared eventEmitter{}; LayoutMetrics layoutMetrics{EmptyLayoutMetrics};