Skip to content

Commit d5f335c

Browse files
huntiefacebook-github-bot
authored andcommitted
Introduce fuseboxFrameRecordingEnabled flag, gate existing code
Summary: 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] Differential Revision: D95405444
1 parent dc4c36e commit d5f335c

29 files changed

Lines changed: 215 additions & 58 deletions

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<<66d3b8ed600077a287d6d7d8f6230b7b>>
7+
* @generated SignedSource<<81d3efdeedd39107b06405f0f13ae5ce>>
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<<98c5f6184864381e579a9df82741928b>>
7+
* @generated SignedSource<<4801fec88223bbf304c494b538c91495>>
88
*/
99

1010
/**
@@ -82,6 +82,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
8282
private var fixYogaFlexBasisFitContentInMainAxisCache: 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<<2bf2a1dec031145181f6bc28c50cf32a>>
7+
* @generated SignedSource<<9ff1740404b860b9b724f30538206b67>>
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<<89cd07b543fc079341bb3a5d90e50d13>>
7+
* @generated SignedSource<<0a871795464dbf64e4a533b5694f55e6>>
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<<e82235d73386509fc2378a5b8e4b2cfa>>
7+
* @generated SignedSource<<786ff3e6041a60ec2816d14b34fba436>>
88
*/
99

1010
/**
@@ -86,6 +86,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
8686
private var fixYogaFlexBasisFitContentInMainAxisCache: 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<<e3051a7aec6e7da31a65eb2d58fcd64b>>
7+
* @generated SignedSource<<7b7b3093a60d8b4f6d541998942f0f9f>>
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)