Skip to content

Commit c31ff55

Browse files
realsoelynnfacebook-github-bot
authored andcommitted
Fix LegacyViewManagerInteropComponentDescriptor (#52094)
Summary: Pull Request resolved: #52094 Changelog [Internal]: - LegacyViewManagerInteropComponentDescriptor was initiaizing Module just to get the `Class` for `componentName`. This can cause deadlock issue when we have module that needs mainQueue to initialize. Reviewed By: RSNara Differential Revision: D76757706 fbshipit-source-id: 6fc6127b6ff472fda509364f0c3daa13b6a6df1e
1 parent d405e30 commit c31ff55

21 files changed

Lines changed: 187 additions & 59 deletions

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

Lines changed: 7 additions & 1 deletion
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<<4c40e490481c50d2f19830366f50aad5>>
7+
* @generated SignedSource<<debf3b462af8766b6921d6a6879971bb>>
88
*/
99

1010
/**
@@ -150,6 +150,12 @@ public object ReactNativeFeatureFlags {
150150
@JvmStatic
151151
public fun enableIOSViewClipToPaddingBox(): Boolean = accessor.enableIOSViewClipToPaddingBox()
152152

153+
/**
154+
* This is to fix the issue with interop view manager where component descriptor lookup is causing ViewManager to preload.
155+
*/
156+
@JvmStatic
157+
public fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean = accessor.enableInteropViewManagerClassLookUpOptimizationIOS()
158+
153159
/**
154160
* Integrates IntersectionObserver in the Event Loop in the new architecture, to dispatch the initial notifications for observations in the "Update the rendering" step.
155161
*/

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

Lines changed: 11 additions & 1 deletion
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<<8cb9eb082005be480c39272ffc7dde03>>
7+
* @generated SignedSource<<df9400aba67746f1465e0085fac3e0d0>>
88
*/
99

1010
/**
@@ -40,6 +40,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
4040
private var enableFontScaleChangesUpdatingLayoutCache: Boolean? = null
4141
private var enableIOSTextBaselineOffsetPerLineCache: Boolean? = null
4242
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
43+
private var enableInteropViewManagerClassLookUpOptimizationIOSCache: Boolean? = null
4344
private var enableIntersectionObserverEventLoopIntegrationCache: Boolean? = null
4445
private var enableLayoutAnimationsOnAndroidCache: Boolean? = null
4546
private var enableLayoutAnimationsOnIOSCache: Boolean? = null
@@ -253,6 +254,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
253254
return cached
254255
}
255256

257+
override fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean {
258+
var cached = enableInteropViewManagerClassLookUpOptimizationIOSCache
259+
if (cached == null) {
260+
cached = ReactNativeFeatureFlagsCxxInterop.enableInteropViewManagerClassLookUpOptimizationIOS()
261+
enableInteropViewManagerClassLookUpOptimizationIOSCache = cached
262+
}
263+
return cached
264+
}
265+
256266
override fun enableIntersectionObserverEventLoopIntegration(): Boolean {
257267
var cached = enableIntersectionObserverEventLoopIntegrationCache
258268
if (cached == null) {

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

Lines changed: 3 additions & 1 deletion
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<<b6ddd7c2e829c427e7d6b07bc588cd8c>>
7+
* @generated SignedSource<<0be83b3012bb4c2c35719019663ff002>>
88
*/
99

1010
/**
@@ -68,6 +68,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
6868

6969
@DoNotStrip @JvmStatic public external fun enableIOSViewClipToPaddingBox(): Boolean
7070

71+
@DoNotStrip @JvmStatic public external fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean
72+
7173
@DoNotStrip @JvmStatic public external fun enableIntersectionObserverEventLoopIntegration(): Boolean
7274

7375
@DoNotStrip @JvmStatic public external fun enableLayoutAnimationsOnAndroid(): Boolean

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

Lines changed: 3 additions & 1 deletion
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<<76edde93369be682e837189f82871dfe>>
7+
* @generated SignedSource<<dc393eb9e9b219068bbf01c38d17d555>>
88
*/
99

1010
/**
@@ -63,6 +63,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
6363

6464
override fun enableIOSViewClipToPaddingBox(): Boolean = false
6565

66+
override fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean = false
67+
6668
override fun enableIntersectionObserverEventLoopIntegration(): Boolean = true
6769

6870
override fun enableLayoutAnimationsOnAndroid(): Boolean = false

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

Lines changed: 12 additions & 1 deletion
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<<e718763435de15f788b1f510e4799a67>>
7+
* @generated SignedSource<<7dc8b9b303060f53704acef5cd87299f>>
88
*/
99

1010
/**
@@ -44,6 +44,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
4444
private var enableFontScaleChangesUpdatingLayoutCache: Boolean? = null
4545
private var enableIOSTextBaselineOffsetPerLineCache: Boolean? = null
4646
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
47+
private var enableInteropViewManagerClassLookUpOptimizationIOSCache: Boolean? = null
4748
private var enableIntersectionObserverEventLoopIntegrationCache: Boolean? = null
4849
private var enableLayoutAnimationsOnAndroidCache: Boolean? = null
4950
private var enableLayoutAnimationsOnIOSCache: Boolean? = null
@@ -277,6 +278,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
277278
return cached
278279
}
279280

281+
override fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean {
282+
var cached = enableInteropViewManagerClassLookUpOptimizationIOSCache
283+
if (cached == null) {
284+
cached = currentProvider.enableInteropViewManagerClassLookUpOptimizationIOS()
285+
accessedFeatureFlags.add("enableInteropViewManagerClassLookUpOptimizationIOS")
286+
enableInteropViewManagerClassLookUpOptimizationIOSCache = cached
287+
}
288+
return cached
289+
}
290+
280291
override fun enableIntersectionObserverEventLoopIntegration(): Boolean {
281292
var cached = enableIntersectionObserverEventLoopIntegrationCache
282293
if (cached == null) {

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

Lines changed: 3 additions & 1 deletion
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<<892db232156970e8241d1f1ddde3a745>>
7+
* @generated SignedSource<<c95e849870f4a4464ce8259dda79853d>>
88
*/
99

1010
/**
@@ -63,6 +63,8 @@ public interface ReactNativeFeatureFlagsProvider {
6363

6464
@DoNotStrip public fun enableIOSViewClipToPaddingBox(): Boolean
6565

66+
@DoNotStrip public fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean
67+
6668
@DoNotStrip public fun enableIntersectionObserverEventLoopIntegration(): Boolean
6769

6870
@DoNotStrip public fun enableLayoutAnimationsOnAndroid(): Boolean

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

Lines changed: 15 additions & 1 deletion
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<<bb0b241f561c9c443d6453fa259d0a5d>>
7+
* @generated SignedSource<<2ae2f457eafe2d42f60feed53702ce23>>
88
*/
99

1010
/**
@@ -159,6 +159,12 @@ class ReactNativeFeatureFlagsJavaProvider
159159
return method(javaProvider_);
160160
}
161161

162+
bool enableInteropViewManagerClassLookUpOptimizationIOS() override {
163+
static const auto method =
164+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableInteropViewManagerClassLookUpOptimizationIOS");
165+
return method(javaProvider_);
166+
}
167+
162168
bool enableIntersectionObserverEventLoopIntegration() override {
163169
static const auto method =
164170
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableIntersectionObserverEventLoopIntegration");
@@ -455,6 +461,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableIOSViewClipToPaddingBox(
455461
return ReactNativeFeatureFlags::enableIOSViewClipToPaddingBox();
456462
}
457463

464+
bool JReactNativeFeatureFlagsCxxInterop::enableInteropViewManagerClassLookUpOptimizationIOS(
465+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
466+
return ReactNativeFeatureFlags::enableInteropViewManagerClassLookUpOptimizationIOS();
467+
}
468+
458469
bool JReactNativeFeatureFlagsCxxInterop::enableIntersectionObserverEventLoopIntegration(
459470
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
460471
return ReactNativeFeatureFlags::enableIntersectionObserverEventLoopIntegration();
@@ -706,6 +717,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
706717
makeNativeMethod(
707718
"enableIOSViewClipToPaddingBox",
708719
JReactNativeFeatureFlagsCxxInterop::enableIOSViewClipToPaddingBox),
720+
makeNativeMethod(
721+
"enableInteropViewManagerClassLookUpOptimizationIOS",
722+
JReactNativeFeatureFlagsCxxInterop::enableInteropViewManagerClassLookUpOptimizationIOS),
709723
makeNativeMethod(
710724
"enableIntersectionObserverEventLoopIntegration",
711725
JReactNativeFeatureFlagsCxxInterop::enableIntersectionObserverEventLoopIntegration),

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

Lines changed: 4 additions & 1 deletion
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<<04986fa84ec60aa0816ee79ab68e56aa>>
7+
* @generated SignedSource<<8cccadadddd15f73ee145d5216e41088>>
88
*/
99

1010
/**
@@ -90,6 +90,9 @@ class JReactNativeFeatureFlagsCxxInterop
9090
static bool enableIOSViewClipToPaddingBox(
9191
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
9292

93+
static bool enableInteropViewManagerClassLookUpOptimizationIOS(
94+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
95+
9396
static bool enableIntersectionObserverEventLoopIntegration(
9497
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
9598

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

Lines changed: 5 additions & 1 deletion
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<<96d8201a39879e04c384303d1087a0b0>>
7+
* @generated SignedSource<<c546d491e5546bbd83e817a0a13cb5e4>>
88
*/
99

1010
/**
@@ -106,6 +106,10 @@ bool ReactNativeFeatureFlags::enableIOSViewClipToPaddingBox() {
106106
return getAccessor().enableIOSViewClipToPaddingBox();
107107
}
108108

109+
bool ReactNativeFeatureFlags::enableInteropViewManagerClassLookUpOptimizationIOS() {
110+
return getAccessor().enableInteropViewManagerClassLookUpOptimizationIOS();
111+
}
112+
109113
bool ReactNativeFeatureFlags::enableIntersectionObserverEventLoopIntegration() {
110114
return getAccessor().enableIntersectionObserverEventLoopIntegration();
111115
}

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

Lines changed: 6 additions & 1 deletion
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<<25b3585f3648fe156fab4a5abbf32e60>>
7+
* @generated SignedSource<<25bace4eb813dedb3fb05cd0170aedf5>>
88
*/
99

1010
/**
@@ -139,6 +139,11 @@ class ReactNativeFeatureFlags {
139139
*/
140140
RN_EXPORT static bool enableIOSViewClipToPaddingBox();
141141

142+
/**
143+
* This is to fix the issue with interop view manager where component descriptor lookup is causing ViewManager to preload.
144+
*/
145+
RN_EXPORT static bool enableInteropViewManagerClassLookUpOptimizationIOS();
146+
142147
/**
143148
* Integrates IntersectionObserver in the Event Loop in the new architecture, to dispatch the initial notifications for observations in the "Update the rendering" step.
144149
*/

0 commit comments

Comments
 (0)