Skip to content

Commit 7ac93c2

Browse files
javachemeta-codesync[bot]
authored andcommitted
Cleanup disableOldAndroidAttachmentMetricsWorkarounds flag
Summary: Was already rolled out, clean up code. Changelog: [Internal] Differential Revision: D90106433
1 parent 89a0330 commit 7ac93c2

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<<6849ba71125e565fb9041e9208079178>>
7+
* @generated SignedSource<<14aa7702e2e21c44ad7585afded4912d>>
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<<1cd7aea50d6cb85d0e430f767932e896>>
7+
* @generated SignedSource<<38359e9c6f41449b074cdaba13053f2d>>
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<<17ccb8c52d43234b34986c8922466035>>
7+
* @generated SignedSource<<0fe4834ddf4490a43783cb79d653f30e>>
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<<0373ae3fd5b832cd7fbb0c1e1a83ee6a>>
7+
* @generated SignedSource<<f81c22b8e1f493ba3f01a83e4b418b47>>
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<<85b94c7095ef8613f0d2f6d45273b520>>
7+
* @generated SignedSource<<28ab9c67b2ad2a0925d8d28320e23dde>>
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<<4e37da0750dbcbb8d701ec9e66fdb91b>>
7+
* @generated SignedSource<<7159c7a8927bb59ee91bb1e1366368c8>>
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<<da9fef16b891887d9418052bd013633c>>
7+
* @generated SignedSource<<d4646cb3f17ecbc12736d90d87198340>>
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<<b7d6fc793b2705953911c0755c47d41e>>
7+
* @generated SignedSource<<9531e68eb72d37fc2120d5e32922ed4a>>
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<<cdfb645936921b8f271ec8c4666e3650>>
7+
* @generated SignedSource<<c3928ac55807c853f8ede17d58e978cd>>
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)