From 2f67c8d5b7ae30305679e4c596b95109c7925eda Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 9 Mar 2021 11:47:21 -0800 Subject: [PATCH] Fabric: `surfaceId`-based that controls Surface status methods were removed from `Scheduler` Summary: We don't use them anymore. Changelog: [Internal] Fabric-specific internal change. Differential Revision: D26376683 fbshipit-source-id: 801e9225502005ed01317ed396346176b2f2f5bc --- .../react/renderer/scheduler/Scheduler.cpp | 130 +----------------- .../react/renderer/scheduler/Scheduler.h | 33 ----- 2 files changed, 1 insertion(+), 162 deletions(-) diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 2d7c286a631..4e4dd8f95db 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -32,8 +32,7 @@ namespace react { Scheduler::Scheduler( SchedulerToolbox schedulerToolbox, UIManagerAnimationDelegate *animationDelegate, - SchedulerDelegate *delegate) - : surfaceManager_(*this) { + SchedulerDelegate *delegate) { runtimeExecutor_ = schedulerToolbox.runtimeExecutor; reactNativeConfig_ = @@ -118,13 +117,9 @@ Scheduler::Scheduler( "react_fabric:remove_outstanding_surfaces_on_destruction_android"); Constants::setPropsForwardingEnabled(reactNativeConfig_->getBool( "react_fabric:enable_props_forwarding_android")); - enableSurfaceManager_ = reactNativeConfig_->getBool( - "react_fabric:enable_surface_manager_android"); #else removeOutstandingSurfacesOnDestruction_ = reactNativeConfig_->getBool( "react_fabric:remove_outstanding_surfaces_on_destruction_ios"); - enableSurfaceManager_ = - reactNativeConfig_->getBool("react_fabric:enable_surface_manager_ios"); #endif uiManager->extractUIManagerBindingOnDemand_ = reactNativeConfig_->getBool( @@ -196,37 +191,6 @@ void Scheduler::unregisterSurface( surfaceHandler.setUIManager(nullptr); } -void Scheduler::startSurface( - SurfaceId surfaceId, - const std::string &moduleName, - const folly::dynamic &initialProps, - const LayoutConstraints &layoutConstraints, - const LayoutContext &layoutContext) const { - SystraceSection s("Scheduler::startSurface"); - - if (enableSurfaceManager_) { - surfaceManager_.startSurface( - surfaceId, moduleName, initialProps, layoutConstraints, layoutContext); - return; - } - - auto shadowTree = std::make_unique( - surfaceId, layoutConstraints, layoutContext, *uiManager_); - - auto uiManager = uiManager_; - - uiManager->getShadowTreeRegistry().add(std::move(shadowTree)); - - runtimeExecutor_([=](jsi::Runtime &runtime) { - uiManager->visitBinding( - [&](UIManagerBinding const &uiManagerBinding) { - uiManagerBinding.startSurface( - runtime, surfaceId, moduleName, initialProps); - }, - runtime); - }); -} - void Scheduler::renderTemplateToSurface( SurfaceId surfaceId, const std::string &uiTemplate) { @@ -264,98 +228,6 @@ void Scheduler::renderTemplateToSurface( } } -void Scheduler::stopSurface(SurfaceId surfaceId) const { - SystraceSection s("Scheduler::stopSurface"); - - if (enableSurfaceManager_) { - surfaceManager_.stopSurface(surfaceId); - return; - } - - // Stop any ongoing animations. - uiManager_->stopSurfaceForAnimationDelegate(surfaceId); - - // Waiting for all concurrent commits to be finished and unregistering the - // `ShadowTree`. - auto shadowTree = uiManager_->getShadowTreeRegistry().remove(surfaceId); - - // As part of stopping a Surface, we need to properly destroy all - // mounted views, so we need to commit an empty tree to trigger all - // side-effects (including destroying and removing mounted views). - if (shadowTree) { - shadowTree->commitEmptyTree(); - } - - // We execute JavaScript/React part of the process at the very end to minimize - // any visible side-effects of stopping the Surface. Any possible commits from - // the JavaScript side will not be able to reference a `ShadowTree` and will - // fail silently. - auto uiManager = uiManager_; - runtimeExecutor_([=](jsi::Runtime &runtime) { - uiManager->visitBinding( - [&](UIManagerBinding const &uiManagerBinding) { - uiManagerBinding.stopSurface(runtime, surfaceId); - }, - runtime); - }); -} - -Size Scheduler::measureSurface( - SurfaceId surfaceId, - const LayoutConstraints &layoutConstraints, - const LayoutContext &layoutContext) const { - SystraceSection s("Scheduler::measureSurface"); - - if (enableSurfaceManager_) { - return surfaceManager_.measureSurface( - surfaceId, layoutConstraints, layoutContext); - } - - auto currentRootShadowNode = RootShadowNode::Shared{}; - uiManager_->getShadowTreeRegistry().visit( - surfaceId, [&](const ShadowTree &shadowTree) { - currentRootShadowNode = shadowTree.getCurrentRevision().rootShadowNode; - }); - - auto rootShadowNode = - currentRootShadowNode->clone(layoutConstraints, layoutContext); - rootShadowNode->layoutIfNeeded(); - return rootShadowNode->getLayoutMetrics().frame.size; -} - -MountingCoordinator::Shared Scheduler::findMountingCoordinator( - SurfaceId surfaceId) const { - if (enableSurfaceManager_) { - return surfaceManager_.findMountingCoordinator(surfaceId); - } - - MountingCoordinator::Shared mountingCoordinator = nullptr; - uiManager_->getShadowTreeRegistry().visit( - surfaceId, [&](const ShadowTree &shadowTree) { - mountingCoordinator = shadowTree.getMountingCoordinator(); - }); - return mountingCoordinator; -} - -void Scheduler::constraintSurfaceLayout( - SurfaceId surfaceId, - const LayoutConstraints &layoutConstraints, - const LayoutContext &layoutContext) const { - if (enableSurfaceManager_) { - return surfaceManager_.constraintSurfaceLayout( - surfaceId, layoutConstraints, layoutContext); - } - - SystraceSection s("Scheduler::constraintSurfaceLayout"); - - uiManager_->getShadowTreeRegistry().visit( - surfaceId, [&](ShadowTree const &shadowTree) { - shadowTree.commit([&](RootShadowNode const &oldRootShadowNode) { - return oldRootShadowNode.clone(layoutConstraints, layoutContext); - }); - }); -} - ComponentDescriptor const * Scheduler::findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN( ComponentHandle handle) const { diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.h b/ReactCommon/react/renderer/scheduler/Scheduler.h index 8e0c8db0c5a..a163a66a5e7 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -50,36 +49,10 @@ class Scheduler final : public UIManagerDelegate { void registerSurface(SurfaceHandler const &surfaceHandler) const noexcept; void unregisterSurface(SurfaceHandler const &surfaceHandler) const noexcept; - void startSurface( - SurfaceId surfaceId, - const std::string &moduleName, - const folly::dynamic &initialProps, - const LayoutConstraints &layoutConstraints = {}, - const LayoutContext &layoutContext = {}) const; - void renderTemplateToSurface( SurfaceId surfaceId, const std::string &uiTemplate); - void stopSurface(SurfaceId surfaceId) const; - - Size measureSurface( - SurfaceId surfaceId, - const LayoutConstraints &layoutConstraints, - const LayoutContext &layoutContext) const; - - /* - * Applies given `layoutConstraints` and `layoutContext` to a Surface. - * The user interface will be relaid out as a result. The operation will be - * performed synchronously (including mounting) if the method is called - * on the main thread. - * Can be called from any thread. - */ - void constraintSurfaceLayout( - SurfaceId surfaceId, - const LayoutConstraints &layoutConstraints, - const LayoutContext &layoutContext) const; - /* * This is broken. Please do not use. * `ComponentDescriptor`s are not designed to be used outside of `UIManager`, @@ -89,9 +62,6 @@ class Scheduler final : public UIManagerDelegate { findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN( ComponentHandle handle) const; - MountingCoordinator::Shared findMountingCoordinator( - SurfaceId surfaceId) const; - #pragma mark - Delegate /* @@ -129,7 +99,6 @@ class Scheduler final : public UIManagerDelegate { private: friend class SurfaceHandler; - SurfaceManager surfaceManager_; SchedulerDelegate *delegate_; SharedComponentDescriptorRegistry componentDescriptorRegistry_; RuntimeExecutor runtimeExecutor_; @@ -151,8 +120,6 @@ class Scheduler final : public UIManagerDelegate { * Temporary flags. */ bool removeOutstandingSurfacesOnDestruction_{false}; - - bool enableSurfaceManager_{false}; }; } // namespace react