Skip to content

Commit 46b3a89

Browse files
Michał Gregorczykfacebook-github-bot
authored andcommitted
Stop SystraceMessage markers with SystraceMessage.endSection
Reviewed By: javache Differential Revision: D5182628 fbshipit-source-id: f5112a434cb7564410b0e2e69840e45a0777a184
1 parent 964c3a1 commit 46b3a89

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.facebook.react.bridge.ReactMarkerConstants;
2121
import com.facebook.react.module.model.ReactModuleInfoProvider;
2222
import com.facebook.react.uimanager.ViewManager;
23-
import com.facebook.systrace.Systrace;
2423
import com.facebook.systrace.SystraceMessage;
2524

2625
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
@@ -82,7 +81,7 @@ public final List<NativeModule> createNativeModules(ReactApplicationContext reac
8281
nativeModule = holder.getProvider().get();
8382
} finally {
8483
ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
85-
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
84+
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush();
8685
}
8786
modules.add(nativeModule);
8887
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,6 @@ private void processPackage(
10231023
if (reactPackage instanceof ReactPackageLogger) {
10241024
((ReactPackageLogger) reactPackage).endProcessPackage();
10251025
}
1026-
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
1026+
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush();
10271027
}
10281028
}

ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,20 @@ private void processArguments() {
230230
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processArguments")
231231
.arg("method", mModuleWrapper.getName() + "." + mMethod.getName())
232232
.flush();
233-
mArgumentsProcessed = true;
234-
mArgumentExtractors = buildArgumentExtractors(mParameterTypes);
235-
mSignature = buildSignature(mMethod, mParameterTypes, (mType.equals(BaseJavaModule.METHOD_TYPE_SYNC)));
236-
// Since native methods are invoked from a message queue executed on a single thread, it is
237-
// safe to allocate only one arguments object per method that can be reused across calls
238-
mArguments = new Object[mParameterTypes.length];
239-
mJSArgumentsNeeded = calculateJSArgumentsNeeded();
240-
com.facebook.systrace.Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
233+
try {
234+
mArgumentsProcessed = true;
235+
mArgumentExtractors = buildArgumentExtractors(mParameterTypes);
236+
mSignature = buildSignature(
237+
mMethod,
238+
mParameterTypes,
239+
(mType.equals(BaseJavaModule.METHOD_TYPE_SYNC)));
240+
// Since native methods are invoked from a message queue executed on a single thread, it is
241+
// safe to allocate only one arguments object per method that can be reused across calls
242+
mArguments = new Object[mParameterTypes.length];
243+
mJSArgumentsNeeded = calculateJSArgumentsNeeded();
244+
} finally {
245+
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush();
246+
}
241247
}
242248

243249
public Method getMethod() {
@@ -368,7 +374,7 @@ public void invoke(JSInstance jsInstance, ReadableNativeArray parameters) {
368374
throw new RuntimeException("Could not invoke " + traceName, ite);
369375
}
370376
} finally {
371-
com.facebook.systrace.Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
377+
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush();
372378
}
373379
}
374380

ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public List<MethodDescriptor> getMethodDescriptors() {
153153
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
154154

155155
ReactMarker.logMarker(GET_CONSTANTS_END);
156-
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
156+
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush();
157157
}
158158
}
159159

ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.facebook.infer.annotation.Assertions;
1212
import com.facebook.proguard.annotations.DoNotStrip;
1313
import com.facebook.react.module.model.ReactModuleInfo;
14-
import com.facebook.systrace.Systrace;
1514
import com.facebook.systrace.SystraceMessage;
1615

1716
import static com.facebook.infer.annotation.Assertions.assertNotNull;
@@ -170,8 +169,8 @@ private NativeModule create() {
170169
doInitialize(module);
171170
}
172171
} finally {
173-
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
174172
ReactMarker.logMarker(CREATE_MODULE_END, instanceKey);
173+
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush();
175174
}
176175
return module;
177176
}
@@ -200,7 +199,7 @@ private void doInitialize(NativeModule module) {
200199
}
201200
} finally {
202201
ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_END);
203-
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
202+
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush();
204203
}
205204
}
206205
}

0 commit comments

Comments
 (0)