Skip to content

Commit cb61960

Browse files
ayc1facebook-github-bot
authored andcommitted
Add systrace to UIManagerModule.createConstants
Summary: - Differentiate when the constants are coming from lazy view managers or not - Add systrace sections to each reactpackage iteration for lazy view managers Differential Revision: D9664719 fbshipit-source-id: 3b8c6b3b40667a833471fcb957367501781b0f5d
1 parent 1edeaef commit cb61960

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ public List<ViewManager> getOrCreateViewManagers(
792792
}
793793

794794
public @Nullable List<String> getViewManagerNames() {
795+
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerNames");
795796
ReactApplicationContext context;
796797
synchronized(mReactContextLock) {
797798
context = (ReactApplicationContext) getCurrentReactContext();
@@ -803,15 +804,20 @@ public List<ViewManager> getOrCreateViewManagers(
803804
synchronized (mPackages) {
804805
Set<String> uniqueNames = new HashSet<>();
805806
for (ReactPackage reactPackage : mPackages) {
807+
SystraceMessage.beginSection(
808+
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerName")
809+
.arg("Package", reactPackage.getClass().getSimpleName())
810+
.flush();
806811
if (reactPackage instanceof ViewManagerOnDemandReactPackage) {
807812
List<String> names =
808-
((ViewManagerOnDemandReactPackage) reactPackage)
809-
.getViewManagerNames(context);
813+
((ViewManagerOnDemandReactPackage) reactPackage).getViewManagerNames(context);
810814
if (names != null) {
811815
uniqueNames.addAll(names);
812816
}
813817
}
818+
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
814819
}
820+
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
815821
return new ArrayList<>(uniqueNames);
816822
}
817823
}

ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,14 @@ public void onCatalystInstanceDestroy() {
212212

213213
private static Map<String, Object> createConstants(ViewManagerResolver viewManagerResolver) {
214214
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START);
215-
Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants");
215+
SystraceMessage.beginSection(
216+
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants")
217+
.arg("Lazy", true)
218+
.flush();
216219
try {
217220
return UIManagerModuleConstantsHelper.createConstants(viewManagerResolver);
218221
} finally {
219-
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
222+
SystraceMessage.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
220223
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END);
221224
}
222225
}
@@ -226,12 +229,15 @@ private static Map<String, Object> createConstants(
226229
@Nullable Map<String, Object> customBubblingEvents,
227230
@Nullable Map<String, Object> customDirectEvents) {
228231
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START);
229-
Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants");
232+
SystraceMessage.beginSection(
233+
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants")
234+
.arg("Lazy", false)
235+
.flush();
230236
try {
231237
return UIManagerModuleConstantsHelper.createConstants(
232238
viewManagers, customBubblingEvents, customDirectEvents);
233239
} finally {
234-
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
240+
SystraceMessage.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
235241
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END);
236242
}
237243
}

ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
constants.put(viewManagerName, viewManagerConstants);
100100
}
101101
} finally {
102-
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
102+
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
103103
}
104104
}
105105

0 commit comments

Comments
 (0)