Skip to content

Commit 1aa7a32

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Introduce fuseboxFrameRecordingEnabled flag, gate existing code (facebook#55941)
Summary: Pull Request resolved: facebook#55941 Replaces the previous `globalThis.enableTimelineFrames` setup with backend gating. Enables us to: - Iterate more safely by gating Android/iOS/C++ code - Have a per-app rollout at Meta Changelog: [Internal] Reviewed By: vzaidman Differential Revision: D95405444 fbshipit-source-id: 0c41f10059b28ed940a12a44707946baa310bdfb
1 parent 3aa8a04 commit 1aa7a32

31 files changed

+217
-59
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorFlags.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ internal object InspectorFlags {
2020
@DoNotStrip @JvmStatic external fun getFuseboxEnabled(): Boolean
2121

2222
@DoNotStrip @JvmStatic external fun getIsProfilingBuild(): Boolean
23+
24+
@DoNotStrip @JvmStatic external fun getFrameRecordingEnabled(): Boolean
2325
}

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<<e6da91a25406bc0930e6415da9bdcd55>>
7+
* @generated SignedSource<<039798c50526ff1abf33bc7987aa78a9>>
88
*/
99

1010
/**
@@ -402,6 +402,12 @@ public object ReactNativeFeatureFlags {
402402
@JvmStatic
403403
public fun fuseboxEnabledRelease(): Boolean = accessor.fuseboxEnabledRelease()
404404

405+
/**
406+
* Enable frame timings and screenshots support in the React Native DevTools CDP backend. This flag is global and should not be changed across React Host lifetimes.
407+
*/
408+
@JvmStatic
409+
public fun fuseboxFrameRecordingEnabled(): Boolean = accessor.fuseboxFrameRecordingEnabled()
410+
405411
/**
406412
* Enable network inspection support in the React Native DevTools CDP backend. Requires `enableBridgelessArchitecture`. This flag is global and should not be changed across React Host lifetimes.
407413
*/

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<<a4c3c9732db567bf8ab9915f731e57ff>>
7+
* @generated SignedSource<<cbc85fcd815ba2585166a53e7b410f30>>
88
*/
99

1010
/**
@@ -82,6 +82,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
8282
private var fixTextClippingAndroid15useBoundsForWidthCache: Boolean? = null
8383
private var fuseboxAssertSingleHostStateCache: Boolean? = null
8484
private var fuseboxEnabledReleaseCache: Boolean? = null
85+
private var fuseboxFrameRecordingEnabledCache: Boolean? = null
8586
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
8687
private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null
8788
private var overrideBySynchronousMountPropsAtMountingAndroidCache: Boolean? = null
@@ -667,6 +668,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
667668
return cached
668669
}
669670

671+
override fun fuseboxFrameRecordingEnabled(): Boolean {
672+
var cached = fuseboxFrameRecordingEnabledCache
673+
if (cached == null) {
674+
cached = ReactNativeFeatureFlagsCxxInterop.fuseboxFrameRecordingEnabled()
675+
fuseboxFrameRecordingEnabledCache = cached
676+
}
677+
return cached
678+
}
679+
670680
override fun fuseboxNetworkInspectionEnabled(): Boolean {
671681
var cached = fuseboxNetworkInspectionEnabledCache
672682
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<<ce1f59ca437f7d8e24bdcbd651e44cc2>>
7+
* @generated SignedSource<<3d472893c05bdee6e09f834f52d3d92f>>
88
*/
99

1010
/**
@@ -152,6 +152,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
152152

153153
@DoNotStrip @JvmStatic public external fun fuseboxEnabledRelease(): Boolean
154154

155+
@DoNotStrip @JvmStatic public external fun fuseboxFrameRecordingEnabled(): Boolean
156+
155157
@DoNotStrip @JvmStatic public external fun fuseboxNetworkInspectionEnabled(): Boolean
156158

157159
@DoNotStrip @JvmStatic public external fun hideOffscreenVirtualViewsOnIOS(): 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<<cd851e80f207b3e141400802917e4981>>
7+
* @generated SignedSource<<29f7031f91527f41f2f184596c542a5b>>
88
*/
99

1010
/**
@@ -147,6 +147,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
147147

148148
override fun fuseboxEnabledRelease(): Boolean = false
149149

150+
override fun fuseboxFrameRecordingEnabled(): Boolean = false
151+
150152
override fun fuseboxNetworkInspectionEnabled(): Boolean = true
151153

152154
override fun hideOffscreenVirtualViewsOnIOS(): 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<<ff9e56efafa98cf4c466c976739a2957>>
7+
* @generated SignedSource<<014ee4afdf58a61c9974df198068d81a>>
88
*/
99

1010
/**
@@ -86,6 +86,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
8686
private var fixTextClippingAndroid15useBoundsForWidthCache: Boolean? = null
8787
private var fuseboxAssertSingleHostStateCache: Boolean? = null
8888
private var fuseboxEnabledReleaseCache: Boolean? = null
89+
private var fuseboxFrameRecordingEnabledCache: Boolean? = null
8990
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
9091
private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null
9192
private var overrideBySynchronousMountPropsAtMountingAndroidCache: Boolean? = null
@@ -733,6 +734,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
733734
return cached
734735
}
735736

737+
override fun fuseboxFrameRecordingEnabled(): Boolean {
738+
var cached = fuseboxFrameRecordingEnabledCache
739+
if (cached == null) {
740+
cached = currentProvider.fuseboxFrameRecordingEnabled()
741+
accessedFeatureFlags.add("fuseboxFrameRecordingEnabled")
742+
fuseboxFrameRecordingEnabledCache = cached
743+
}
744+
return cached
745+
}
746+
736747
override fun fuseboxNetworkInspectionEnabled(): Boolean {
737748
var cached = fuseboxNetworkInspectionEnabledCache
738749
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<<39585bb818914cc7a02e18399fe49cbe>>
7+
* @generated SignedSource<<acd57b19a67924a91c6b25904cb24d3b>>
88
*/
99

1010
/**
@@ -147,6 +147,8 @@ public interface ReactNativeFeatureFlagsProvider {
147147

148148
@DoNotStrip public fun fuseboxEnabledRelease(): Boolean
149149

150+
@DoNotStrip public fun fuseboxFrameRecordingEnabled(): Boolean
151+
150152
@DoNotStrip public fun fuseboxNetworkInspectionEnabled(): Boolean
151153

152154
@DoNotStrip public fun hideOffscreenVirtualViewsOnIOS(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,16 +1565,18 @@ public class ReactHostImpl(
15651565
when (state) {
15661566
TracingState.ENABLED_IN_BACKGROUND_MODE,
15671567
TracingState.ENABLED_IN_CDP_MODE -> {
1568-
val observer =
1569-
FrameTimingsObserver(
1570-
_screenshotsEnabled,
1571-
{ frameTimingsSequence ->
1572-
inspectorTarget.recordFrameTimings(frameTimingsSequence)
1573-
},
1574-
)
1575-
observer.setCurrentWindow(currentActivity?.window)
1576-
observer.start()
1577-
frameTimingsObserver = observer
1568+
if (InspectorFlags.getFrameRecordingEnabled()) {
1569+
val observer =
1570+
FrameTimingsObserver(
1571+
_screenshotsEnabled,
1572+
{ frameTimingsSequence ->
1573+
inspectorTarget.recordFrameTimings(frameTimingsSequence)
1574+
},
1575+
)
1576+
observer.setCurrentWindow(currentActivity?.window)
1577+
observer.start()
1578+
frameTimingsObserver = observer
1579+
}
15781580
}
15791581
TracingState.DISABLED -> {
15801582
frameTimingsObserver?.stop()

packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ bool JInspectorFlags::getIsProfilingBuild(jni::alias_ref<jclass> /*unused*/) {
2121
return inspectorFlags.getIsProfilingBuild();
2222
}
2323

