mirror of
https://github.com/status-im/react-native.git
synced 2025-02-03 13:14:42 +00:00
Markers for JSC and Bridge Initialization
Differential Revision: D2507869
This commit is contained in:
parent
943f62b81b
commit
4a5fed3c42
@ -111,7 +111,14 @@ public class CatalystInstance {
|
|||||||
mBridge.setGlobalVariable(
|
mBridge.setGlobalVariable(
|
||||||
"__fbBatchedBridgeConfig",
|
"__fbBatchedBridgeConfig",
|
||||||
buildModulesConfigJSONProperty(registry, jsModulesConfig));
|
buildModulesConfigJSONProperty(registry, jsModulesConfig));
|
||||||
|
Systrace.beginSection(
|
||||||
|
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
|
||||||
|
"CatalystInstance_initializeBridge");
|
||||||
|
try {
|
||||||
jsBundleLoader.loadScript(mBridge);
|
jsBundleLoader.loadScript(mBridge);
|
||||||
|
} finally {
|
||||||
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ void callFunction(
|
/* package */ void callFunction(
|
||||||
|
@ -70,16 +70,30 @@ public class NativeModuleRegistry {
|
|||||||
|
|
||||||
/* package */ void notifyCatalystInstanceDestroy() {
|
/* package */ void notifyCatalystInstanceDestroy() {
|
||||||
UiThreadUtil.assertOnUiThread();
|
UiThreadUtil.assertOnUiThread();
|
||||||
|
Systrace.beginSection(
|
||||||
|
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
|
||||||
|
"NativeModuleRegistry_notifyCatalystInstanceDestroy");
|
||||||
|
try {
|
||||||
for (NativeModule nativeModule : mModuleInstances.values()) {
|
for (NativeModule nativeModule : mModuleInstances.values()) {
|
||||||
nativeModule.onCatalystInstanceDestroy();
|
nativeModule.onCatalystInstanceDestroy();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ void notifyCatalystInstanceInitialized() {
|
/* package */ void notifyCatalystInstanceInitialized() {
|
||||||
UiThreadUtil.assertOnUiThread();
|
UiThreadUtil.assertOnUiThread();
|
||||||
|
Systrace.beginSection(
|
||||||
|
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
|
||||||
|
"NativeModuleRegistry_notifyCatalystInstanceInitialized");
|
||||||
|
try {
|
||||||
for (NativeModule nativeModule : mModuleInstances.values()) {
|
for (NativeModule nativeModule : mModuleInstances.values()) {
|
||||||
nativeModule.initialize();
|
nativeModule.initialize();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBatchComplete() {
|
public void onBatchComplete() {
|
||||||
|
@ -70,6 +70,10 @@ void JSCExecutor::executeApplicationScript(
|
|||||||
const std::string& sourceURL) {
|
const std::string& sourceURL) {
|
||||||
String jsScript(script.c_str());
|
String jsScript(script.c_str());
|
||||||
String jsSourceURL(sourceURL.c_str());
|
String jsSourceURL(sourceURL.c_str());
|
||||||
|
#ifdef WITH_FBSYSTRACE
|
||||||
|
FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "JSCExecutor::executeApplicationScript",
|
||||||
|
"sourceURL", sourceURL);
|
||||||
|
#endif
|
||||||
evaluateScriptWithJSC(m_context, jsScript, jsSourceURL);
|
evaluateScriptWithJSC(m_context, jsScript, jsSourceURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <fb/log.h>
|
#include <fb/log.h>
|
||||||
|
|
||||||
|
#ifdef WITH_FBSYSTRACE
|
||||||
|
#include <fbsystrace.h>
|
||||||
|
using fbsystrace::FbSystraceSection;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace react {
|
namespace react {
|
||||||
|
|
||||||
@ -17,6 +22,11 @@ std::string loadScriptFromAssets(
|
|||||||
JNIEnv *env,
|
JNIEnv *env,
|
||||||
jobject assetManager,
|
jobject assetManager,
|
||||||
std::string assetName) {
|
std::string assetName) {
|
||||||
|
#ifdef WITH_FBSYSTRACE
|
||||||
|
FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "reactbridge_jni_loadScriptFromAssets",
|
||||||
|
"assetName", assetName);
|
||||||
|
#endif
|
||||||
|
|
||||||
auto manager = AAssetManager_fromJava(env, assetManager);
|
auto manager = AAssetManager_fromJava(env, assetManager);
|
||||||
if (manager) {
|
if (manager) {
|
||||||
auto asset = AAssetManager_open(
|
auto asset = AAssetManager_open(
|
||||||
@ -41,6 +51,10 @@ std::string loadScriptFromAssets(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string loadScriptFromFile(std::string fileName) {
|
std::string loadScriptFromFile(std::string fileName) {
|
||||||
|
#ifdef WITH_FBSYSTRACE
|
||||||
|
FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "reactbridge_jni_loadScriptFromFile",
|
||||||
|
"fileName", fileName);
|
||||||
|
#endif
|
||||||
std::ifstream jsfile(fileName);
|
std::ifstream jsfile(fileName);
|
||||||
if (jsfile) {
|
if (jsfile) {
|
||||||
std::string output;
|
std::string output;
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
#include "NativeArray.h"
|
#include "NativeArray.h"
|
||||||
#include "ProxyExecutor.h"
|
#include "ProxyExecutor.h"
|
||||||
|
|
||||||
|
#ifdef WITH_FBSYSTRACE
|
||||||
|
#include <fbsystrace.h>
|
||||||
|
using fbsystrace::FbSystraceSection;
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace facebook::jni;
|
using namespace facebook::jni;
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
@ -583,6 +588,11 @@ static void loadScriptFromAssets(JNIEnv* env, jobject obj, jobject assetManager,
|
|||||||
auto bridge = extractRefPtr<Bridge>(env, obj);
|
auto bridge = extractRefPtr<Bridge>(env, obj);
|
||||||
auto assetNameStr = fromJString(env, assetName);
|
auto assetNameStr = fromJString(env, assetName);
|
||||||
auto script = react::loadScriptFromAssets(env, assetManager, assetNameStr);
|
auto script = react::loadScriptFromAssets(env, assetManager, assetNameStr);
|
||||||
|
#ifdef WITH_FBSYSTRACE
|
||||||
|
FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "reactbridge_jni_"
|
||||||
|
"executeApplicationScript",
|
||||||
|
"assetName", assetNameStr);
|
||||||
|
#endif
|
||||||
bridge->executeApplicationScript(script, assetNameStr);
|
bridge->executeApplicationScript(script, assetNameStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -593,6 +603,12 @@ static void loadScriptFromNetworkCached(JNIEnv* env, jobject obj, jstring source
|
|||||||
if (tempFileName != NULL) {
|
if (tempFileName != NULL) {
|
||||||
script = react::loadScriptFromFile(jni::fromJString(env, tempFileName));
|
script = react::loadScriptFromFile(jni::fromJString(env, tempFileName));
|
||||||
}
|
}
|
||||||
|
#ifdef WITH_FBSYSTRACE
|
||||||
|
auto sourceURLStr = fromJString(env, sourceURL);
|
||||||
|
FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "reactbridge_jni_"
|
||||||
|
"executeApplicationScript",
|
||||||
|
"sourceURL", sourceURLStr);
|
||||||
|
#endif
|
||||||
bridge->executeApplicationScript(script, jni::fromJString(env, sourceURL));
|
bridge->executeApplicationScript(script, jni::fromJString(env, sourceURL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user