From 22b6e1c8ec0e69700e9142cf5c9c1ab1e6a84b78 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 18 Oct 2022 13:32:03 -0700 Subject: [PATCH] Ship and delete mapBufferSerialization for Text measurement Summary: In this diff I'm shipping and deleting mapBufferSerialization for Text measurement changelog: [internal] internal Reviewed By: NickGerleman Differential Revision: D40348982 fbshipit-source-id: 7336cbe055a55d7d8d4f0a723049842bae1defb5 --- .../views/text/ReactTextViewManager.java | 10 +-- .../textinput/ReactTextInputManager.java | 9 +-- .../src/main/jni/react/fabric/Binding.cpp | 4 -- .../textlayoutmanager/TextLayoutManager.cpp | 63 +------------------ .../textlayoutmanager/TextLayoutManager.h | 1 - 5 files changed, 8 insertions(+), 79 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java index bdc9d249816ad7..0c8a7f0621b9ea 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java @@ -17,7 +17,6 @@ import com.facebook.react.common.MapBuilder; import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.common.mapbuffer.MapBuffer; -import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.uimanager.IViewManagerWithChildren; import com.facebook.react.uimanager.ReactAccessibilityDelegate; @@ -132,13 +131,10 @@ public boolean needsCustomLayoutForChildren() { @Override public Object updateState( ReactTextView view, ReactStylesDiffMap props, StateWrapper stateWrapper) { - if (ReactFeatureFlags.mapBufferSerializationEnabled) { - MapBuffer stateMapBuffer = stateWrapper.getStateDataMapBuffer(); - if (stateMapBuffer != null) { - return getReactTextUpdate(view, props, stateMapBuffer); - } + MapBuffer stateMapBuffer = stateWrapper.getStateDataMapBuffer(); + if (stateMapBuffer != null) { + return getReactTextUpdate(view, props, stateMapBuffer); } - ReadableNativeMap state = stateWrapper.getStateData(); if (state == null) { return null; diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 3db39a7b2927dd..1b5371626fac72 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -45,7 +45,6 @@ import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.common.MapBuilder; import com.facebook.react.common.mapbuffer.MapBuffer; -import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.uimanager.BaseViewManager; import com.facebook.react.uimanager.FabricViewStateManager; @@ -1295,11 +1294,9 @@ public Object updateState( stateManager.setStateWrapper(stateWrapper); - if (ReactFeatureFlags.mapBufferSerializationEnabled) { - MapBuffer stateMapBuffer = stateWrapper.getStateDataMapBuffer(); - if (stateMapBuffer != null) { - return getReactTextUpdate(view, props, stateMapBuffer); - } + MapBuffer stateMapBuffer = stateWrapper.getStateDataMapBuffer(); + if (stateMapBuffer != null) { + return getReactTextUpdate(view, props, stateMapBuffer); } ReadableNativeMap state = stateWrapper.getStateData(); diff --git a/ReactAndroid/src/main/jni/react/fabric/Binding.cpp b/ReactAndroid/src/main/jni/react/fabric/Binding.cpp index 4afe8bd8475349..d619227359a33b 100644 --- a/ReactAndroid/src/main/jni/react/fabric/Binding.cpp +++ b/ReactAndroid/src/main/jni/react/fabric/Binding.cpp @@ -433,10 +433,6 @@ void Binding::installFabricUIManager( // Keep reference to config object and cache some feature flags here reactNativeConfig_ = config; - contextContainer->insert( - "MapBufferSerializationEnabled", - getFeatureFlagValue("mapBufferSerializationEnabled")); - contextContainer->insert( "CalculateTransformedFramesEnabled", getFeatureFlagValue("calculateTransformedFramesEnabled")); diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp index 7e94bc54d96b4f..7d67eb0990fe7e 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp @@ -146,8 +146,6 @@ Size measureAndroidComponentMapBuffer( TextLayoutManager::TextLayoutManager( const ContextContainer::Shared &contextContainer) : contextContainer_(contextContainer), - mapBufferSerializationEnabled_( - contextContainer->at("MapBufferSerializationEnabled")), measureCache_( contextContainer->at("EnableLargeTextMeasureCache") ? 1024 @@ -171,11 +169,8 @@ TextMeasurement TextLayoutManager::measure( telemetry->willMeasureText(); } - auto measurement = mapBufferSerializationEnabled_ - ? doMeasureMapBuffer( - attributedString, paragraphAttributes, layoutConstraints) - : doMeasure( - attributedString, paragraphAttributes, layoutConstraints); + auto measurement = doMeasureMapBuffer( + attributedString, paragraphAttributes, layoutConstraints); if (telemetry != nullptr) { telemetry->didMeasureText(); @@ -227,60 +222,6 @@ LinesMeasurements TextLayoutManager::measureLines( AttributedString const &attributedString, ParagraphAttributes const ¶graphAttributes, Size size) const { - if (mapBufferSerializationEnabled_) { - return measureLinesMapBuffer(attributedString, paragraphAttributes, size); - } - - const jni::global_ref &fabricUIManager = - contextContainer_->at>("FabricUIManager"); - static auto measureLines = - jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") - ->getMethod("measureLines"); - - auto serializedAttributedString = toDynamic(attributedString); - - local_ref attributedStringRNM = - ReadableNativeMap::newObjectCxxArgs(serializedAttributedString); - local_ref paragraphAttributesRNM = - ReadableNativeMap::newObjectCxxArgs(toDynamic(paragraphAttributes)); - - local_ref attributedStringRM = make_local( - reinterpret_cast(attributedStringRNM.get())); - local_ref paragraphAttributesRM = make_local( - reinterpret_cast(paragraphAttributesRNM.get())); - - auto array = measureLines( - fabricUIManager, - attributedStringRM.get(), - paragraphAttributesRM.get(), - size.width, - size.height); - - auto dynamicArray = cthis(array)->consume(); - LinesMeasurements lineMeasurements; - lineMeasurements.reserve(dynamicArray.size()); - - for (auto const &data : dynamicArray) { - lineMeasurements.push_back(LineMeasurement(data)); - } - - // Explicitly release smart pointers to free up space faster in JNI tables - attributedStringRM.reset(); - attributedStringRNM.reset(); - paragraphAttributesRM.reset(); - paragraphAttributesRNM.reset(); - - return lineMeasurements; -} - -LinesMeasurements TextLayoutManager::measureLinesMapBuffer( - AttributedString const &attributedString, - ParagraphAttributes const ¶graphAttributes, - Size size) const { const jni::global_ref &fabricUIManager = contextContainer_->at>("FabricUIManager"); static auto measureLines = diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h index 711e617fc729f0..63694bc1bbc66d 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h @@ -90,7 +90,6 @@ class TextLayoutManager { void *self_{}; ContextContainer::Shared contextContainer_; - bool mapBufferSerializationEnabled_; TextMeasureCache measureCache_; };