mirror of
https://github.com/status-im/react-native.git
synced 2025-02-10 16:36:25 +00:00
add more Systrace to native module / view manager constants
Reviewed By: lexs Differential Revision: D3739966 fbshipit-source-id: 4ba31aade00852132e528f96252197b823bb58a3
This commit is contained in:
parent
14188289fc
commit
924187eb9a
@ -15,6 +15,10 @@ import java.util.List;
|
|||||||
import com.facebook.react.bridge.ModuleSpec;
|
import com.facebook.react.bridge.ModuleSpec;
|
||||||
import com.facebook.react.bridge.NativeModule;
|
import com.facebook.react.bridge.NativeModule;
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
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.
|
* React package supporting lazy creation of native modules.
|
||||||
@ -33,7 +37,14 @@ public abstract class LazyReactPackage implements ReactPackage {
|
|||||||
public final List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
public final List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||||
List<NativeModule> modules = new ArrayList<>();
|
List<NativeModule> modules = new ArrayList<>();
|
||||||
for (ModuleSpec holder : getNativeModules(reactContext)) {
|
for (ModuleSpec holder : getNativeModules(reactContext)) {
|
||||||
|
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createNativeModule")
|
||||||
|
.arg("module", holder.getType())
|
||||||
|
.flush();
|
||||||
|
try {
|
||||||
modules.add(holder.getProvider().get());
|
modules.add(holder.getProvider().get());
|
||||||
|
} finally {
|
||||||
|
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return modules;
|
return modules;
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,17 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
|
||||||
import com.facebook.react.bridge.BaseJavaModule;
|
import com.facebook.react.bridge.BaseJavaModule;
|
||||||
import com.facebook.react.bridge.CatalystInstance;
|
import com.facebook.react.bridge.CatalystInstance;
|
||||||
import com.facebook.react.bridge.ExecutorToken;
|
import com.facebook.react.bridge.ExecutorToken;
|
||||||
import com.facebook.react.bridge.NativeArray;
|
import com.facebook.react.bridge.NativeArray;
|
||||||
import com.facebook.react.bridge.ReadableNativeArray;
|
import com.facebook.react.bridge.ReadableNativeArray;
|
||||||
import com.facebook.react.bridge.WritableNativeArray;
|
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++
|
* 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.
|
// NativeMap out of OnLoad.
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
public NativeArray getConstants() {
|
public NativeArray getConstants() {
|
||||||
|
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "Map constants")
|
||||||
|
.arg("moduleName", getName())
|
||||||
|
.flush();
|
||||||
|
Map<String, Object> 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();
|
WritableNativeArray array = new WritableNativeArray();
|
||||||
array.pushMap(Arguments.makeNativeMap(mModule.getConstants()));
|
array.pushMap(writableNativeMap);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -103,11 +101,6 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
|
|||||||
return "RKCameraRollManager";
|
return "RKCameraRollManager";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> getConstants() {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save an image to the gallery (i.e. {@link MediaStore.Images}). This copies the original file
|
* 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
|
* 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);
|
node.putMap("location", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,10 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.facebook.react.common.MapBuilder;
|
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
|
* Helps generate constants map for {@link UIManagerModule} by collecting and merging constants from
|
||||||
@ -42,6 +46,10 @@ import com.facebook.react.common.MapBuilder;
|
|||||||
Map directEventTypesConstants = UIManagerModuleConstants.getDirectEventTypeConstants();
|
Map directEventTypesConstants = UIManagerModuleConstants.getDirectEventTypeConstants();
|
||||||
|
|
||||||
for (ViewManager viewManager : viewManagers) {
|
for (ViewManager viewManager : viewManagers) {
|
||||||
|
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "constants for ViewManager")
|
||||||
|
.arg("ViewManager", viewManager.getName())
|
||||||
|
.flush();
|
||||||
|
try {
|
||||||
Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants();
|
Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants();
|
||||||
if (viewManagerBubblingEvents != null) {
|
if (viewManagerBubblingEvents != null) {
|
||||||
recursiveMerge(bubblingEventTypesConstants, viewManagerBubblingEvents);
|
recursiveMerge(bubblingEventTypesConstants, viewManagerBubblingEvents);
|
||||||
@ -66,6 +74,9 @@ import com.facebook.react.common.MapBuilder;
|
|||||||
if (!viewManagerConstants.isEmpty()) {
|
if (!viewManagerConstants.isEmpty()) {
|
||||||
constants.put(viewManager.getName(), viewManagerConstants);
|
constants.put(viewManager.getName(), viewManagerConstants);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constants.put(CUSTOM_BUBBLING_EVENT_TYPES_KEY, bubblingEventTypesConstants);
|
constants.put(CUSTOM_BUBBLING_EVENT_TYPES_KEY, bubblingEventTypesConstants);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user