24+
bool JInspectorFlags::getFrameRecordingEnabled(
25+
jni::alias_ref<jclass> /*unused*/) {
26+
auto& inspectorFlags = InspectorFlags::getInstance();
27+
return inspectorFlags.getFrameRecordingEnabled();
28+
}
29+
2430
void JInspectorFlags::registerNatives() {
2531
javaClassLocal()->registerNatives({
2632
makeNativeMethod("getFuseboxEnabled", JInspectorFlags::getFuseboxEnabled),
@@ -29,6 +35,11 @@ void JInspectorFlags::registerNatives() {
2935
makeNativeMethod(
3036
"getIsProfilingBuild", JInspectorFlags::getIsProfilingBuild),
3137
});
38+
javaClassLocal()->registerNatives({
39+
makeNativeMethod(
40+
"getFrameRecordingEnabled",
41+
JInspectorFlags::getFrameRecordingEnabled),
42+
});
3243
}
3344

3445
} // namespace facebook::react::jsinspector_modern

packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class JInspectorFlags : public jni::JavaClass<JInspectorFlags> {
2020

2121
static bool getFuseboxEnabled(jni::alias_ref<jclass> /*unused*/);
2222
static bool getIsProfilingBuild(jni::alias_ref<jclass> /*unused*/);
23+
static bool getFrameRecordingEnabled(jni::alias_ref<jclass> /*unused*/);
2324

2425
static void registerNatives();
2526

0 commit comments

Comments
 (0)