From 29846283579a35abdd6a5e236c747736563fa200 Mon Sep 17 00:00:00 2001 From: Ben Nham Date: Fri, 9 Jun 2017 06:11:43 -0700 Subject: [PATCH] add marker surrounding entire native module creation Reviewed By: javache Differential Revision: D5200856 fbshipit-source-id: 35b0e627224d518126a1cfdd36d6af264dd186cf --- React/CxxBridge/RCTCxxBridge.mm | 2 ++ .../facebook/react/bridge/ReactMarkerConstants.java | 2 ++ ReactAndroid/src/main/jni/react/jni/OnLoad.cpp | 6 ++++++ ReactCommon/cxxreact/JSCNativeModules.cpp | 10 +++++++++- ReactCommon/cxxreact/Platform.h | 2 ++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 41d04bf10..40f9f46cc 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -97,6 +97,8 @@ static void registerPerformanceLoggerHooks(RCTPerformanceLogger *performanceLogg case ReactMarker::CREATE_REACT_CONTEXT_STOP: case ReactMarker::JS_BUNDLE_STRING_CONVERT_START: case ReactMarker::JS_BUNDLE_STRING_CONVERT_STOP: + case ReactMarker::NATIVE_MODULE_SETUP_START: + case ReactMarker::NATIVE_MODULE_SETUP_STOP: // These are not used on iOS. break; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java index eede3ce0b..f2468f62e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java @@ -28,6 +28,8 @@ public enum ReactMarkerConstants { CREATE_VIEW_MANAGERS_END, CREATE_UI_MANAGER_MODULE_CONSTANTS_START, CREATE_UI_MANAGER_MODULE_CONSTANTS_END, + NATIVE_MODULE_SETUP_START, + NATIVE_MODULE_SETUP_END, CREATE_MODULE_START, CREATE_MODULE_END, PROCESS_CORE_REACT_PACKAGE_START, diff --git a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp index b6236f584..b01f5ce62 100644 --- a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +++ b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp @@ -139,6 +139,12 @@ static void logPerfMarker(const ReactMarker::ReactMarkerId markerId, const char* case ReactMarker::JS_BUNDLE_STRING_CONVERT_STOP: JReactMarker::logMarker("loadApplicationScript_endStringConvert"); break; + case ReactMarker::NATIVE_MODULE_SETUP_START: + JReactMarker::logMarker("NATIVE_MODULE_SETUP_START", tag); + break; + case ReactMarker::NATIVE_MODULE_SETUP_STOP: + JReactMarker::logMarker("NATIVE_MODULE_SETUP_END", tag); + break; case ReactMarker::NATIVE_REQUIRE_START: case ReactMarker::NATIVE_REQUIRE_STOP: // These are not used on Android. diff --git a/ReactCommon/cxxreact/JSCNativeModules.cpp b/ReactCommon/cxxreact/JSCNativeModules.cpp index 013f6ef13..63380dfa6 100644 --- a/ReactCommon/cxxreact/JSCNativeModules.cpp +++ b/ReactCommon/cxxreact/JSCNativeModules.cpp @@ -4,6 +4,8 @@ #include +#include "Platform.h" + namespace facebook { namespace react { @@ -41,6 +43,8 @@ void JSCNativeModules::reset() { } folly::Optional JSCNativeModules::createModule(const std::string& name, JSContextRef context) { + ReactMarker::logTaggedMarker(ReactMarker::NATIVE_MODULE_SETUP_START, name.c_str()); + if (!m_genNativeModuleJS) { auto global = Object::getGlobalObject(context); m_genNativeModuleJS = global.getProperty("__fbGenNativeModule").asObject(); @@ -58,7 +62,11 @@ folly::Optional JSCNativeModules::createModule(const std::string& name, }); CHECK(!moduleInfo.isNull()) << "Module returned from genNativeModule is null"; - return moduleInfo.asObject().getProperty("module").asObject(); + folly::Optional module(moduleInfo.asObject().getProperty("module").asObject()); + + ReactMarker::logTaggedMarker(ReactMarker::NATIVE_MODULE_SETUP_STOP, name.c_str()); + + return module; } } } diff --git a/ReactCommon/cxxreact/Platform.h b/ReactCommon/cxxreact/Platform.h index 800e1208f..6a38557a4 100644 --- a/ReactCommon/cxxreact/Platform.h +++ b/ReactCommon/cxxreact/Platform.h @@ -23,6 +23,8 @@ enum ReactMarkerId { CREATE_REACT_CONTEXT_STOP, JS_BUNDLE_STRING_CONVERT_START, JS_BUNDLE_STRING_CONVERT_STOP, + NATIVE_MODULE_SETUP_START, + NATIVE_MODULE_SETUP_STOP, }; using LogTaggedMarker = std::function;