From 97f3eb2d3b9eed23ef6f6129e5b0854c720a91f1 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 3 Mar 2022 09:41:23 -0800 Subject: [PATCH] Ship large text measure cache in Fabric Android Summary: Ship large text measure cache in Fabric Android changelog: [internal] internal Reviewed By: sammy-SC Differential Revision: D34602873 fbshipit-source-id: bd0a77b8b2f85301a78d528e7810938b78c7f7b8 --- .../com/facebook/react/config/ReactFeatureFlags.java | 6 ++++++ .../java/com/facebook/react/fabric/jni/Binding.cpp | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index e2e7da7fb19b0b..7ede3c7eb6038d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -100,4 +100,10 @@ public static boolean doesUseOverflowInset() { public static boolean insertZReorderBarriersOnViewGroupChildren = true; public static boolean enableDelayedViewStateDeletion = false; + + /** + * Feature Flag to control the size of the cache used by TextLayoutManager in Fabric. Used from + * JNI. + */ + public static boolean enableLargeTextMeasureCache = true; } 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 b80b5109f3010e..0b1a41e16a7534 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 @@ -76,6 +76,14 @@ Binding::getInspectorDataForInstance( return ReadableNativeMap::newObjectCxxArgs(result); } +bool isLargeTextMeasureCacheEnabled() { + static const auto reactFeatureFlagsJavaDescriptor = + jni::findClassStatic(Binding::ReactFeatureFlagsJavaDescriptor); + const auto field = reactFeatureFlagsJavaDescriptor->getStaticField( + "enableLargeTextMeasureCache"); + return reactFeatureFlagsJavaDescriptor->getStaticFieldValue(field); +} + bool isMapBufferSerializationEnabled() { static const auto reactFeatureFlagsJavaDescriptor = jni::findClassStatic(Binding::ReactFeatureFlagsJavaDescriptor); @@ -437,9 +445,7 @@ void Binding::installFabricUIManager( "react_native_new_architecture:dispatch_preallocation_in_bg"); contextContainer->insert( - "EnableLargeTextMeasureCache", - reactNativeConfig_->getBool( - "react_fabric:enable_large_text_measure_cache_android")); + "EnableLargeTextMeasureCache", isLargeTextMeasureCacheEnabled()); auto toolbox = SchedulerToolbox{}; toolbox.contextContainer = contextContainer;