mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: ## Motivation This rename will fix the following CircleCI build failures: - [test_ios_unit_frameworks](https://circleci.com/gh/facebook/react-native/150473?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link) - [test_ios_detox_frameworks](https://circleci.com/gh/facebook/react-native/150474?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link) ## Investigation We have 4 podspec targets that map to the same header namespace (i.e: `header_dir`) `ReactCommon`: - **New:** `React-perflogger`: Directory is `ReactCommon/preflogger`, and contains `NativeModulePerfLogger.{h,cpp}`. - `React-runtimeexecutor`: Directory is `ReactCommon/runtimeexecutor`, and contains only `RuntimeExecutor.h` - `React-callinvoker`: Directory is `ReactCommon/callinvoker`, and contains only `CallInvoker.h` - `ReactCommon/turbomodule/core`: Directory is `ReactCommon/turbomodule`, and contains C++ files, as well has header files. **The problem:** We couldn't import headers from `React-perflogger` in `ReactCommon/turbomodule/core` files. **The cause:** I'm not entirely sure why, but I was able to discern the following two rules by playing around with the podspecs: 1. If your podspec target has a cpp file, it'll generate a framework when `USE_FRAMEWORKS=1`. 2. Two different frameworks cannot map to the same `module_name` or `header_dir`. (Why? No clue. But something breaks silently when this is the case). So, this is what happened when I landed `React-perflogger` (D21443610): 1. The TurboModules code generates the `ReactCommon` framework that uses the `ReactCommon` header namespace. 2. `React-runtimeexecutor` and `React-callinvoker` also used the `ReactCommon` header namespace. However, neither generate a framework because of Rule 1. 3. When I comitted `React-perflogger`, I introduced a second framework that competed with the `ReactCommon` framework (i.e: TurboModules code) for the `ReactCommon` header namespace. Rule 2 violation. ## Thoughts on renaming - `<perflogger/NativeModulePerfLogger.h>` is too generic, and the `perflogger` namepsace is used internally within FB. - `<react/perflogger/NativeModulePerfLogger.h>` matches our fabric header format, but I'm pretty sure that slashes aren't allowed in `header_dir`: I tested this and it didn't work. IIRC, only alphanumeric and underscore are valid characters for `header_dir` or `module_name`. So, I opted to just use `reactperflogger`. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D21598852 fbshipit-source-id: 60da5d0f7758eaf13907a080b7d8756688f40723
166 lines
5.7 KiB
C++
166 lines
5.7 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>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/**
|
|
* A platform-agnostic interface to do performance logging on NativeModules and
|
|
* TuboModules.
|
|
*/
|
|
class NativeModulePerfLogger {
|
|
private:
|
|
static std::shared_ptr<NativeModulePerfLogger> s_perfLogger;
|
|
|
|
public:
|
|
static NativeModulePerfLogger &getInstance();
|
|
static void setInstance(std::shared_ptr<NativeModulePerfLogger> perfLogger);
|
|
|
|
virtual ~NativeModulePerfLogger();
|
|
|
|
/**
|
|
* NativeModule Initialization.
|
|
*
|
|
* The initialization of two NativeModules can interleave. Therefore,
|
|
* performance markers should use the moduleName as a unique key.
|
|
*/
|
|
|
|
/**
|
|
* On iOS:
|
|
* - NativeModule initialization is split into two phases, which sometimes
|
|
* have a pause in the middle.
|
|
* - TurboModule initialization happens all at once.
|
|
*
|
|
* On Android:
|
|
* - NativeModule and TurboModule initialization happens all at once.
|
|
*
|
|
* These markers are meant for iOS NativeModules:
|
|
* - moduleDataCreateStart: very beginning of first phase.
|
|
* - moduleDataCreateEnd: after RCTModuleData has been created.
|
|
*/
|
|
virtual void moduleDataCreateStart(const char *moduleName, int32_t id);
|
|
virtual void moduleDataCreateEnd(const char *moduleName, int32_t id);
|
|
|
|
/**
|
|
* How long does it take to create the platform NativeModule object?
|
|
* - moduleCreateStart: start creating platform NativeModule
|
|
* - moduleCreateEnd: stop creating platform NativeModule
|
|
*/
|
|
virtual void moduleCreateStart(const char *moduleName, int32_t id);
|
|
virtual void moduleCreateCacheHit(const char *moduleName, int32_t id);
|
|
virtual void moduleCreateConstructStart(const char *moduleName, int32_t id);
|
|
virtual void moduleCreateConstructEnd(const char *moduleName, int32_t id);
|
|
virtual void moduleCreateSetUpStart(const char *moduleName, int32_t id);
|
|
virtual void moduleCreateSetUpEnd(const char *moduleName, int32_t id);
|
|
virtual void moduleCreateEnd(const char *moduleName, int32_t id);
|
|
virtual void moduleCreateFail(const char *moduleName, int32_t id);
|
|
|
|
/**
|
|
* How long, after starting JS require, does it take to start creating the
|
|
* platform NativeModule?
|
|
* - moduleJSRequireBeginningStart: start of JS require
|
|
* - moduleJSRequireBeginningEnd: start creating platform NativeModule
|
|
*/
|
|
virtual void moduleJSRequireBeginningStart(const char *moduleName);
|
|
virtual void moduleJSRequireBeginningCacheHit(const char *moduleName);
|
|
virtual void moduleJSRequireBeginningEnd(const char *moduleName);
|
|
virtual void moduleJSRequireBeginningFail(const char *moduleName);
|
|
|
|
/**
|
|
* How long does it take to return from the JS require after the platform
|
|
* NativeModule is created?
|
|
* - moduleJSRequireEndingStart: end creating platform NativeModule
|
|
* - moduleJSRequireEndingEnd: end of JS require
|
|
*/
|
|
virtual void moduleJSRequireEndingStart(const char *moduleName);
|
|
virtual void moduleJSRequireEndingEnd(const char *moduleName);
|
|
virtual void moduleJSRequireEndingFail(const char *moduleName);
|
|
|
|
// Sync method calls
|
|
virtual void syncMethodCallStart(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void syncMethodCallArgConversionStart(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void syncMethodCallArgConversionEnd(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void syncMethodCallExecutionStart(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void syncMethodCallExecutionEnd(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void syncMethodCallReturnConversionStart(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void syncMethodCallReturnConversionEnd(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void syncMethodCallEnd(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void syncMethodCallFail(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
|
|
// Async method calls
|
|
virtual void asyncMethodCallStart(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void asyncMethodCallArgConversionStart(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void asyncMethodCallArgConversionEnd(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void asyncMethodCallDispatch(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
virtual void asyncMethodCallEnd(
|
|
const char *moduleName,
|
|
const char *methodName);
|
|
|
|
/**
|
|
* In the NativeModule system, we batch async NativeModule method calls.
|
|
* When we execute a batch of NativeModule method calls, we convert the batch
|
|
* from a jsi::Value to folly::dynamic to std::vector<MethodCall>. This marker
|
|
* documents that work.
|
|
*/
|
|
virtual void asyncMethodCallBatchPreprocessStart();
|
|
virtual void asyncMethodCallBatchPreprocessEnd(int batchSize);
|
|
|
|
// Async method call execution
|
|
virtual void asyncMethodCallExecutionStart(
|
|
const char *moduleName,
|
|
const char *methodName,
|
|
int32_t id);
|
|
virtual void asyncMethodCallExecutionArgConversionStart(
|
|
const char *moduleName,
|
|
const char *methodName,
|
|
int32_t id);
|
|
virtual void asyncMethodCallExecutionArgConversionEnd(
|
|
const char *moduleName,
|
|
const char *methodName,
|
|
int32_t id);
|
|
virtual void asyncMethodCallExecutionEnd(
|
|
const char *moduleName,
|
|
const char *methodName,
|
|
int32_t id);
|
|
virtual void asyncMethodCallExecutionFail(
|
|
const char *moduleName,
|
|
const char *methodName,
|
|
int32_t id);
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|