diff --git a/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java index 87e5b0c45..111291445 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java @@ -15,6 +15,10 @@ import java.util.List; import com.facebook.react.bridge.ModuleSpec; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.systrace.Systrace; +import com.facebook.systrace.SystraceMessage; + +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; /** * React package supporting lazy creation of native modules. @@ -33,7 +37,14 @@ public abstract class LazyReactPackage implements ReactPackage { public final List createNativeModules(ReactApplicationContext reactContext) { List modules = new ArrayList<>(); for (ModuleSpec holder : getNativeModules(reactContext)) { - modules.add(holder.getProvider().get()); + SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createNativeModule") + .arg("module", holder.getType()) + .flush(); + try { + modules.add(holder.getProvider().get()); + } finally { + Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + } } return modules; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java index d2c02aefc..c8fff1df6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java @@ -925,10 +925,10 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; } private void processPackage( - ReactPackage reactPackage, - ReactApplicationContext reactContext, - NativeModuleRegistry.Builder nativeRegistryBuilder, - JavaScriptModuleRegistry.Builder jsModulesBuilder) { + ReactPackage reactPackage, + ReactApplicationContext reactContext, + NativeModuleRegistry.Builder nativeRegistryBuilder, + JavaScriptModuleRegistry.Builder jsModulesBuilder) { for (NativeModule nativeModule : reactPackage.createNativeModules(reactContext)) { nativeRegistryBuilder.add(nativeModule); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/cxxbridge/JavaModuleWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/cxxbridge/JavaModuleWrapper.java index f9dc5cbb5..ab802d8e4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/cxxbridge/JavaModuleWrapper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/cxxbridge/JavaModuleWrapper.java @@ -15,13 +15,17 @@ import java.util.List; import java.util.Map; import com.facebook.proguard.annotations.DoNotStrip; - 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.ReadableNativeArray; import com.facebook.react.bridge.WritableNativeArray; +import com.facebook.react.bridge.WritableNativeMap; +import com.facebook.systrace.Systrace; +import com.facebook.systrace.SystraceMessage; + +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; /** * This is part of the glue which wraps a java BaseJavaModule in a C++ @@ -120,8 +124,23 @@ import com.facebook.react.bridge.WritableNativeArray; // NativeMap out of OnLoad. @DoNotStrip public NativeArray getConstants() { + SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "Map constants") + .arg("moduleName", getName()) + .flush(); + Map map = mModule.getConstants(); + Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + + SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "WritableNativeMap constants") + .arg("moduleName", getName()) + .flush(); + WritableNativeMap writableNativeMap; + try { + writableNativeMap = Arguments.makeNativeMap(map); + } finally { + Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + } WritableNativeArray array = new WritableNativeArray(); - array.pushMap(Arguments.makeNativeMap(mModule.getConstants())); + array.pushMap(writableNativeMap); return array; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java index c103f445a..ff2ee2d5f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java @@ -17,9 +17,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.Map; import android.content.ContentResolver; import android.content.Context; @@ -103,11 +101,6 @@ public class CameraRollManager extends ReactContextBaseJavaModule { return "RKCameraRollManager"; } - @Override - public Map getConstants() { - return Collections.emptyMap(); - } - /** * Save an image to the gallery (i.e. {@link MediaStore.Images}). This copies the original file * from wherever it may be to the external storage pictures directory, so that it can be scanned @@ -440,5 +433,4 @@ public class CameraRollManager extends ReactContextBaseJavaModule { node.putMap("location", location); } } - } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java index ffee1cea4..2d725c2c2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java @@ -13,6 +13,10 @@ import java.util.List; import java.util.Map; import com.facebook.react.common.MapBuilder; +import com.facebook.systrace.Systrace; +import com.facebook.systrace.SystraceMessage; + +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; /** * Helps generate constants map for {@link UIManagerModule} by collecting and merging constants from @@ -42,29 +46,36 @@ import com.facebook.react.common.MapBuilder; Map directEventTypesConstants = UIManagerModuleConstants.getDirectEventTypeConstants(); for (ViewManager viewManager : viewManagers) { - Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants(); - if (viewManagerBubblingEvents != null) { - recursiveMerge(bubblingEventTypesConstants, viewManagerBubblingEvents); - } - Map viewManagerDirectEvents = viewManager.getExportedCustomDirectEventTypeConstants(); - if (viewManagerDirectEvents != null) { - recursiveMerge(directEventTypesConstants, viewManagerDirectEvents); - } - Map viewManagerConstants = MapBuilder.newHashMap(); - Map customViewConstants = viewManager.getExportedViewConstants(); - if (customViewConstants != null) { - viewManagerConstants.put("Constants", customViewConstants); - } - Map viewManagerCommands = viewManager.getCommandsMap(); - if (viewManagerCommands != null) { - viewManagerConstants.put("Commands", viewManagerCommands); - } - Map viewManagerNativeProps = viewManager.getNativeProps(); - if (!viewManagerNativeProps.isEmpty()) { - viewManagerConstants.put("NativeProps", viewManagerNativeProps); - } - if (!viewManagerConstants.isEmpty()) { - constants.put(viewManager.getName(), viewManagerConstants); + SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "constants for ViewManager") + .arg("ViewManager", viewManager.getName()) + .flush(); + try { + Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants(); + if (viewManagerBubblingEvents != null) { + recursiveMerge(bubblingEventTypesConstants, viewManagerBubblingEvents); + } + Map viewManagerDirectEvents = viewManager.getExportedCustomDirectEventTypeConstants(); + if (viewManagerDirectEvents != null) { + recursiveMerge(directEventTypesConstants, viewManagerDirectEvents); + } + Map viewManagerConstants = MapBuilder.newHashMap(); + Map customViewConstants = viewManager.getExportedViewConstants(); + if (customViewConstants != null) { + viewManagerConstants.put("Constants", customViewConstants); + } + Map viewManagerCommands = viewManager.getCommandsMap(); + if (viewManagerCommands != null) { + viewManagerConstants.put("Commands", viewManagerCommands); + } + Map viewManagerNativeProps = viewManager.getNativeProps(); + if (!viewManagerNativeProps.isEmpty()) { + viewManagerConstants.put("NativeProps", viewManagerNativeProps); + } + if (!viewManagerConstants.isEmpty()) { + constants.put(viewManager.getName(), viewManagerConstants); + } + } finally { + Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } }