mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
9b50ea7e80
Summary: The hermes profiler doesn't work currently, I tracked down the problem to a couple of things. - Need to call `registerForProfiling` to enable profiling for a specific runtime. I added the call at the same place where we enable the debugger. - `runInExecutor` didn't work and call its callback. Not sure exactly why, but using `executor_->add` like we do in a lot of other places to run code on the executor works. - `GetHeapUsageRequest` seems to cause some deadlocks. JS contexts were not detected reliably, I suspect this is related to deadlocks when trying to run on inspector executor. `GetHeapUsageRequest` doesn't actually need any data from the inspector so there is no need to run it on that queue. To fix it I moved the call to use `runInExecutor` instead. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [General] [Fixed] - Fix hermes profiler Pull Request resolved: https://github.com/facebook/react-native/pull/34129 Reviewed By: cortinico Differential Revision: D37669469 Pulled By: philIip fbshipit-source-id: 6cf3b2857ac60b0a1518837b9c56b9c093ed222f
58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and 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 <hermes/hermes.h>
|
|
#include <jsireact/JSIExecutor.h>
|
|
#include <functional>
|
|
#include <utility>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
class HermesExecutorFactory : public JSExecutorFactory {
|
|
public:
|
|
explicit HermesExecutorFactory(
|
|
JSIExecutor::RuntimeInstaller runtimeInstaller,
|
|
const JSIScopedTimeoutInvoker &timeoutInvoker =
|
|
JSIExecutor::defaultTimeoutInvoker,
|
|
::hermes::vm::RuntimeConfig runtimeConfig = defaultRuntimeConfig())
|
|
: runtimeInstaller_(runtimeInstaller),
|
|
timeoutInvoker_(timeoutInvoker),
|
|
runtimeConfig_(std::move(runtimeConfig)) {
|
|
assert(timeoutInvoker_ && "Should not have empty timeoutInvoker");
|
|
}
|
|
|
|
std::unique_ptr<JSExecutor> createJSExecutor(
|
|
std::shared_ptr<ExecutorDelegate> delegate,
|
|
std::shared_ptr<MessageQueueThread> jsQueue) override;
|
|
|
|
private:
|
|
static ::hermes::vm::RuntimeConfig defaultRuntimeConfig();
|
|
|
|
JSIExecutor::RuntimeInstaller runtimeInstaller_;
|
|
JSIScopedTimeoutInvoker timeoutInvoker_;
|
|
::hermes::vm::RuntimeConfig runtimeConfig_;
|
|
};
|
|
|
|
class HermesExecutor : public JSIExecutor {
|
|
public:
|
|
HermesExecutor(
|
|
std::shared_ptr<jsi::Runtime> runtime,
|
|
std::shared_ptr<ExecutorDelegate> delegate,
|
|
std::shared_ptr<MessageQueueThread> jsQueue,
|
|
const JSIScopedTimeoutInvoker &timeoutInvoker,
|
|
RuntimeInstaller runtimeInstaller);
|
|
|
|
private:
|
|
JSIScopedTimeoutInvoker timeoutInvoker_;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|