From cb6196073a7588f27e063a09137994db9779c2de Mon Sep 17 00:00:00 2001 From: "Andrew Chen (Eng)" Date: Wed, 5 Sep 2018 15:57:23 -0700 Subject: [PATCH] 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 --- .../com/facebook/react/ReactInstanceManager.java | 10 ++++++++-- .../facebook/react/uimanager/UIManagerModule.java | 14 ++++++++++---- .../uimanager/UIManagerModuleConstantsHelper.java | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index d24f13ef4..2ee738c91 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -792,6 +792,7 @@ public class ReactInstanceManager { } public @Nullable List getViewManagerNames() { + Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerNames"); ReactApplicationContext context; synchronized(mReactContextLock) { context = (ReactApplicationContext) getCurrentReactContext(); @@ -803,15 +804,20 @@ public class ReactInstanceManager { synchronized (mPackages) { Set uniqueNames = new HashSet<>(); for (ReactPackage reactPackage : mPackages) { + SystraceMessage.beginSection( + Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerName") + .arg("Package", reactPackage.getClass().getSimpleName()) + .flush(); if (reactPackage instanceof ViewManagerOnDemandReactPackage) { List names = - ((ViewManagerOnDemandReactPackage) reactPackage) - .getViewManagerNames(context); + ((ViewManagerOnDemandReactPackage) reactPackage).getViewManagerNames(context); if (names != null) { uniqueNames.addAll(names); } } + Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } + Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); return new ArrayList<>(uniqueNames); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index f20d8db1d..37255c996 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -212,11 +212,14 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements private static Map createConstants(ViewManagerResolver viewManagerResolver) { ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START); - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants"); + SystraceMessage.beginSection( + Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants") + .arg("Lazy", true) + .flush(); try { return UIManagerModuleConstantsHelper.createConstants(viewManagerResolver); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + SystraceMessage.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END); } } @@ -226,12 +229,15 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements @Nullable Map customBubblingEvents, @Nullable Map customDirectEvents) { ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START); - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants"); + SystraceMessage.beginSection( + Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants") + .arg("Lazy", false) + .flush(); try { return UIManagerModuleConstantsHelper.createConstants( viewManagers, customBubblingEvents, customDirectEvents); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + SystraceMessage.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END); } } 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 beb067f13..b57f8f7ad 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java @@ -99,7 +99,7 @@ import javax.annotation.Nullable; constants.put(viewManagerName, viewManagerConstants); } } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } }