From 46b3a89a70d3d9eecb7ba0bb730b453c2a99d657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Gregorczyk?= Date: Tue, 6 Jun 2017 11:01:20 -0700 Subject: [PATCH] Stop SystraceMessage markers with SystraceMessage.endSection Reviewed By: javache Differential Revision: D5182628 fbshipit-source-id: f5112a434cb7564410b0e2e69840e45a0777a184 --- .../com/facebook/react/LazyReactPackage.java | 3 +-- .../facebook/react/ReactInstanceManager.java | 2 +- .../react/bridge/JavaMethodWrapper.java | 24 ++++++++++++------- .../react/bridge/JavaModuleWrapper.java | 2 +- .../facebook/react/bridge/ModuleHolder.java | 5 ++-- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java index 59f074bb2..7a0385059 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java @@ -20,7 +20,6 @@ import com.facebook.react.bridge.ReactMarker; import com.facebook.react.bridge.ReactMarkerConstants; import com.facebook.react.module.model.ReactModuleInfoProvider; import com.facebook.react.uimanager.ViewManager; -import com.facebook.systrace.Systrace; import com.facebook.systrace.SystraceMessage; import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; @@ -82,7 +81,7 @@ public abstract class LazyReactPackage implements ReactPackage { nativeModule = holder.getProvider().get(); } finally { ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); } modules.add(nativeModule); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 85eed009e..08385326d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -1023,6 +1023,6 @@ public class ReactInstanceManager { if (reactPackage instanceof ReactPackageLogger) { ((ReactPackageLogger) reactPackage).endProcessPackage(); } - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java index 8b41f61a3..ec4e97054 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java @@ -230,14 +230,20 @@ public class JavaMethodWrapper implements NativeModule.NativeMethod { SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processArguments") .arg("method", mModuleWrapper.getName() + "." + mMethod.getName()) .flush(); - mArgumentsProcessed = true; - mArgumentExtractors = buildArgumentExtractors(mParameterTypes); - mSignature = buildSignature(mMethod, mParameterTypes, (mType.equals(BaseJavaModule.METHOD_TYPE_SYNC))); - // Since native methods are invoked from a message queue executed on a single thread, it is - // safe to allocate only one arguments object per method that can be reused across calls - mArguments = new Object[mParameterTypes.length]; - mJSArgumentsNeeded = calculateJSArgumentsNeeded(); - com.facebook.systrace.Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + try { + mArgumentsProcessed = true; + mArgumentExtractors = buildArgumentExtractors(mParameterTypes); + mSignature = buildSignature( + mMethod, + mParameterTypes, + (mType.equals(BaseJavaModule.METHOD_TYPE_SYNC))); + // Since native methods are invoked from a message queue executed on a single thread, it is + // safe to allocate only one arguments object per method that can be reused across calls + mArguments = new Object[mParameterTypes.length]; + mJSArgumentsNeeded = calculateJSArgumentsNeeded(); + } finally { + SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + } } public Method getMethod() { @@ -368,7 +374,7 @@ public class JavaMethodWrapper implements NativeModule.NativeMethod { throw new RuntimeException("Could not invoke " + traceName, ite); } } finally { - com.facebook.systrace.Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java index afe877412..33c97719b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java @@ -153,7 +153,7 @@ public class JavaModuleWrapper { Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(GET_CONSTANTS_END); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java index c56c70a50..45d7b0cf3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java @@ -11,7 +11,6 @@ import java.util.concurrent.atomic.AtomicInteger; import com.facebook.infer.annotation.Assertions; import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.module.model.ReactModuleInfo; -import com.facebook.systrace.Systrace; import com.facebook.systrace.SystraceMessage; import static com.facebook.infer.annotation.Assertions.assertNotNull; @@ -170,8 +169,8 @@ public class ModuleHolder { doInitialize(module); } } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(CREATE_MODULE_END, instanceKey); + SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); } return module; } @@ -200,7 +199,7 @@ public class ModuleHolder { } } finally { ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_END); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); } } }