log constants map conversion for UIManagerModule and I18N Module

Reviewed By: yungsters

Differential Revision: D4473401

fbshipit-source-id: 7c2a7484305a099fe6a49cbcd0a1d9d9d082a3f8
This commit is contained in:
Aaron Chiu 2017-01-27 18:06:58 -08:00 committed by Facebook Github Bot
parent 2a5cb9a773
commit 5c7009d147
4 changed files with 47 additions and 2 deletions

View File

@ -0,0 +1,12 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.react.bridge;
/**
* Interface on native modules for the bridge to call for TTI start and end markers.
*/
public interface NativeModuleLogger {
void startConstantsMapConversion();
void endConstantsMapConversion();
}

View File

@ -42,4 +42,16 @@ public class ReactMarkerConstants {
"CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_START";
public static final String CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END =
"CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END";
public static final String UI_MANAGER_MODULE_CONSTANTS_CONVERT_START =
"UI_MANAGER_MODULE_CONSTANTS_CONVERT_START";
public static final String UI_MANAGER_MODULE_CONSTANTS_CONVERT_END =
"UI_MANAGER_MODULE_CONSTANTS_CONVERT_END";
public static final String CREATE_I18N_MODULE_CONSTANTS_START =
"CREATE_I18N_MODULE_CONSTANTS_START";
public static final String CREATE_I18N_MODULE_CONSTANTS_END =
"CREATE_I18N_MODULE_CONSTANTS_END";
public static final String I18N_MODULE_CONSTANTS_CONVERT_START =
"I18N_MODULE_CONSTANTS_CONVERT_START";
public static final String I18N_MODULE_CONSTANTS_CONVERT_END =
"I18N_MODULE_CONSTANTS_CONVERT_END";
}

View File

@ -18,6 +18,7 @@ import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.ExecutorToken;
import com.facebook.react.bridge.NativeArray;
import com.facebook.react.bridge.NativeModuleLogger;
import com.facebook.react.bridge.ReadableNativeArray;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
@ -89,12 +90,16 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "Map constants")
.arg("moduleName", getName())
.flush();
Map<String, Object> map = getModule().getConstants();
BaseJavaModule baseJavaModule = getModule();
Map<String, Object> map = baseJavaModule.getConstants();
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "WritableNativeMap constants")
.arg("moduleName", getName())
.flush();
if (baseJavaModule instanceof NativeModuleLogger) {
((NativeModuleLogger) baseJavaModule).startConstantsMapConversion();
}
WritableNativeMap writableNativeMap;
try {
writableNativeMap = Arguments.makeNativeMap(map);
@ -103,6 +108,9 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
}
WritableNativeArray array = new WritableNativeArray();
array.pushMap(writableNativeMap);
if (baseJavaModule instanceof NativeModuleLogger) {
((NativeModuleLogger) baseJavaModule).endConstantsMapConversion();
}
return array;
}

View File

@ -22,6 +22,7 @@ import com.facebook.common.logging.FLog;
import com.facebook.react.animation.Animation;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.NativeModuleLogger;
import com.facebook.react.bridge.OnBatchCompleteListener;
import com.facebook.react.bridge.PerformanceCounter;
import com.facebook.react.bridge.ReactApplicationContext;
@ -39,6 +40,8 @@ import com.facebook.systrace.SystraceMessage;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_CONSTANTS_END;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_CONSTANTS_START;
import static com.facebook.react.bridge.ReactMarkerConstants.UI_MANAGER_MODULE_CONSTANTS_CONVERT_END;
import static com.facebook.react.bridge.ReactMarkerConstants.UI_MANAGER_MODULE_CONSTANTS_CONVERT_START;
/**
* <p>Native module to allow JS to create and update native Views.</p>
@ -71,7 +74,7 @@ import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_M
*/
@ReactModule(name = "RKUIManager")
public class UIManagerModule extends ReactContextBaseJavaModule implements
OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter {
OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter, NativeModuleLogger {
// Keep in sync with ReactIOSTagHandles JS module - see that file for an explanation on why the
// increment here is 10
@ -567,6 +570,16 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
return mUIImplementation.resolveRootTagFromReactTag(reactTag);
}
@Override
public void startConstantsMapConversion() {
ReactMarker.logMarker(UI_MANAGER_MODULE_CONSTANTS_CONVERT_START);
}
@Override
public void endConstantsMapConversion() {
ReactMarker.logMarker(UI_MANAGER_MODULE_CONSTANTS_CONVERT_END);
}
/**
* Listener that drops the CSSNode pool on low memory when the app is backgrounded.
*/