mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44015 Changelog: [internal] ## Context When we introduced synchronous state updates in Fabric, we saw some crashes on coming from the mounting layer on Android. It seems some of these crashes are caused by nested mount operations. When we're mounting some views, like [scroll views](https://github.com/facebook/react-native/blob/881c0bc8970b9e402df6b4f87e1759b238b24735/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java#L383), we dispatch state updates that end up doing more mutations. When we were doing these state updates asynchronously, all the original mutations were processed before these updates, but now that we do them synchronously, the mutations are interleaved causing errors. ## Changes This introduces a new flag that will force all the mutations going through `MountItemExecutor` in `FabricUIManager` to be batched instead of executed synchronously. This fixes the issues I saw locally and I'm expecting this will unblock synchronous state updates in production. Potentially, this might fix other crashes we've been seeing with a low frequency. Reviewed By: sammy-SC Differential Revision: D55942125 fbshipit-source-id: b8d9c145ec307de7318dbbed14880bc9a84fdb2a
79 lines
2.7 KiB
C++
79 lines
2.7 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @generated SignedSource<<fe45466cd2b60fe856aa811ccc2365bd>>
|
|
*/
|
|
|
|
/**
|
|
* IMPORTANT: Do NOT modify this file directly.
|
|
*
|
|
* To change the definition of the flags, edit
|
|
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
|
|
*
|
|
* To regenerate this code, run the following script from the repo root:
|
|
* yarn featureflags-update
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <react/featureflags/ReactNativeFeatureFlagsProvider.h>
|
|
#include <array>
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <optional>
|
|
|
|
namespace facebook::react {
|
|
|
|
class ReactNativeFeatureFlagsAccessor {
|
|
public:
|
|
ReactNativeFeatureFlagsAccessor();
|
|
|
|
bool commonTestFlag();
|
|
bool batchRenderingUpdatesInEventLoop();
|
|
bool enableBackgroundExecutor();
|
|
bool enableCleanTextInputYogaNode();
|
|
bool enableCustomDrawOrderFabric();
|
|
bool enableMicrotasks();
|
|
bool enableMountHooksAndroid();
|
|
bool enableSpannableBuildingUnification();
|
|
bool enableSynchronousStateUpdates();
|
|
bool enableUIConsistency();
|
|
bool forceBatchingMountItemsOnAndroid();
|
|
bool inspectorEnableCxxInspectorPackagerConnection();
|
|
bool inspectorEnableModernCDPRegistry();
|
|
bool useModernRuntimeScheduler();
|
|
bool useNativeViewConfigsInBridgelessMode();
|
|
|
|
void override(std::unique_ptr<ReactNativeFeatureFlagsProvider> provider);
|
|
|
|
private:
|
|
void markFlagAsAccessed(int position, const char* flagName);
|
|
void ensureFlagsNotAccessed();
|
|
|
|
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
|
|
bool wasOverridden_;
|
|
|
|
std::array<std::atomic<const char*>, 15> accessedFeatureFlags_;
|
|
|
|
std::atomic<std::optional<bool>> commonTestFlag_;
|
|
std::atomic<std::optional<bool>> batchRenderingUpdatesInEventLoop_;
|
|
std::atomic<std::optional<bool>> enableBackgroundExecutor_;
|
|
std::atomic<std::optional<bool>> enableCleanTextInputYogaNode_;
|
|
std::atomic<std::optional<bool>> enableCustomDrawOrderFabric_;
|
|
std::atomic<std::optional<bool>> enableMicrotasks_;
|
|
std::atomic<std::optional<bool>> enableMountHooksAndroid_;
|
|
std::atomic<std::optional<bool>> enableSpannableBuildingUnification_;
|
|
std::atomic<std::optional<bool>> enableSynchronousStateUpdates_;
|
|
std::atomic<std::optional<bool>> enableUIConsistency_;
|
|
std::atomic<std::optional<bool>> forceBatchingMountItemsOnAndroid_;
|
|
std::atomic<std::optional<bool>> inspectorEnableCxxInspectorPackagerConnection_;
|
|
std::atomic<std::optional<bool>> inspectorEnableModernCDPRegistry_;
|
|
std::atomic<std::optional<bool>> useModernRuntimeScheduler_;
|
|
std::atomic<std::optional<bool>> useNativeViewConfigsInBridgelessMode_;
|
|
};
|
|
|
|
} // namespace facebook::react
|