Skip to content

Commit 8fe9e6b

Browse files
javachefacebook-github-bot
authored andcommitted
Cleanup disableOldAndroidAttachmentMetricsWorkarounds flag (facebook#55035)
Summary: Was already rolled out, clean up code. Changelog: [Internal] Reviewed By: rubennorte Differential Revision: D90106433
1 parent 9d1c55b commit 8fe9e6b

21 files changed

+111
-269
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<1ee723a105e7d14a01f92469bad94888>>
7+
* @generated SignedSource<<3ee5c6b643fa4065a8168ebbb19d4efc>>
88
*/
99

1010
/**
@@ -66,12 +66,6 @@ public object ReactNativeFeatureFlags {
6666
@JvmStatic
6767
public fun disableMountItemReorderingAndroid(): Boolean = accessor.disableMountItemReorderingAndroid()
6868

69-
/**
70-
* Disable some workarounds for old Android versions in TextLayoutManager logic for retrieving attachment metrics
71-
*/
72-
@JvmStatic
73-
public fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean = accessor.disableOldAndroidAttachmentMetricsWorkarounds()
74-
7569
/**
7670
* Force disable subview clipping for ReactViewGroup on Android
7771
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<934d187fb9928a20d4a442977c7f90b2>>
7+
* @generated SignedSource<<0c88c86f3085fa7c319b0c0a60102057>>
88
*/
99

1010
/**
@@ -26,7 +26,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
2626
private var disableEarlyViewCommandExecutionCache: Boolean? = null
2727
private var disableImageViewPreallocationAndroidCache: Boolean? = null
2828
private var disableMountItemReorderingAndroidCache: Boolean? = null
29-
private var disableOldAndroidAttachmentMetricsWorkaroundsCache: Boolean? = null
3029
private var disableSubviewClippingAndroidCache: Boolean? = null
3130
private var disableTextLayoutManagerCacheAndroidCache: Boolean? = null
3231
private var disableViewPreallocationAndroidCache: Boolean? = null
@@ -161,15 +160,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
161160
return cached
162161
}
163162

164-
override fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean {
165-
var cached = disableOldAndroidAttachmentMetricsWorkaroundsCache
166-
if (cached == null) {
167-
cached = ReactNativeFeatureFlagsCxxInterop.disableOldAndroidAttachmentMetricsWorkarounds()
168-
disableOldAndroidAttachmentMetricsWorkaroundsCache = cached
169-
}
170-
return cached
171-
}
172-
173163
override fun disableSubviewClippingAndroid(): Boolean {
174164
var cached = disableSubviewClippingAndroidCache
175165
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9eaa1bfee243767cc98b9477fc391c37>>
7+
* @generated SignedSource<<ca442b740e44e6eea6a8227f00fa1f99>>
88
*/
99

1010
/**
@@ -40,8 +40,6 @@ public object ReactNativeFeatureFlagsCxxInterop {
4040

4141
@DoNotStrip @JvmStatic public external fun disableMountItemReorderingAndroid(): Boolean
4242

43-
@DoNotStrip @JvmStatic public external fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean
44-
4543
@DoNotStrip @JvmStatic public external fun disableSubviewClippingAndroid(): Boolean
4644

4745
@DoNotStrip @JvmStatic public external fun disableTextLayoutManagerCacheAndroid(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<51a5be93dbaf0000664d6ff482bdc18c>>
7+
* @generated SignedSource<<15272e1b6cbbcb03b08f453e9cdfccb1>>
88
*/
99

1010
/**
@@ -35,8 +35,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
3535

3636
override fun disableMountItemReorderingAndroid(): Boolean = false
3737

38-
override fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean = true
39-
4038
override fun disableSubviewClippingAndroid(): Boolean = false
4139

4240
override fun disableTextLayoutManagerCacheAndroid(): Boolean = false

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<503f34acc5cf8a0755cef1ca8b72e7e5>>
7+
* @generated SignedSource<<2a0f4c8afaa630631d09e804776197a2>>
88
*/
99

1010
/**
@@ -30,7 +30,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
3030
private var disableEarlyViewCommandExecutionCache: Boolean? = null
3131
private var disableImageViewPreallocationAndroidCache: Boolean? = null
3232
private var disableMountItemReorderingAndroidCache: Boolean? = null
33-
private var disableOldAndroidAttachmentMetricsWorkaroundsCache: Boolean? = null
3433
private var disableSubviewClippingAndroidCache: Boolean? = null
3534
private var disableTextLayoutManagerCacheAndroidCache: Boolean? = null
3635
private var disableViewPreallocationAndroidCache: Boolean? = null
@@ -171,16 +170,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
171170
return cached
172171
}
173172

174-
override fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean {
175-
var cached = disableOldAndroidAttachmentMetricsWorkaroundsCache
176-
if (cached == null) {
177-
cached = currentProvider.disableOldAndroidAttachmentMetricsWorkarounds()
178-
accessedFeatureFlags.add("disableOldAndroidAttachmentMetricsWorkarounds")
179-
disableOldAndroidAttachmentMetricsWorkaroundsCache = cached
180-
}
181-
return cached
182-
}
183-
184173
override fun disableSubviewClippingAndroid(): Boolean {
185174
var cached = disableSubviewClippingAndroidCache
186175
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<d301449edc583e49d5660ea5d5f80929>>
7+
* @generated SignedSource<<6346af0ed92119faadaec2b5b08b34d1>>
88
*/
99

1010
/**
@@ -35,8 +35,6 @@ public interface ReactNativeFeatureFlagsProvider {
3535

3636
@DoNotStrip public fun disableMountItemReorderingAndroid(): Boolean
3737

38-
@DoNotStrip public fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean
39-
4038
@DoNotStrip public fun disableSubviewClippingAndroid(): Boolean
4139

4240
@DoNotStrip public fun disableTextLayoutManagerCacheAndroid(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,63 +1307,22 @@ internal object TextLayoutManager {
13071307
} else {
13081308
val placeholderWidth = placeholder.width.toFloat()
13091309
val placeholderHeight = placeholder.height.toFloat()
1310+
13101311
// Calculate if the direction of the placeholder character is Right-To-Left.
13111312
val isRtlChar = layout.isRtlCharAt(start)
13121313
val isRtlParagraph = layout.getParagraphDirection(line) == Layout.DIR_RIGHT_TO_LEFT
1313-
var placeholderLeftPosition: Float
1314-
// There's a bug on Samsung devices where calling getPrimaryHorizontal on
1315-
// the last offset in the layout will result in an endless loop. Work around
1316-
// this bug by avoiding getPrimaryHorizontal in that case.
1317-
if (
1318-
!ReactNativeFeatureFlags.disableOldAndroidAttachmentMetricsWorkarounds() &&
1319-
start == text.length - 1
1320-
) {
1321-
val endsWithNewLine = text.length > 0 && text[layout.getLineEnd(line) - 1] == '\n'
1322-
val lineWidth = if (endsWithNewLine) layout.getLineMax(line) else layout.getLineWidth(line)
1323-
placeholderLeftPosition =
1324-
if (
1325-
isRtlParagraph // Equivalent to `layout.getLineLeft(line)` but `getLineLeft` returns
1326-
// incorrect
1327-
// values when the paragraph is RTL and `setSingleLine(true)`.
1328-
)
1329-
( // Equivalent to `layout.getLineLeft(line)` but `getLineLeft` returns
1330-
// incorrect
1331-
// values when the paragraph is RTL and `setSingleLine(true)`.
1332-
calculatedWidth - lineWidth)
1333-
else (layout.getLineRight(line) - placeholderWidth)
1334-
} else {
1335-
// The direction of the paragraph may not be exactly the direction the string is
1336-
// heading
1337-
// in at the
1338-
// position of the placeholder. So, if the direction of the character is the same
1339-
// as the
1340-
// paragraph
1341-
// use primary, secondary otherwise.
1342-
val characterAndParagraphDirectionMatch = isRtlParagraph == isRtlChar
1343-
placeholderLeftPosition =
1344-
if (characterAndParagraphDirectionMatch) layout.getPrimaryHorizontal(start)
1345-
else layout.getSecondaryHorizontal(start)
1346-
if (
1347-
!ReactNativeFeatureFlags.disableOldAndroidAttachmentMetricsWorkarounds() &&
1348-
isRtlParagraph &&
1349-
!isRtlChar
1350-
) {
1351-
// Adjust `placeholderLeftPosition` to work around an Android bug.
1352-
// The bug is when the paragraph is RTL and `setSingleLine(true)`, some layout
1353-
// methods such as `getPrimaryHorizontal`, `getSecondaryHorizontal`, and
1354-
// `getLineRight` return incorrect values. Their return values seem to be off
1355-
// by the same number of pixels so subtracting these values cancels out the
1356-
// error.
1357-
//
1358-
// The result is equivalent to bugless versions of
1359-
// `getPrimaryHorizontal`/`getSecondaryHorizontal`.
1360-
placeholderLeftPosition =
1361-
calculatedWidth - (layout.getLineRight(line) - placeholderLeftPosition)
1362-
}
1363-
if (isRtlChar) {
1364-
placeholderLeftPosition -= placeholderWidth
1365-
}
1314+
1315+
// The direction of the paragraph may not be exactly the direction the string is heading in at
1316+
// the position of the placeholder. So, if the direction of the character is the same as the
1317+
// paragraph use primary, secondary otherwise.
1318+
val characterAndParagraphDirectionMatch = isRtlParagraph == isRtlChar
1319+
var placeholderLeftPosition =
1320+
if (characterAndParagraphDirectionMatch) layout.getPrimaryHorizontal(start)
1321+
else layout.getSecondaryHorizontal(start)
1322+
if (isRtlChar) {
1323+
placeholderLeftPosition -= placeholderWidth
13661324
}
1325+
13671326
// Vertically align the inline view to the baseline of the line of text.
13681327
val placeholderTopPosition = layout.getLineBaseline(line) - placeholderHeight
13691328

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<bedfbd46022e1f5f29c7f6331ef99688>>
7+
* @generated SignedSource<<49089fe126ce14edaf58fbf8a942330f>>
88
*/
99

1010
/**
@@ -75,12 +75,6 @@ class ReactNativeFeatureFlagsJavaProvider
7575
return method(javaProvider_);
7676
}
7777

78-
bool disableOldAndroidAttachmentMetricsWorkarounds() override {
79-
static const auto method =
80-
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("disableOldAndroidAttachmentMetricsWorkarounds");
81-
return method(javaProvider_);
82-
}
83-
8478
bool disableSubviewClippingAndroid() override {
8579
static const auto method =
8680
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("disableSubviewClippingAndroid");
@@ -589,11 +583,6 @@ bool JReactNativeFeatureFlagsCxxInterop::disableMountItemReorderingAndroid(
589583
return ReactNativeFeatureFlags::disableMountItemReorderingAndroid();
590584
}
591585

592-
bool JReactNativeFeatureFlagsCxxInterop::disableOldAndroidAttachmentMetricsWorkarounds(
593-
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
594-
return ReactNativeFeatureFlags::disableOldAndroidAttachmentMetricsWorkarounds();
595-
}
596-
597586
bool JReactNativeFeatureFlagsCxxInterop::disableSubviewClippingAndroid(
598587
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
599588
return ReactNativeFeatureFlags::disableSubviewClippingAndroid();
@@ -1038,9 +1027,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
10381027
makeNativeMethod(
10391028
"disableMountItemReorderingAndroid",
10401029
JReactNativeFeatureFlagsCxxInterop::disableMountItemReorderingAndroid),
1041-
makeNativeMethod(
1042-
"disableOldAndroidAttachmentMetricsWorkarounds",
1043-
JReactNativeFeatureFlagsCxxInterop::disableOldAndroidAttachmentMetricsWorkarounds),
10441030
makeNativeMethod(
10451031
"disableSubviewClippingAndroid",
10461032
JReactNativeFeatureFlagsCxxInterop::disableSubviewClippingAndroid),

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<dfdba04bf07b35c5f49c1ac20b13a33a>>
7+
* @generated SignedSource<<06dbf870e1f4fe12a401c8688e6474e3>>
88
*/
99

1010
/**
@@ -48,9 +48,6 @@ class JReactNativeFeatureFlagsCxxInterop
4848
static bool disableMountItemReorderingAndroid(
4949
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
5050

51-
static bool disableOldAndroidAttachmentMetricsWorkarounds(
52-
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
53-
5451
static bool disableSubviewClippingAndroid(
5552
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
5653

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9e57bf3807cda945c78dd6d3229908a0>>
7+
* @generated SignedSource<<cde6583036fe361451901aa616751ae2>>
88
*/
99

1010
/**
@@ -50,10 +50,6 @@ bool ReactNativeFeatureFlags::disableMountItemReorderingAndroid() {
5050
return getAccessor().disableMountItemReorderingAndroid();
5151
}
5252

53-
bool ReactNativeFeatureFlags::disableOldAndroidAttachmentMetricsWorkarounds() {
54-
return getAccessor().disableOldAndroidAttachmentMetricsWorkarounds();
55-
}
56-
5753
bool ReactNativeFeatureFlags::disableSubviewClippingAndroid() {
5854
return getAccessor().disableSubviewClippingAndroid();
5955
}

0 commit comments

Comments
 (0)