delete 'decouple commit from mount on Android' (#44504)

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

changelog: [internal]

Reviewed By: rubennorte

Differential Revision: D57154279

fbshipit-source-id: 5902a81fe892ae1d4cf85f63c2b81a16c31baa34
This commit is contained in:
Samuel Susla
2024-05-10 04:54:47 -07:00
committed by Facebook GitHub Bot
parent 34a50ae8ef
commit 00b251b8ee
33 changed files with 30 additions and 241 deletions
@@ -43,12 +43,6 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
// This delegate method is not currently used on iOS.
}
void schedulerDidRequestUpdateToPreallocatedView(const ShadowNode &shadowNode) override
{
// Does nothing.
// This delegate method is not currently used on iOS.
}
void schedulerDidDispatchCommand(
const ShadowView &shadowView,
const std::string &commandName,
@@ -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<<3585602cd983452045d3165edbafc0ca>>
* @generated SignedSource<<c35ee97cf5c4b5f77cdd045341f2848b>>
*/
/**
@@ -94,12 +94,6 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableUIConsistency(): Boolean = accessor.enableUIConsistency()
/**
* Splits hasBeenMounted and promoted.
*/
@JvmStatic
public fun fixMountedFlagAndFixPreallocationClone(): Boolean = accessor.fixMountedFlagAndFixPreallocationClone()
/**
* Forces the mounting layer on Android to always batch mount items instead of dispatching them immediately. This might fix some crashes related to synchronous state updates, where some views dispatch state updates during mount.
*/
@@ -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<<36558176ca3a38b086a50ac90cf08c67>>
* @generated SignedSource<<1b84e5fa96120a511db6f831afb73eab>>
*/
/**
@@ -31,7 +31,6 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var enableMicrotasksCache: Boolean? = null
private var enableSynchronousStateUpdatesCache: Boolean? = null
private var enableUIConsistencyCache: Boolean? = null
private var fixMountedFlagAndFixPreallocationCloneCache: Boolean? = null
private var forceBatchingMountItemsOnAndroidCache: Boolean? = null
private var inspectorEnableCxxInspectorPackagerConnectionCache: Boolean? = null
private var inspectorEnableModernCDPRegistryCache: Boolean? = null
@@ -140,15 +139,6 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}
override fun fixMountedFlagAndFixPreallocationClone(): Boolean {
var cached = fixMountedFlagAndFixPreallocationCloneCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.fixMountedFlagAndFixPreallocationClone()
fixMountedFlagAndFixPreallocationCloneCache = cached
}
return cached
}
override fun forceBatchingMountItemsOnAndroid(): Boolean {
var cached = forceBatchingMountItemsOnAndroidCache
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<<34806c87ad1769ee08a5322994b0bb1b>>
* @generated SignedSource<<2cd7ab4688ca2179ba3a19e9a062f695>>
*/
/**
@@ -50,8 +50,6 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun enableUIConsistency(): Boolean
@DoNotStrip @JvmStatic public external fun fixMountedFlagAndFixPreallocationClone(): Boolean
@DoNotStrip @JvmStatic public external fun forceBatchingMountItemsOnAndroid(): Boolean
@DoNotStrip @JvmStatic public external fun inspectorEnableCxxInspectorPackagerConnection(): 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<<e6a248df3e57d36319d9a32bd49dfa5a>>
* @generated SignedSource<<a2c4f2c950a7b92163fdc6219864d6ca>>
*/
/**
@@ -45,8 +45,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun enableUIConsistency(): Boolean = false
override fun fixMountedFlagAndFixPreallocationClone(): Boolean = false
override fun forceBatchingMountItemsOnAndroid(): Boolean = false
override fun inspectorEnableCxxInspectorPackagerConnection(): 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<<40609d554dca56ea34653f0a77e5b62c>>
* @generated SignedSource<<48f657b282ef658ab7e9024f470d37ad>>
*/
/**
@@ -35,7 +35,6 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var enableMicrotasksCache: Boolean? = null
private var enableSynchronousStateUpdatesCache: Boolean? = null
private var enableUIConsistencyCache: Boolean? = null
private var fixMountedFlagAndFixPreallocationCloneCache: Boolean? = null
private var forceBatchingMountItemsOnAndroidCache: Boolean? = null
private var inspectorEnableCxxInspectorPackagerConnectionCache: Boolean? = null
private var inspectorEnableModernCDPRegistryCache: Boolean? = null
@@ -155,16 +154,6 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun fixMountedFlagAndFixPreallocationClone(): Boolean {
var cached = fixMountedFlagAndFixPreallocationCloneCache
if (cached == null) {
cached = currentProvider.fixMountedFlagAndFixPreallocationClone()
accessedFeatureFlags.add("fixMountedFlagAndFixPreallocationClone")
fixMountedFlagAndFixPreallocationCloneCache = cached
}
return cached
}
override fun forceBatchingMountItemsOnAndroid(): Boolean {
var cached = forceBatchingMountItemsOnAndroidCache
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<<173f9f2cd094134c32a7a78c7241518c>>
* @generated SignedSource<<0f3d31f94f4bded41936fe4ecafbdd4a>>
*/
/**
@@ -45,8 +45,6 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun enableUIConsistency(): Boolean
@DoNotStrip public fun fixMountedFlagAndFixPreallocationClone(): Boolean
@DoNotStrip public fun forceBatchingMountItemsOnAndroid(): Boolean
@DoNotStrip public fun inspectorEnableCxxInspectorPackagerConnection(): Boolean
@@ -518,17 +518,6 @@ void Binding::schedulerDidRequestPreliminaryViewAllocation(
mountingManager->preallocateShadowView(shadowNode);
}
void Binding::schedulerDidRequestUpdateToPreallocatedView(
const ShadowNode& shadowNode) {
auto mountingManager =
getMountingManager("schedulerDidRequestUpdateToPreallocatedView");
if (!mountingManager) {
return;
}
mountingManager->updatePreallocatedShadowNode(shadowNode);
}
void Binding::schedulerDidDispatchCommand(
const ShadowView& shadowView,
const std::string& commandName,
@@ -108,9 +108,6 @@ class Binding : public jni::HybridClass<Binding, JBinding>,
void schedulerDidRequestPreliminaryViewAllocation(
const ShadowNode& shadowNode) override;
void schedulerDidRequestUpdateToPreallocatedView(
const ShadowNode& shadowNode) override;
void schedulerDidDispatchCommand(
const ShadowView& shadowView,
const std::string& commandName,
@@ -829,29 +829,6 @@ void FabricMountingManager::preallocateShadowView(
isLayoutableShadowNode);
}
void FabricMountingManager::updatePreallocatedShadowNode(
const ShadowNode& shadowNode) {
if (ReactNativeFeatureFlags::fixMountedFlagAndFixPreallocationClone()) {
// When batched rendering is enabled, React may do
// multiple commits in a row but only the last one is mounted.
// View preallocation does not account for this scenario and
// a prop update may be dropped because view is marked as preallocated.
// To work around this, we can detect when a view was cloned with different
// props, and remove the view from `allocatedViewRegistry_`.
std::lock_guard lock(allocatedViewsMutex_);
auto allocatedViewsIterator =
allocatedViewRegistry_.find(shadowNode.getSurfaceId());
if (allocatedViewsIterator == allocatedViewRegistry_.end()) {
// The surface does not exist, nothing to do.
return;
}
auto& allocatedViews = allocatedViewsIterator->second;
if (allocatedViews.find(shadowNode.getTag()) != allocatedViews.end()) {
allocatedViews.erase(shadowNode.getTag());
}
}
}
void FabricMountingManager::dispatchCommand(
const ShadowView& shadowView,
const std::string& commandName,
@@ -33,7 +33,6 @@ class FabricMountingManager final {
void onSurfaceStop(SurfaceId surfaceId);
void preallocateShadowView(const ShadowNode& shadowNode);
void updatePreallocatedShadowNode(const ShadowNode& shadowNode);
void executeMount(const MountingTransaction& transaction);
@@ -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<<70cc98f74b676cb12f4e510b88d551aa>>
* @generated SignedSource<<630ef8f9e65223c8d4c2b07bcc0ebadd>>
*/
/**
@@ -105,12 +105,6 @@ class ReactNativeFeatureFlagsProviderHolder
return method(javaProvider_);
}
bool fixMountedFlagAndFixPreallocationClone() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("fixMountedFlagAndFixPreallocationClone");
return method(javaProvider_);
}
bool forceBatchingMountItemsOnAndroid() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("forceBatchingMountItemsOnAndroid");
@@ -218,11 +212,6 @@ bool JReactNativeFeatureFlagsCxxInterop::enableUIConsistency(
return ReactNativeFeatureFlags::enableUIConsistency();
}
bool JReactNativeFeatureFlagsCxxInterop::fixMountedFlagAndFixPreallocationClone(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::fixMountedFlagAndFixPreallocationClone();
}
bool JReactNativeFeatureFlagsCxxInterop::forceBatchingMountItemsOnAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::forceBatchingMountItemsOnAndroid();
@@ -313,9 +302,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableUIConsistency",
JReactNativeFeatureFlagsCxxInterop::enableUIConsistency),
makeNativeMethod(
"fixMountedFlagAndFixPreallocationClone",
JReactNativeFeatureFlagsCxxInterop::fixMountedFlagAndFixPreallocationClone),
makeNativeMethod(
"forceBatchingMountItemsOnAndroid",
JReactNativeFeatureFlagsCxxInterop::forceBatchingMountItemsOnAndroid),
@@ -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<<5065ed4400b76ae62f43ec64ee03ebd2>>
* @generated SignedSource<<39dde965f082a0dffbe00763e184d1db>>
*/
/**
@@ -63,9 +63,6 @@ class JReactNativeFeatureFlagsCxxInterop
static bool enableUIConsistency(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool fixMountedFlagAndFixPreallocationClone(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool forceBatchingMountItemsOnAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -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<<6c93c729ef1a05b5b7d00bafa1f386ad>>
* @generated SignedSource<<d176ed0be7b015e7b9444a0b7ac7f7ba>>
*/
/**
@@ -65,10 +65,6 @@ bool ReactNativeFeatureFlags::enableUIConsistency() {
return getAccessor().enableUIConsistency();
}
bool ReactNativeFeatureFlags::fixMountedFlagAndFixPreallocationClone() {
return getAccessor().fixMountedFlagAndFixPreallocationClone();
}
bool ReactNativeFeatureFlags::forceBatchingMountItemsOnAndroid() {
return getAccessor().forceBatchingMountItemsOnAndroid();
}
@@ -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<<b081516c5b1aa804ec4f444f48773fbb>>
* @generated SignedSource<<0f7b95b5d42c879dabea8f7d53f9cc17>>
*/
/**
@@ -92,11 +92,6 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool enableUIConsistency();
/**
* Splits hasBeenMounted and promoted.
*/
RN_EXPORT static bool fixMountedFlagAndFixPreallocationClone();
/**
* Forces the mounting layer on Android to always batch mount items instead of dispatching them immediately. This might fix some crashes related to synchronous state updates, where some views dispatch state updates during mount.
*/
@@ -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<<2091c7b1d7d19d8967a6bb5ebb2ac76f>>
* @generated SignedSource<<165de70ff21543c949e57971f1a8ff07>>
*/
/**
@@ -227,24 +227,6 @@ bool ReactNativeFeatureFlagsAccessor::enableUIConsistency() {
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::fixMountedFlagAndFixPreallocationClone() {
auto flagValue = fixMountedFlagAndFixPreallocationClone_.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(11, "fixMountedFlagAndFixPreallocationClone");
flagValue = currentProvider_->fixMountedFlagAndFixPreallocationClone();
fixMountedFlagAndFixPreallocationClone_ = flagValue;
}
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::forceBatchingMountItemsOnAndroid() {
auto flagValue = forceBatchingMountItemsOnAndroid_.load();
@@ -254,7 +236,7 @@ bool ReactNativeFeatureFlagsAccessor::forceBatchingMountItemsOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(12, "forceBatchingMountItemsOnAndroid");
markFlagAsAccessed(11, "forceBatchingMountItemsOnAndroid");
flagValue = currentProvider_->forceBatchingMountItemsOnAndroid();
forceBatchingMountItemsOnAndroid_ = flagValue;
@@ -272,7 +254,7 @@ bool ReactNativeFeatureFlagsAccessor::inspectorEnableCxxInspectorPackagerConnect
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(13, "inspectorEnableCxxInspectorPackagerConnection");
markFlagAsAccessed(12, "inspectorEnableCxxInspectorPackagerConnection");
flagValue = currentProvider_->inspectorEnableCxxInspectorPackagerConnection();
inspectorEnableCxxInspectorPackagerConnection_ = flagValue;
@@ -290,7 +272,7 @@ bool ReactNativeFeatureFlagsAccessor::inspectorEnableModernCDPRegistry() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(14, "inspectorEnableModernCDPRegistry");
markFlagAsAccessed(13, "inspectorEnableModernCDPRegistry");
flagValue = currentProvider_->inspectorEnableModernCDPRegistry();
inspectorEnableModernCDPRegistry_ = flagValue;
@@ -308,7 +290,7 @@ bool ReactNativeFeatureFlagsAccessor::lazyAnimationCallbacks() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(15, "lazyAnimationCallbacks");
markFlagAsAccessed(14, "lazyAnimationCallbacks");
flagValue = currentProvider_->lazyAnimationCallbacks();
lazyAnimationCallbacks_ = flagValue;
@@ -326,7 +308,7 @@ bool ReactNativeFeatureFlagsAccessor::preventDoubleTextMeasure() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(16, "preventDoubleTextMeasure");
markFlagAsAccessed(15, "preventDoubleTextMeasure");
flagValue = currentProvider_->preventDoubleTextMeasure();
preventDoubleTextMeasure_ = flagValue;
@@ -344,7 +326,7 @@ bool ReactNativeFeatureFlagsAccessor::useModernRuntimeScheduler() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(17, "useModernRuntimeScheduler");
markFlagAsAccessed(16, "useModernRuntimeScheduler");
flagValue = currentProvider_->useModernRuntimeScheduler();
useModernRuntimeScheduler_ = flagValue;
@@ -362,7 +344,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(18, "useNativeViewConfigsInBridgelessMode");
markFlagAsAccessed(17, "useNativeViewConfigsInBridgelessMode");
flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode();
useNativeViewConfigsInBridgelessMode_ = flagValue;
@@ -380,7 +362,7 @@ bool ReactNativeFeatureFlagsAccessor::useStateAlignmentMechanism() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(19, "useStateAlignmentMechanism");
markFlagAsAccessed(18, "useStateAlignmentMechanism");
flagValue = currentProvider_->useStateAlignmentMechanism();
useStateAlignmentMechanism_ = 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<<7fde6d4edaab918ff5cfd1df7e496333>>
* @generated SignedSource<<a9582288194b7e00f20bf6071458da61>>
*/
/**
@@ -42,7 +42,6 @@ class ReactNativeFeatureFlagsAccessor {
bool enableMicrotasks();
bool enableSynchronousStateUpdates();
bool enableUIConsistency();
bool fixMountedFlagAndFixPreallocationClone();
bool forceBatchingMountItemsOnAndroid();
bool inspectorEnableCxxInspectorPackagerConnection();
bool inspectorEnableModernCDPRegistry();
@@ -61,7 +60,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 20> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 19> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> allowCollapsableChildren_;
@@ -74,7 +73,6 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> enableMicrotasks_;
std::atomic<std::optional<bool>> enableSynchronousStateUpdates_;
std::atomic<std::optional<bool>> enableUIConsistency_;
std::atomic<std::optional<bool>> fixMountedFlagAndFixPreallocationClone_;
std::atomic<std::optional<bool>> forceBatchingMountItemsOnAndroid_;
std::atomic<std::optional<bool>> inspectorEnableCxxInspectorPackagerConnection_;
std::atomic<std::optional<bool>> inspectorEnableModernCDPRegistry_;
@@ -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<<ea2440da83ee9eddc3fce3e7e69935b2>>
* @generated SignedSource<<db008ef815b13a6d72acc099dd0ff704>>
*/
/**
@@ -71,10 +71,6 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}
bool fixMountedFlagAndFixPreallocationClone() override {
return false;
}
bool forceBatchingMountItemsOnAndroid() 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<<0f88f63dfcb4b3ca71c010bc24efd56c>>
* @generated SignedSource<<488476c6915add36fe67d53697a64801>>
*/
/**
@@ -36,7 +36,6 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableMicrotasks() = 0;
virtual bool enableSynchronousStateUpdates() = 0;
virtual bool enableUIConsistency() = 0;
virtual bool fixMountedFlagAndFixPreallocationClone() = 0;
virtual bool forceBatchingMountItemsOnAndroid() = 0;
virtual bool inspectorEnableCxxInspectorPackagerConnection() = 0;
virtual bool inspectorEnableModernCDPRegistry() = 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<<8c9f24f3410f42027e619c911625944b>>
* @generated SignedSource<<ad6ff0fd6930b98b58c9383b7d0fb0ba>>
*/
/**
@@ -92,11 +92,6 @@ bool NativeReactNativeFeatureFlags::enableUIConsistency(
return ReactNativeFeatureFlags::enableUIConsistency();
}
bool NativeReactNativeFeatureFlags::fixMountedFlagAndFixPreallocationClone(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::fixMountedFlagAndFixPreallocationClone();
}
bool NativeReactNativeFeatureFlags::forceBatchingMountItemsOnAndroid(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::forceBatchingMountItemsOnAndroid();
@@ -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<<acbc14ea4c336f7e8e3c9e2252b57e77>>
* @generated SignedSource<<a3aae2684ef3f10db61782fc7823704b>>
*/
/**
@@ -57,8 +57,6 @@ class NativeReactNativeFeatureFlags
bool enableUIConsistency(jsi::Runtime& runtime);
bool fixMountedFlagAndFixPreallocationClone(jsi::Runtime& runtime);
bool forceBatchingMountItemsOnAndroid(jsi::Runtime& runtime);
bool inspectorEnableCxxInspectorPackagerConnection(jsi::Runtime& runtime);
@@ -212,18 +212,6 @@ int ShadowNode::getOrderIndex() const {
return orderIndex_;
}
void ShadowNode::markPromotedRecursively() const {
if (hasBeenPromoted_) {
return;
}
hasBeenPromoted_ = true;
for (const auto& child : *children_) {
child->markPromotedRecursively();
}
}
void ShadowNode::sealRecursive() const {
if (getSealed()) {
return;
@@ -301,18 +289,11 @@ void ShadowNode::setMounted(bool mounted) const {
}
bool ShadowNode::getHasBeenPromoted() const {
auto hasBeenPromoted =
ReactNativeFeatureFlags::fixMountedFlagAndFixPreallocationClone()
? hasBeenPromoted_
: hasBeenMounted_.load();
return hasBeenPromoted;
return hasBeenMounted_.load();
}
bool ShadowNode::progressStateIfNecessary() {
auto hasBeenPromoted =
ReactNativeFeatureFlags::fixMountedFlagAndFixPreallocationClone()
? hasBeenPromoted_
: hasBeenMounted_.load();
auto hasBeenPromoted = hasBeenMounted_.load();
if (!hasBeenPromoted && state_) {
ensureUnsealed();
auto mostRecentState = family_->getMostRecentStateIfObsolete(*state_);
@@ -154,12 +154,6 @@ class ShadowNode : public Sealable,
void sealRecursive() const;
/*
* Marks this shadow node and all of its children as promoted. Promoted shadow
* node is scheduled to be mounted.
*/
void markPromotedRecursively() const;
const ShadowNodeFamily& getFamily() const;
#pragma mark - Mutating Methods
@@ -17,7 +17,6 @@
#include <cxxreact/SystraceSection.h>
#include <react/debug/react_native_assert.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/renderer/mounting/ShadowViewMutation.h>
namespace facebook::react {
@@ -91,14 +90,6 @@ std::optional<MountingTransaction> MountingCoordinator::pullTransaction()
if (lastRevision_.has_value()) {
number_++;
if (ReactNativeFeatureFlags::fixMountedFlagAndFixPreallocationClone()) {
std::scoped_lock dispatchLock(EventEmitter::DispatchMutex());
updateMountedFlag(
baseRevision_.rootShadowNode->getChildren(),
lastRevision_->rootShadowNode->getChildren());
}
auto telemetry = lastRevision_->telemetry;
telemetry.willDiff();
@@ -451,9 +451,7 @@ CommitStatus ShadowTree::tryCommit(
auto newRevisionNumber = currentRevision_.number + 1;
if (ReactNativeFeatureFlags::fixMountedFlagAndFixPreallocationClone()) {
newRootShadowNode->markPromotedRecursively();
} else {
{
std::scoped_lock dispatchLock(EventEmitter::DispatchMutex());
updateMountedFlag(
currentRevision_.rootShadowNode->getChildren(),
@@ -317,15 +317,6 @@ void Scheduler::uiManagerDidCreateShadowNode(const ShadowNode& shadowNode) {
}
}
void Scheduler::uiManagerDidCloneShadowNodeWithNewProps(
const ShadowNode& shadowNode) {
SystraceSection s("Scheduler::uiManagerDidCreateShadowNode");
if (delegate_ != nullptr) {
delegate_->schedulerDidRequestUpdateToPreallocatedView(shadowNode);
}
}
void Scheduler::uiManagerDidDispatchCommand(
const ShadowNode::Shared& shadowNode,
const std::string& commandName,
@@ -88,8 +88,6 @@ class Scheduler final : public UIManagerDelegate {
MountingCoordinator::Shared mountingCoordinator,
bool mountSynchronously) override;
void uiManagerDidCreateShadowNode(const ShadowNode& shadowNode) override;
void uiManagerDidCloneShadowNodeWithNewProps(
const ShadowNode& shadowNode) override;
void uiManagerDidDispatchCommand(
const ShadowNode::Shared& shadowNode,
const std::string& commandName,
@@ -45,12 +45,6 @@ class SchedulerDelegate {
virtual void schedulerDidRequestPreliminaryViewAllocation(
const ShadowNode& shadowNode) = 0;
/*
* Called after shadow node is cloned with new props.
*/
virtual void schedulerDidRequestUpdateToPreallocatedView(
const ShadowNode& shadowView) = 0;
virtual void schedulerDidDispatchCommand(
const ShadowView& shadowView,
const std::string& commandName,
@@ -155,10 +155,6 @@ std::shared_ptr<ShadowNode> UIManager::cloneNode(
.children = children,
});
if (!rawProps.isEmpty() && delegate_ != nullptr) {
delegate_->uiManagerDidCloneShadowNodeWithNewProps(*clonedShadowNode);
}
return clonedShadowNode;
}
@@ -33,15 +33,6 @@ class UIManagerDelegate {
*/
virtual void uiManagerDidCreateShadowNode(const ShadowNode& shadowNode) = 0;
/*
* Called after shadow node is cloned with new props.
* Receiver should use this to adjust props passed to mounting layer
* during view pre-allocation that was triggered from
* `uiManagerDidCreateShadowNode`.
*/
virtual void uiManagerDidCloneShadowNodeWithNewProps(
const ShadowNode& shadowNode) = 0;
/*
* Called when UIManager wants to dispatch a command to the mounting layer.
*/
@@ -88,10 +88,6 @@ const definitions: FeatureFlagDefinitions = {
description:
'Ensures that JavaScript always has a consistent view of the state of the UI (e.g.: commits done in other threads are not immediately propagated to JS during its execution).',
},
fixMountedFlagAndFixPreallocationClone: {
defaultValue: false,
description: 'Splits hasBeenMounted and promoted.',
},
forceBatchingMountItemsOnAndroid: {
defaultValue: false,
description:
@@ -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<<aff7e65ca1f679a79456b2b622dc070f>>
* @generated SignedSource<<953d2d7e7adb016bf30c2be62ee0d89a>>
* @flow strict-local
*/
@@ -51,7 +51,6 @@ export type ReactNativeFeatureFlags = {
enableMicrotasks: Getter<boolean>,
enableSynchronousStateUpdates: Getter<boolean>,
enableUIConsistency: Getter<boolean>,
fixMountedFlagAndFixPreallocationClone: Getter<boolean>,
forceBatchingMountItemsOnAndroid: Getter<boolean>,
inspectorEnableCxxInspectorPackagerConnection: Getter<boolean>,
inspectorEnableModernCDPRegistry: Getter<boolean>,
@@ -146,10 +145,6 @@ export const enableSynchronousStateUpdates: Getter<boolean> = createNativeFlagGe
* Ensures that JavaScript always has a consistent view of the state of the UI (e.g.: commits done in other threads are not immediately propagated to JS during its execution).
*/
export const enableUIConsistency: Getter<boolean> = createNativeFlagGetter('enableUIConsistency', false);
/**
* Splits hasBeenMounted and promoted.
*/
export const fixMountedFlagAndFixPreallocationClone: Getter<boolean> = createNativeFlagGetter('fixMountedFlagAndFixPreallocationClone', false);
/**
* Forces the mounting layer on Android to always batch mount items instead of dispatching them immediately. This might fix some crashes related to synchronous state updates, where some views dispatch state updates during mount.
*/
@@ -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<<22d2fc7d575d13cf21c782f5f5192580>>
* @generated SignedSource<<446991ce24c5765399940bfda55c0e5c>>
* @flow strict-local
*/
@@ -34,7 +34,6 @@ export interface Spec extends TurboModule {
+enableMicrotasks?: () => boolean;
+enableSynchronousStateUpdates?: () => boolean;
+enableUIConsistency?: () => boolean;
+fixMountedFlagAndFixPreallocationClone?: () => boolean;
+forceBatchingMountItemsOnAndroid?: () => boolean;
+inspectorEnableCxxInspectorPackagerConnection?: () => boolean;
+inspectorEnableModernCDPRegistry?: () => boolean;