Files
react-native/ReactCommon/react/renderer/scheduler/SchedulerToolbox.h
T
Samuel Susla 34d189ae09 Introducing Leak Checker
Summary:
Changelog: [internal]

Introducing LeakChecker. A tool that checks if all native components have been cleaned up when surface is stopped.

**Known shortcomings**:
- LeakChecker is only enabled in debug builds and the existence of leaks is logged to console.
- For now, Leak Checker looks at N-1 screen. This is intentional as there is a known limitation of React that doesn't free up all shadow nodes when surface is stopped. Because of this, the use of LeakChecker is not intuitive and I'll work with React team to try to work around this.
- It doesn't help locating the leak, it only informs that leak is present. I'll be looking into ways to help locate the leak.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D26727461

fbshipit-source-id: 8350190b99f24642f8e15a3c2e1d79cfaa810d3d
2021-03-17 02:57:37 -07:00

82 lines
2.4 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <memory>
#include <ReactCommon/RuntimeExecutor.h>
#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#include <react/renderer/core/EventBeat.h>
#include <react/renderer/leakchecker/LeakChecker.h>
#include <react/renderer/uimanager/UIManagerCommitHook.h>
#include <react/renderer/uimanager/primitives.h>
#include <react/utils/ContextContainer.h>
#include <react/utils/RunLoopObserver.h>
namespace facebook {
namespace react {
/*
* Contains all external dependencies of Scheduler.
* Copyable.
*/
struct SchedulerToolbox final {
/*
* Represents general purpose DI container for product components/needs.
* Must not be `nullptr`.
*/
ContextContainer::Shared contextContainer;
/*
* Represents externally managed, lazily available collection of components.
*/
ComponentRegistryFactory componentRegistryFactory;
/*
* Represents running JavaScript VM and associated execution queue.
*/
RuntimeExecutor runtimeExecutor;
/*
* Represent connections with a platform-specific UI run loops.
*/
RunLoopObserver::Factory mainRunLoopObserverFactory;
/*
* Asynchronous & synchronous event beats.
* Represent connections with the platform-specific run loops and general
* purpose background queue.
*/
EventBeat::Factory asynchronousEventBeatFactory;
EventBeat::Factory synchronousEventBeatFactory;
/*
* General-purpose executor that is used to dispatch work on some utility
* queue (mostly) asynchronously to avoid unnecessary blocking the caller
* queue.
* The concrete implementation can use a serial or concurrent queue.
* Due to architectural constraints, the concrete implementation *must* call
* the call back synchronously if the executor is invoked on the main thread.
*/
BackgroundExecutor backgroundExecutor;
/*
* Triggers garbage collection. Used when checking if all Fabric's HostObjects
* have been properly cleaned up from JavaScript.
*/
GarbageCollectionTrigger garbageCollectionTrigger;
/*
* A list of `UIManagerCommitHook`s that should be registered in `UIManager`.
*/
std::vector<std::shared_ptr<UIManagerCommitHook const>> commitHooks;
};
} // namespace react
} // namespace facebook