mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
aba11daff8
commit
2f67c8d5b7
@@ -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<ShadowTree>(
|
||||
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 {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <react/renderer/scheduler/SchedulerDelegate.h>
|
||||
#include <react/renderer/scheduler/SchedulerToolbox.h>
|
||||
#include <react/renderer/scheduler/SurfaceHandler.h>
|
||||
#include <react/renderer/scheduler/SurfaceManager.h>
|
||||
#include <react/renderer/uimanager/UIManagerAnimationDelegate.h>
|
||||
#include <react/renderer/uimanager/UIManagerBinding.h>
|
||||
#include <react/renderer/uimanager/UIManagerDelegate.h>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user