Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from facebook:master #536

Merged
merged 1 commit into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ReactCommon/react/renderer/scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ Scheduler::Scheduler(
componentDescriptorRegistry_));

delegate_ = delegate;
commitHooks_ = schedulerToolbox.commitHooks;
uiManager_ = uiManager;

for (auto commitHook : commitHooks_) {
uiManager->registerCommitHook(*commitHook);
}

if (animationDelegate != nullptr) {
animationDelegate->setComponentDescriptorRegistry(
componentDescriptorRegistry_);
Expand All @@ -118,6 +123,10 @@ Scheduler::~Scheduler() {
LOG(WARNING) << "Scheduler::~Scheduler() was called (address: " << this
<< ").";

for (auto commitHook : commitHooks_) {
uiManager_->unregisterCommitHook(*commitHook);
}

// All Surfaces must be explicitly stopped before destroying `Scheduler`.
// The idea is that `UIManager` is allowed to call `Scheduler` only if the
// corresponding `ShadowTree` instance exists.
Expand Down
2 changes: 2 additions & 0 deletions ReactCommon/react/renderer/scheduler/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class Scheduler final : public UIManagerDelegate {
std::shared_ptr<UIManager> uiManager_;
std::shared_ptr<const ReactNativeConfig> reactNativeConfig_;

std::vector<std::shared_ptr<UIManagerCommitHook const>> commitHooks_;

/*
* At some point, we have to have an owning shared pointer to something that
* will become an `EventDispatcher` a moment later. That's why we have it as a
Expand Down
8 changes: 8 additions & 0 deletions ReactCommon/react/renderer/scheduler/SchedulerToolbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

#pragma once

#include <memory>

#include <ReactCommon/RuntimeExecutor.h>
#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#include <react/renderer/core/EventBeat.h>
#include <react/renderer/uimanager/UIManagerCommitHook.h>
#include <react/renderer/uimanager/primitives.h>
#include <react/utils/ContextContainer.h>
#include <react/utils/RunLoopObserver.h>
Expand Down Expand Up @@ -60,6 +63,11 @@ struct SchedulerToolbox final {
* the call back synchronously if the executor is invoked on the main thread.
*/
BackgroundExecutor backgroundExecutor;

/*
* A list of `UIManagerCommitHook`s that should be registered in `UIManager`.
*/
std::vector<std::shared_ptr<UIManagerCommitHook const>> commitHooks;
};

} // namespace react
Expand Down