Add single host inspector state assertion over CDP (#54407)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54407

Introduces a new `InspectorSystemState` object and `ReactNativeApplication.systemStateChanged` CDP event, used to assert whether more than one React Native Host has been registered for the current app lifetime.

This will be used to disable the Performance and Network features in React Native DevTools when the debugger backend is in this currently unsupported state. We intend to implement host lifecycle correctness across all features soon.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D86201689

fbshipit-source-id: b8525359fc01eb7ae666879f2c0fd4c94f0af81a
This commit is contained in:
Alex Hunt authored and Alex Hunt committed 2025-11-11 11:24:34 +00:00
1 parent 8573650959
commit 74d687c213
27 files changed
+260 -50

No files matched your search

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<d8dc8c3a2efe8b7e870546e5749ef5ad>>
* @generated SignedSource<<09d1f1bdf5e156afcd7ce15f73ca1c3b>>
*/
/**
@@ -354,6 +354,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean = accessor.fixMappingOfEventPrioritiesBetweenFabricAndReact()
/**
* Enable system assertion validating that Fusebox is configured with a single host. When set, the CDP backend will dynamically disable features (Perf and Network) in the event that multiple hosts are registered (undefined behaviour), and broadcast this over `ReactNativeApplication.systemStateChanged`.
*/
@JvmStatic
public fun fuseboxAssertSingleHostState(): Boolean = accessor.fuseboxAssertSingleHostState()
/**
* Flag determining if the React Native DevTools (Fusebox) CDP backend should be enabled in release builds. This flag is global and should not be changed across React Host lifetimes.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<447ccc7271b71b0208a2297b7eba5995>>
* @generated SignedSource<<017aba8e549dc289c27bb4fa93e6d038>>
*/
/**
@@ -74,6 +74,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var enableVirtualViewWindowFocusDetectionCache: Boolean? = null
private var enableWebPerformanceAPIsByDefaultCache: Boolean? = null
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
private var fuseboxAssertSingleHostStateCache: Boolean? = null
private var fuseboxEnabledReleaseCache: Boolean? = null
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null
@@ -590,6 +591,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun fuseboxAssertSingleHostState(): Boolean {
var cached = fuseboxAssertSingleHostStateCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.fuseboxAssertSingleHostState()
fuseboxAssertSingleHostStateCache = cached
}
return cached
}
override fun fuseboxEnabledRelease(): Boolean {
var cached = fuseboxEnabledReleaseCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<d6403b67e269ad80ef3e2389ac923c8a>>
* @generated SignedSource<<278f3853a98e1dd72b66ad6168e11686>>
*/
/**
@@ -136,6 +136,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
@DoNotStrip @JvmStatic public external fun fuseboxAssertSingleHostState(): Boolean
@DoNotStrip @JvmStatic public external fun fuseboxEnabledRelease(): Boolean
@DoNotStrip @JvmStatic public external fun fuseboxNetworkInspectionEnabled(): Boolean
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<ab48ba86a7cf3cd35ec530a216aea774>>
* @generated SignedSource<<31da0143bec4eacc9884c950970f0a25>>
*/
/**
@@ -131,6 +131,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean = false
override fun fuseboxAssertSingleHostState(): Boolean = true
override fun fuseboxEnabledRelease(): Boolean = false
override fun fuseboxNetworkInspectionEnabled(): Boolean = false
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<6f6b5abe79764b88cf3ed62fe0230786>>
* @generated SignedSource<<14a5680355bb8c42e39a67edfa6a8974>>
*/
/**
@@ -78,6 +78,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var enableVirtualViewWindowFocusDetectionCache: Boolean? = null
private var enableWebPerformanceAPIsByDefaultCache: Boolean? = null
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
private var fuseboxAssertSingleHostStateCache: Boolean? = null
private var fuseboxEnabledReleaseCache: Boolean? = null
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null
@@ -648,6 +649,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}
override fun fuseboxAssertSingleHostState(): Boolean {
var cached = fuseboxAssertSingleHostStateCache
if (cached == null) {
cached = currentProvider.fuseboxAssertSingleHostState()
accessedFeatureFlags.add("fuseboxAssertSingleHostState")
fuseboxAssertSingleHostStateCache = cached
}
return cached
}
override fun fuseboxEnabledRelease(): Boolean {
var cached = fuseboxEnabledReleaseCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<6b61490a8d6b1df1d6264016455382f8>>
* @generated SignedSource<<5a348c354bb6dd2ddfbc869a9e2f0dbe>>
*/
/**
@@ -131,6 +131,8 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
@DoNotStrip public fun fuseboxAssertSingleHostState(): Boolean
@DoNotStrip public fun fuseboxEnabledRelease(): Boolean
@DoNotStrip public fun fuseboxNetworkInspectionEnabled(): Boolean
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<13ed11b5c260fae79048ea80745d22fe>>
* @generated SignedSource<<5b2d44dcf36386f86f26c694d3f00229>>
*/
/**
@@ -363,6 +363,12 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}
bool fuseboxAssertSingleHostState() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("fuseboxAssertSingleHostState");
return method(javaProvider_);
}
bool fuseboxEnabledRelease() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("fuseboxEnabledRelease");
@@ -811,6 +817,11 @@ bool JReactNativeFeatureFlagsCxxInterop::fixMappingOfEventPrioritiesBetweenFabri
return ReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact();
}
bool JReactNativeFeatureFlagsCxxInterop::fuseboxAssertSingleHostState(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::fuseboxAssertSingleHostState();
}
bool JReactNativeFeatureFlagsCxxInterop::fuseboxEnabledRelease(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::fuseboxEnabledRelease();
@@ -1149,6 +1160,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"fixMappingOfEventPrioritiesBetweenFabricAndReact",
JReactNativeFeatureFlagsCxxInterop::fixMappingOfEventPrioritiesBetweenFabricAndReact),
makeNativeMethod(
"fuseboxAssertSingleHostState",
JReactNativeFeatureFlagsCxxInterop::fuseboxAssertSingleHostState),
makeNativeMethod(
"fuseboxEnabledRelease",
JReactNativeFeatureFlagsCxxInterop::fuseboxEnabledRelease),
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<1e57bf8252c16fc10bbfcae08710af85>>
* @generated SignedSource<<5a03db93d78fc1b14283ca3dc92db207>>
*/
/**
@@ -192,6 +192,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool fixMappingOfEventPrioritiesBetweenFabricAndReact(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool fuseboxAssertSingleHostState(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool fuseboxEnabledRelease(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -10,6 +10,7 @@
#ifdef REACT_NATIVE_DEBUGGER_ENABLED
#include "InspectorFlags.h"
#include "InspectorInterfaces.h"
#include "NetworkIOAgent.h"
#include "SessionState.h"
#include "TracingAgent.h"
@@ -216,6 +217,11 @@ class HostAgent::Impl final {
cdp::jsonNotification(
"ReactNativeApplication.metadataUpdated",
createHostMetadataPayload(hostMetadata_)));
auto& inspector = getInspectorInstance();
bool isSingleHost = inspector.getSystemState().registeredPagesCount <= 1;
if (!isSingleHost) {
emitSystemStateChanged(isSingleHost);
}
auto stashedTraceRecording =
targetController_.getDelegate()
@@ -374,6 +380,17 @@ class HostAgent::Impl final {
tracingAgent_.emitExternalTraceRecording(std::move(traceRecording));
}
void emitSystemStateChanged(bool isSingleHost) {
frontendChannel_(
cdp::jsonNotification(
"ReactNativeApplication.systemStateChanged",
folly::dynamic::object("isSingleHost", isSingleHost)));
if (!isSingleHost) {
frontendChannel_(cdp::jsonNotification("Network.disable"));
}
}
private:
enum class FuseboxClientType { Unknown, Fusebox, NonFusebox };
@@ -480,6 +497,7 @@ class HostAgent::Impl final {
}
void emitExternalTraceRecording(tracing::TraceRecordingState traceRecording) {
}
void emitSystemStateChanged(bool isSingleHost) {}
};
#endif // REACT_NATIVE_DEBUGGER_ENABLED
@@ -519,6 +537,10 @@ void HostAgent::emitExternalTraceRecording(
impl_->emitExternalTraceRecording(std::move(traceRecording));
}
void HostAgent::emitSystemStateChanged(bool isSingleHost) const {
impl_->emitSystemStateChanged(isSingleHost);
}
#pragma mark - Tracing
HostTracingAgent::HostTracingAgent(tracing::TraceRecordingState& state)
@@ -79,6 +79,12 @@ class HostAgent final {
*/
void emitExternalTraceRecording(tracing::TraceRecordingState traceRecording) const;
/**
* Emits a system state changed event when the number of ReactHost instances
* changes.
*/
void emitSystemStateChanged(bool isSingleHost) const;
private:
// We use the private implementation idiom to ensure this class has the same
// layout regardless of whether REACT_NATIVE_DEBUGGER_ENABLED is defined. The
@@ -320,6 +320,11 @@ class JSINSPECTOR_EXPORT HostTarget : public EnableExecutorFromThis<HostTarget>
*/
void emitTraceRecordingForFirstFuseboxClient(tracing::TraceRecordingState traceRecording) const;
/**
* Emits a system state changed event to all active sessions.
*/
void emitSystemStateChanged(bool isSingleHost) const;
private:
/**
* Constructs a new HostTarget.
@@ -17,6 +17,10 @@ InspectorFlags& InspectorFlags::getInstance() {
return instance;
}
bool InspectorFlags::getAssertSingleHostState() const {
return loadFlagsAndAssertUnchanged().assertSingleHostState;
}
bool InspectorFlags::getFuseboxEnabled() const {
if (fuseboxDisabledForTest_) {
return false;
@@ -48,6 +52,8 @@ void InspectorFlags::dangerouslyDisableFuseboxForTest() {
const InspectorFlags::Values& InspectorFlags::loadFlagsAndAssertUnchanged()
const {
InspectorFlags::Values newValues = {
.assertSingleHostState =
ReactNativeFeatureFlags::fuseboxAssertSingleHostState(),
.fuseboxEnabled =
#if defined(REACT_NATIVE_DEBUGGER_ENABLED)
true,
@@ -19,6 +19,12 @@ class InspectorFlags {
public:
static InspectorFlags &getInstance();
/**
* Flag determining if the inspector backend should strictly assert that only
* a single host is registered.
*/
bool getAssertSingleHostState() const;
/**
* Flag determining if the modern CDP backend should be enabled.
*/
@@ -54,6 +60,7 @@ class InspectorFlags {
private:
struct Values {
bool assertSingleHostState;
bool fuseboxEnabled;
bool isProfilingBuild;
bool networkInspectionEnabled;
@@ -7,6 +7,8 @@
#include "InspectorInterfaces.h"
#include "InspectorFlags.h"
#include <cassert>
#include <list>
#include <mutex>
@@ -35,6 +37,14 @@ namespace {
class InspectorImpl : public IInspector {
public:
InspectorImpl() {
systemStateListener_ = std::make_shared<SystemStateListener>(systemState_);
auto& inspectorFlags = InspectorFlags::getInstance();
if (inspectorFlags.getAssertSingleHostState()) {
registerPageStatusListener(systemStateListener_);
}
}
int addPage(
const std::string& description,
const std::string& vm,
@@ -50,7 +60,21 @@ class InspectorImpl : public IInspector {
void registerPageStatusListener(
std::weak_ptr<IPageStatusListener> listener) override;
InspectorSystemState getSystemState() const override;
private:
class SystemStateListener : public IPageStatusListener {
public:
explicit SystemStateListener(InspectorSystemState& state) : state_(state) {}
void onPageAdded(int /*pageId*/) override {
state_.registeredPagesCount++;
}
private:
InspectorSystemState& state_;
};
class Page {
public:
Page(
@@ -74,6 +98,8 @@ class InspectorImpl : public IInspector {
int nextPageId_{1};
std::map<int, Page> pages_;
std::list<std::weak_ptr<IPageStatusListener>> listeners_;
InspectorSystemState systemState_{0};
std::shared_ptr<SystemStateListener> systemStateListener_;
};
InspectorImpl::Page::Page(
@@ -116,6 +142,12 @@ int InspectorImpl::addPage(
pageId,
Page{pageId, description, vm, std::move(connectFunc), capabilities});
for (const auto& listenerWeak : listeners_) {
if (auto listener = listenerWeak.lock()) {
listener->onPageAdded(pageId);
}
}
return pageId;
}
@@ -175,6 +207,11 @@ void InspectorImpl::registerPageStatusListener(
}
listeners_.push_back(listener);
}
InspectorSystemState InspectorImpl::getSystemState() const {
std::scoped_lock lock(mutex_);
return systemState_;
}
} // namespace
IInspector& getInspectorInstance() {
@@ -51,6 +51,11 @@ struct InspectorPageDescription {
// Alias for backwards compatibility.
using InspectorPage = InspectorPageDescription;
struct InspectorSystemState {
/** The total count of pages registered during the app lifetime. */
int registeredPagesCount;
};
/// IRemoteConnection allows the VM to send debugger messages to the client.
/// IRemoteConnection's methods are safe to call from any thread *if*
/// InspectorPackagerConnection.cpp is in use.
@@ -78,7 +83,8 @@ class JSINSPECTOR_EXPORT ILocalConnection : public IDestructible {
class JSINSPECTOR_EXPORT IPageStatusListener : public IDestructible {
public:
virtual ~IPageStatusListener() = 0;
virtual void onPageRemoved(int pageId) = 0;
virtual void onPageAdded(int /*pageId*/) {}
virtual void onPageRemoved(int /*pageId*/) {}
};
/// IInspector tracks debuggable JavaScript targets (pages).
@@ -127,6 +133,11 @@ class JSINSPECTOR_EXPORT IInspector : public IDestructible {
* when pages are removed.
*/
virtual void registerPageStatusListener(std::weak_ptr<IPageStatusListener> listener) = 0;
/**
* Get the current \c InspectorSystemState object.
*/
virtual InspectorSystemState getSystemState() const = 0;
};
class NotImplementedException : public std::exception {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<5d596cc470e66861d7c1b2ffbb15b268>>
* @generated SignedSource<<efd875dca79abd383d527b063063051f>>
*/
/**
@@ -242,6 +242,10 @@ bool ReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact()
return getAccessor().fixMappingOfEventPrioritiesBetweenFabricAndReact();
}
bool ReactNativeFeatureFlags::fuseboxAssertSingleHostState() {
return getAccessor().fuseboxAssertSingleHostState();
}
bool ReactNativeFeatureFlags::fuseboxEnabledRelease() {
return getAccessor().fuseboxEnabledRelease();
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<41492e85e1feeb20d2e3e60b6cc6cbe7>>
* @generated SignedSource<<95ab3eb7a8aab0a72095cc9ad7c583ce>>
*/
/**
@@ -309,6 +309,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool fixMappingOfEventPrioritiesBetweenFabricAndReact();
/**
* Enable system assertion validating that Fusebox is configured with a single host. When set, the CDP backend will dynamically disable features (Perf and Network) in the event that multiple hosts are registered (undefined behaviour), and broadcast this over `ReactNativeApplication.systemStateChanged`.
*/
RN_EXPORT static bool fuseboxAssertSingleHostState();
/**
* Flag determining if the React Native DevTools (Fusebox) CDP backend should be enabled in release builds. This flag is global and should not be changed across React Host lifetimes.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<cf152ea3a4e9635a71d2794a3139dadb>>
* @generated SignedSource<<0985314bcdfe904d33ea0685b4008087>>
*/
/**
@@ -1001,6 +1001,24 @@ bool ReactNativeFeatureFlagsAccessor::fixMappingOfEventPrioritiesBetweenFabricAn
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::fuseboxAssertSingleHostState() {
auto flagValue = fuseboxAssertSingleHostState_.load();
if (!flagValue.has_value()) {
// This block is not exclusive but it is not necessary.
// If multiple threads try to initialize the feature flag, we would only
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(54, "fuseboxAssertSingleHostState");
flagValue = currentProvider_->fuseboxAssertSingleHostState();
fuseboxAssertSingleHostState_ = flagValue;
}
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledRelease() {
auto flagValue = fuseboxEnabledRelease_.load();
@@ -1010,7 +1028,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledRelease() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(54, "fuseboxEnabledRelease");
markFlagAsAccessed(55, "fuseboxEnabledRelease");
flagValue = currentProvider_->fuseboxEnabledRelease();
fuseboxEnabledRelease_ = flagValue;
@@ -1028,7 +1046,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxNetworkInspectionEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(55, "fuseboxNetworkInspectionEnabled");
markFlagAsAccessed(56, "fuseboxNetworkInspectionEnabled");
flagValue = currentProvider_->fuseboxNetworkInspectionEnabled();
fuseboxNetworkInspectionEnabled_ = flagValue;
@@ -1046,7 +1064,7 @@ bool ReactNativeFeatureFlagsAccessor::hideOffscreenVirtualViewsOnIOS() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(56, "hideOffscreenVirtualViewsOnIOS");
markFlagAsAccessed(57, "hideOffscreenVirtualViewsOnIOS");
flagValue = currentProvider_->hideOffscreenVirtualViewsOnIOS();
hideOffscreenVirtualViewsOnIOS_ = flagValue;
@@ -1064,7 +1082,7 @@ bool ReactNativeFeatureFlagsAccessor::overrideBySynchronousMountPropsAtMountingA
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(57, "overrideBySynchronousMountPropsAtMountingAndroid");
markFlagAsAccessed(58, "overrideBySynchronousMountPropsAtMountingAndroid");
flagValue = currentProvider_->overrideBySynchronousMountPropsAtMountingAndroid();
overrideBySynchronousMountPropsAtMountingAndroid_ = flagValue;
@@ -1082,7 +1100,7 @@ bool ReactNativeFeatureFlagsAccessor::perfIssuesEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(58, "perfIssuesEnabled");
markFlagAsAccessed(59, "perfIssuesEnabled");
flagValue = currentProvider_->perfIssuesEnabled();
perfIssuesEnabled_ = flagValue;
@@ -1100,7 +1118,7 @@ bool ReactNativeFeatureFlagsAccessor::perfMonitorV2Enabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(59, "perfMonitorV2Enabled");
markFlagAsAccessed(60, "perfMonitorV2Enabled");
flagValue = currentProvider_->perfMonitorV2Enabled();
perfMonitorV2Enabled_ = flagValue;
@@ -1118,7 +1136,7 @@ double ReactNativeFeatureFlagsAccessor::preparedTextCacheSize() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(60, "preparedTextCacheSize");
markFlagAsAccessed(61, "preparedTextCacheSize");
flagValue = currentProvider_->preparedTextCacheSize();
preparedTextCacheSize_ = flagValue;
@@ -1136,7 +1154,7 @@ bool ReactNativeFeatureFlagsAccessor::preventShadowTreeCommitExhaustion() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(61, "preventShadowTreeCommitExhaustion");
markFlagAsAccessed(62, "preventShadowTreeCommitExhaustion");
flagValue = currentProvider_->preventShadowTreeCommitExhaustion();
preventShadowTreeCommitExhaustion_ = flagValue;
@@ -1154,7 +1172,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldPressibilityUseW3CPointerEventsForHo
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(62, "shouldPressibilityUseW3CPointerEventsForHover");
markFlagAsAccessed(63, "shouldPressibilityUseW3CPointerEventsForHover");
flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover();
shouldPressibilityUseW3CPointerEventsForHover_ = flagValue;
@@ -1172,7 +1190,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldTriggerResponderTransferOnScrollAndr
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(63, "shouldTriggerResponderTransferOnScrollAndroid");
markFlagAsAccessed(64, "shouldTriggerResponderTransferOnScrollAndroid");
flagValue = currentProvider_->shouldTriggerResponderTransferOnScrollAndroid();
shouldTriggerResponderTransferOnScrollAndroid_ = flagValue;
@@ -1190,7 +1208,7 @@ bool ReactNativeFeatureFlagsAccessor::skipActivityIdentityAssertionOnHostPause()
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(64, "skipActivityIdentityAssertionOnHostPause");
markFlagAsAccessed(65, "skipActivityIdentityAssertionOnHostPause");
flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause();
skipActivityIdentityAssertionOnHostPause_ = flagValue;
@@ -1208,7 +1226,7 @@ bool ReactNativeFeatureFlagsAccessor::sweepActiveTouchOnChildNativeGesturesAndro
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(65, "sweepActiveTouchOnChildNativeGesturesAndroid");
markFlagAsAccessed(66, "sweepActiveTouchOnChildNativeGesturesAndroid");
flagValue = currentProvider_->sweepActiveTouchOnChildNativeGesturesAndroid();
sweepActiveTouchOnChildNativeGesturesAndroid_ = flagValue;
@@ -1226,7 +1244,7 @@ bool ReactNativeFeatureFlagsAccessor::traceTurboModulePromiseRejectionsOnAndroid
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(66, "traceTurboModulePromiseRejectionsOnAndroid");
markFlagAsAccessed(67, "traceTurboModulePromiseRejectionsOnAndroid");
flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid();
traceTurboModulePromiseRejectionsOnAndroid_ = flagValue;
@@ -1244,7 +1262,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommit(
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(67, "updateRuntimeShadowNodeReferencesOnCommit");
markFlagAsAccessed(68, "updateRuntimeShadowNodeReferencesOnCommit");
flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit();
updateRuntimeShadowNodeReferencesOnCommit_ = flagValue;
@@ -1262,7 +1280,7 @@ bool ReactNativeFeatureFlagsAccessor::useAlwaysAvailableJSErrorHandling() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(68, "useAlwaysAvailableJSErrorHandling");
markFlagAsAccessed(69, "useAlwaysAvailableJSErrorHandling");
flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling();
useAlwaysAvailableJSErrorHandling_ = flagValue;
@@ -1280,7 +1298,7 @@ bool ReactNativeFeatureFlagsAccessor::useFabricInterop() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(69, "useFabricInterop");
markFlagAsAccessed(70, "useFabricInterop");
flagValue = currentProvider_->useFabricInterop();
useFabricInterop_ = flagValue;
@@ -1298,7 +1316,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeEqualsInNativeReadableArrayAndroi
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(70, "useNativeEqualsInNativeReadableArrayAndroid");
markFlagAsAccessed(71, "useNativeEqualsInNativeReadableArrayAndroid");
flagValue = currentProvider_->useNativeEqualsInNativeReadableArrayAndroid();
useNativeEqualsInNativeReadableArrayAndroid_ = flagValue;
@@ -1316,7 +1334,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeTransformHelperAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(71, "useNativeTransformHelperAndroid");
markFlagAsAccessed(72, "useNativeTransformHelperAndroid");
flagValue = currentProvider_->useNativeTransformHelperAndroid();
useNativeTransformHelperAndroid_ = flagValue;
@@ -1334,7 +1352,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeViewConfigsInBridgelessMode() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(72, "useNativeViewConfigsInBridgelessMode");
markFlagAsAccessed(73, "useNativeViewConfigsInBridgelessMode");
flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode();
useNativeViewConfigsInBridgelessMode_ = flagValue;
@@ -1352,7 +1370,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimizedEventBatchingOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(73, "useOptimizedEventBatchingOnAndroid");
markFlagAsAccessed(74, "useOptimizedEventBatchingOnAndroid");
flagValue = currentProvider_->useOptimizedEventBatchingOnAndroid();
useOptimizedEventBatchingOnAndroid_ = flagValue;
@@ -1370,7 +1388,7 @@ bool ReactNativeFeatureFlagsAccessor::useRawPropsJsiValue() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(74, "useRawPropsJsiValue");
markFlagAsAccessed(75, "useRawPropsJsiValue");
flagValue = currentProvider_->useRawPropsJsiValue();
useRawPropsJsiValue_ = flagValue;
@@ -1388,7 +1406,7 @@ bool ReactNativeFeatureFlagsAccessor::useShadowNodeStateOnClone() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(75, "useShadowNodeStateOnClone");
markFlagAsAccessed(76, "useShadowNodeStateOnClone");
flagValue = currentProvider_->useShadowNodeStateOnClone();
useShadowNodeStateOnClone_ = flagValue;
@@ -1406,7 +1424,7 @@ bool ReactNativeFeatureFlagsAccessor::useSharedAnimatedBackend() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(76, "useSharedAnimatedBackend");
markFlagAsAccessed(77, "useSharedAnimatedBackend");
flagValue = currentProvider_->useSharedAnimatedBackend();
useSharedAnimatedBackend_ = flagValue;
@@ -1424,7 +1442,7 @@ bool ReactNativeFeatureFlagsAccessor::useTraitHiddenOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(77, "useTraitHiddenOnAndroid");
markFlagAsAccessed(78, "useTraitHiddenOnAndroid");
flagValue = currentProvider_->useTraitHiddenOnAndroid();
useTraitHiddenOnAndroid_ = flagValue;
@@ -1442,7 +1460,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(78, "useTurboModuleInterop");
markFlagAsAccessed(79, "useTurboModuleInterop");
flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
@@ -1460,7 +1478,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModules() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(79, "useTurboModules");
markFlagAsAccessed(80, "useTurboModules");
flagValue = currentProvider_->useTurboModules();
useTurboModules_ = flagValue;
@@ -1478,7 +1496,7 @@ double ReactNativeFeatureFlagsAccessor::viewCullingOutsetRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(80, "viewCullingOutsetRatio");
markFlagAsAccessed(81, "viewCullingOutsetRatio");
flagValue = currentProvider_->viewCullingOutsetRatio();
viewCullingOutsetRatio_ = flagValue;
@@ -1496,7 +1514,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewHysteresisRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(81, "virtualViewHysteresisRatio");
markFlagAsAccessed(82, "virtualViewHysteresisRatio");
flagValue = currentProvider_->virtualViewHysteresisRatio();
virtualViewHysteresisRatio_ = flagValue;
@@ -1514,7 +1532,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(82, "virtualViewPrerenderRatio");
markFlagAsAccessed(83, "virtualViewPrerenderRatio");
flagValue = currentProvider_->virtualViewPrerenderRatio();
virtualViewPrerenderRatio_ = flagValue;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<e7e8d311c0d1cca4e28bee7ddcf5065c>>
* @generated SignedSource<<5864ef780bdc795d47c096b16bf248b5>>
*/
/**
@@ -86,6 +86,7 @@ class ReactNativeFeatureFlagsAccessor {
bool enableVirtualViewWindowFocusDetection();
bool enableWebPerformanceAPIsByDefault();
bool fixMappingOfEventPrioritiesBetweenFabricAndReact();
bool fuseboxAssertSingleHostState();
bool fuseboxEnabledRelease();
bool fuseboxNetworkInspectionEnabled();
bool hideOffscreenVirtualViewsOnIOS();
@@ -126,7 +127,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 83> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 84> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> cdpInteractionMetricsEnabled_;
@@ -182,6 +183,7 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> enableVirtualViewWindowFocusDetection_;
std::atomic<std::optional<bool>> enableWebPerformanceAPIsByDefault_;
std::atomic<std::optional<bool>> fixMappingOfEventPrioritiesBetweenFabricAndReact_;
std::atomic<std::optional<bool>> fuseboxAssertSingleHostState_;
std::atomic<std::optional<bool>> fuseboxEnabledRelease_;
std::atomic<std::optional<bool>> fuseboxNetworkInspectionEnabled_;
std::atomic<std::optional<bool>> hideOffscreenVirtualViewsOnIOS_;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<a0a1898f3a4c14179bd03d5dbe97adfa>>
* @generated SignedSource<<84f99a0fde50ce70a8da2762dbb1a7af>>
*/
/**
@@ -243,6 +243,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}
bool fuseboxAssertSingleHostState() override {
return true;
}
bool fuseboxEnabledRelease() override {
return false;
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<fc8f8541827a039fa5bc4a113e75fdf6>>
* @generated SignedSource<<394e4281884f0d2519d680974d2ebfe5>>
*/
/**
@@ -531,6 +531,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef
return ReactNativeFeatureFlagsDefaults::fixMappingOfEventPrioritiesBetweenFabricAndReact();
}
bool fuseboxAssertSingleHostState() override {
auto value = values_["fuseboxAssertSingleHostState"];
if (!value.isNull()) {
return value.getBool();
}
return ReactNativeFeatureFlagsDefaults::fuseboxAssertSingleHostState();
}
bool fuseboxEnabledRelease() override {
auto value = values_["fuseboxEnabledRelease"];
if (!value.isNull()) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<5dcaab263795b1605da54dbbb617264f>>
* @generated SignedSource<<045cc4e4390d6ddf2ca252ff4c8f399d>>
*/
/**
@@ -79,6 +79,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableVirtualViewWindowFocusDetection() = 0;
virtual bool enableWebPerformanceAPIsByDefault() = 0;
virtual bool fixMappingOfEventPrioritiesBetweenFabricAndReact() = 0;
virtual bool fuseboxAssertSingleHostState() = 0;
virtual bool fuseboxEnabledRelease() = 0;
virtual bool fuseboxNetworkInspectionEnabled() = 0;
virtual bool hideOffscreenVirtualViewsOnIOS() = 0;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<6bd64914d0e2f0c727490a420496fbb0>>
* @generated SignedSource<<368a69d36f8c7aef0103deb940751012>>
*/
/**
@@ -314,6 +314,11 @@ bool NativeReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndR
return ReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact();
}
bool NativeReactNativeFeatureFlags::fuseboxAssertSingleHostState(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::fuseboxAssertSingleHostState();
}
bool NativeReactNativeFeatureFlags::fuseboxEnabledRelease(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::fuseboxEnabledRelease();
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<99624bd7682ad34476ac395e8acc43c7>>
* @generated SignedSource<<5b7229fbb99de21237fa8d69da46a057>>
*/
/**
@@ -144,6 +144,8 @@ class NativeReactNativeFeatureFlags
bool fixMappingOfEventPrioritiesBetweenFabricAndReact(jsi::Runtime& runtime);
bool fuseboxAssertSingleHostState(jsi::Runtime& runtime);
bool fuseboxEnabledRelease(jsi::Runtime& runtime);
bool fuseboxNetworkInspectionEnabled(jsi::Runtime& runtime);
@@ -623,6 +623,16 @@ const definitions: FeatureFlagDefinitions = {
},
ossReleaseStage: 'none',
},
fuseboxAssertSingleHostState: {
defaultValue: true,
metadata: {
description:
'Enable system assertion validating that Fusebox is configured with a single host. When set, the CDP backend will dynamically disable features (Perf and Network) in the event that multiple hosts are registered (undefined behaviour), and broadcast this over `ReactNativeApplication.systemStateChanged`.',
expectedReleaseValue: true,
purpose: 'operational',
},
ossReleaseStage: 'stable',
},
fuseboxEnabledRelease: {
defaultValue: false,
metadata: {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<6bc2fbc946e21d0b51dd9bc71ac041e7>>
* @generated SignedSource<<472646b95362ace71083c0a471aa8878>>
* @flow strict
* @noformat
*/
@@ -104,6 +104,7 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
enableVirtualViewWindowFocusDetection: Getter<boolean>,
enableWebPerformanceAPIsByDefault: Getter<boolean>,
fixMappingOfEventPrioritiesBetweenFabricAndReact: Getter<boolean>,
fuseboxAssertSingleHostState: Getter<boolean>,
fuseboxEnabledRelease: Getter<boolean>,
fuseboxNetworkInspectionEnabled: Getter<boolean>,
hideOffscreenVirtualViewsOnIOS: Getter<boolean>,
@@ -430,6 +431,10 @@ export const enableWebPerformanceAPIsByDefault: Getter<boolean> = createNativeFl
* Uses the default event priority instead of the discreet event priority by default when dispatching events from Fabric to React.
*/
export const fixMappingOfEventPrioritiesBetweenFabricAndReact: Getter<boolean> = createNativeFlagGetter('fixMappingOfEventPrioritiesBetweenFabricAndReact', false);
/**
* Enable system assertion validating that Fusebox is configured with a single host. When set, the CDP backend will dynamically disable features (Perf and Network) in the event that multiple hosts are registered (undefined behaviour), and broadcast this over `ReactNativeApplication.systemStateChanged`.
*/
export const fuseboxAssertSingleHostState: Getter<boolean> = createNativeFlagGetter('fuseboxAssertSingleHostState', true);
/**
* Flag determining if the React Native DevTools (Fusebox) CDP backend should be enabled in release builds. This flag is global and should not be changed across React Host lifetimes.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<0b1f3b307c28d6798d4c15029ad5bc58>>
* @generated SignedSource<<d51c41724cd4d10eb227f96847277e99>>
* @flow strict
* @noformat
*/
@@ -79,6 +79,7 @@ export interface Spec extends TurboModule {
+enableVirtualViewWindowFocusDetection?: () => boolean;
+enableWebPerformanceAPIsByDefault?: () => boolean;
+fixMappingOfEventPrioritiesBetweenFabricAndReact?: () => boolean;
+fuseboxAssertSingleHostState?: () => boolean;
+fuseboxEnabledRelease?: () => boolean;
+fuseboxNetworkInspectionEnabled?: () => boolean;
+hideOffscreenVirtualViewsOnIOS?: () => boolean;