diff --git a/packages/react-native/React/Fabric/RCTScheduler.mm b/packages/react-native/React/Fabric/RCTScheduler.mm index e64db067e50..5a5c3b42ea2 100644 --- a/packages/react-native/React/Fabric/RCTScheduler.mm +++ b/packages/react-native/React/Fabric/RCTScheduler.mm @@ -37,7 +37,7 @@ class SchedulerDelegateProxy : public SchedulerDelegate { [scheduler.delegate schedulerShouldRenderTransactions:mountingCoordinator]; } - void schedulerDidRequestPreliminaryViewAllocation(SurfaceId surfaceId, const ShadowNode &shadowNode) override + void schedulerDidRequestPreliminaryViewAllocation(const ShadowNode &shadowNode) override { // Does nothing. // This delegate method is not currently used on iOS. diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp index 1c15652a37b..ede3d65e57e 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp @@ -14,12 +14,8 @@ #include "FabricMountingManager.h" #include "JBackgroundExecutor.h" #include "ReactNativeConfigHolder.h" -#include "StateWrapperImpl.h" #include "SurfaceHandlerBinding.h" -#include -#include - #include #include #include @@ -510,7 +506,6 @@ void Binding::schedulerShouldRenderTransactions( } void Binding::schedulerDidRequestPreliminaryViewAllocation( - const SurfaceId surfaceId, const ShadowNode& shadowNode) { if (!shadowNode.getTraits().check(ShadowNodeTraits::Trait::FormsView)) { return; @@ -520,7 +515,7 @@ void Binding::schedulerDidRequestPreliminaryViewAllocation( if (!mountingManager) { return; } - mountingManager->preallocateShadowView(surfaceId, ShadowView(shadowNode)); + mountingManager->preallocateShadowView(shadowNode); } void Binding::schedulerDidRequestUpdateToPreallocatedView( diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.h b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.h index 7e42f4ca756..05100da49a3 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.h @@ -106,7 +106,6 @@ class Binding : public jni::HybridClass, const MountingCoordinator::Shared& mountingCoordinator) override; void schedulerDidRequestPreliminaryViewAllocation( - const SurfaceId surfaceId, const ShadowNode& shadowNode) override; void schedulerDidRequestUpdateToPreallocatedView( diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp index 373030f51e5..e34a3f2adf6 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp @@ -776,21 +776,23 @@ void FabricMountingManager::executeMount( } void FabricMountingManager::preallocateShadowView( - SurfaceId surfaceId, - const ShadowView& shadowView) { + const ShadowNode& shadowNode) { { std::lock_guard lock(allocatedViewsMutex_); - auto allocatedViewsIterator = allocatedViewRegistry_.find(surfaceId); + auto allocatedViewsIterator = + allocatedViewRegistry_.find(shadowNode.getSurfaceId()); if (allocatedViewsIterator == allocatedViewRegistry_.end()) { return; } auto& allocatedViews = allocatedViewsIterator->second; - if (allocatedViews.find(shadowView.tag) != allocatedViews.end()) { + if (allocatedViews.find(shadowNode.getTag()) != allocatedViews.end()) { return; } - allocatedViews.insert(shadowView.tag); + allocatedViews.insert(shadowNode.getTag()); } + auto shadowView = ShadowView(shadowNode); + bool isLayoutableShadowNode = shadowView.layoutMetrics != EmptyLayoutMetrics; static auto preallocateView = @@ -818,7 +820,7 @@ void FabricMountingManager::preallocateShadowView( preallocateView( javaUIManager_, - surfaceId, + shadowNode.getSurfaceId(), shadowView.tag, component.get(), props.get(), diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.h b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.h index ea0eeb774d8..8f8ae041cd4 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.h @@ -32,7 +32,7 @@ class FabricMountingManager final { void onSurfaceStop(SurfaceId surfaceId); - void preallocateShadowView(SurfaceId surfaceId, const ShadowView& shadowView); + void preallocateShadowView(const ShadowNode& shadowNode); void updatePreallocatedShadowNode(const ShadowNode& shadowNode); void executeMount(const MountingTransaction& transaction); diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 8986bc240e8..3253061cf51 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -317,8 +317,7 @@ void Scheduler::uiManagerDidCreateShadowNode(const ShadowNode& shadowNode) { SystraceSection s("Scheduler::uiManagerDidCreateShadowNode"); if (delegate_ != nullptr) { - delegate_->schedulerDidRequestPreliminaryViewAllocation( - shadowNode.getSurfaceId(), shadowNode); + delegate_->schedulerDidRequestPreliminaryViewAllocation(shadowNode); } } diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h b/packages/react-native/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h index 40c7050b82b..51f2270017b 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h @@ -43,8 +43,7 @@ class SchedulerDelegate { * Called right after a new ShadowNode was created. */ virtual void schedulerDidRequestPreliminaryViewAllocation( - SurfaceId surfaceId, - const ShadowNode& shadowView) = 0; + const ShadowNode& shadowNode) = 0; /* * Called after shadow node is cloned with new props. diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp index 9c94c259c57..9b200d35820 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -89,8 +89,7 @@ std::shared_ptr UIManager::createNode( auto shadowNode = componentDescriptor.createShadowNode( ShadowNodeFragment{ - /* .props = */ - fallbackDescriptor != nullptr && + .props = fallbackDescriptor != nullptr && fallbackDescriptor->getComponentHandle() == componentDescriptor.getComponentHandle() ? componentDescriptor.cloneProps( @@ -98,8 +97,8 @@ std::shared_ptr UIManager::createNode( props, RawProps(folly::dynamic::object("name", name))) : props, - /* .children = */ ShadowNodeFragment::childrenPlaceholder(), - /* .state = */ state, + .children = ShadowNodeFragment::childrenPlaceholder(), + .state = state, }, family); @@ -152,8 +151,8 @@ std::shared_ptr UIManager::cloneNode( auto clonedShadowNode = componentDescriptor.cloneShadowNode( shadowNode, { - /* .props = */ props, - /* .children = */ children, + .props = props, + .children = children, }); if (!rawProps.isEmpty() && delegate_ != nullptr) { diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 73ce6f5e381..b73714bbbbf 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -527,9 +527,9 @@ jsi::Value UIManagerBinding::get( strongUIManager->completeSurface( surfaceId, shadowNodeList, - {/* .enableStateReconciliation = */ true, - /* .mountSynchronously = */ false, - /* .shouldYield = */ shouldYield}); + {.enableStateReconciliation = true, + .mountSynchronously = false, + .shouldYield = shouldYield}); } }); } else {