add Systrace to render logic

Reviewed By: achen1

Differential Revision: D5153246

fbshipit-source-id: 4f6f6c7117734552682995fc74a3a926a63feb28
This commit is contained in:
Aaron Chiu 2017-05-31 21:45:24 -07:00 committed by Facebook Github Bot
parent ae49713342
commit 8394f9b553
2 changed files with 116 additions and 67 deletions

View File

@ -552,19 +552,53 @@ public class UIImplementation {
* Invoked at the end of the transaction to commit any updates to the node hierarchy. * Invoked at the end of the transaction to commit any updates to the node hierarchy.
*/ */
public void dispatchViewUpdates(int batchId) { public void dispatchViewUpdates(int batchId) {
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIImplementation.dispatchViewUpdates")
.arg("batchId", batchId)
.flush();
try {
updateViewHierarchy(); updateViewHierarchy();
mNativeViewHierarchyOptimizer.onBatchComplete(); mNativeViewHierarchyOptimizer.onBatchComplete();
mOperationsQueue.dispatchViewUpdates(batchId); mOperationsQueue.dispatchViewUpdates(batchId);
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
} }
protected void updateViewHierarchy() { protected void updateViewHierarchy() {
Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIImplementation.updateViewHierarchy");
try {
for (int i = 0; i < mShadowNodeRegistry.getRootNodeCount(); i++) { for (int i = 0; i < mShadowNodeRegistry.getRootNodeCount(); i++) {
int tag = mShadowNodeRegistry.getRootTag(i); int tag = mShadowNodeRegistry.getRootTag(i);
ReactShadowNode cssRoot = mShadowNodeRegistry.getNode(tag); ReactShadowNode cssRoot = mShadowNodeRegistry.getNode(tag);
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIImplementation.notifyOnBeforeLayoutRecursive")
.arg("rootTag", cssRoot.getReactTag())
.flush();
try {
notifyOnBeforeLayoutRecursive(cssRoot); notifyOnBeforeLayoutRecursive(cssRoot);
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
calculateRootLayout(cssRoot); calculateRootLayout(cssRoot);
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIImplementation.applyUpdatesRecursive")
.arg("rootTag", cssRoot.getReactTag())
.flush();
try {
applyUpdatesRecursive(cssRoot, 0f, 0f); applyUpdatesRecursive(cssRoot, 0f, 0f);
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
}
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
} }
} }

View File

@ -724,6 +724,12 @@ public class UIViewOperationQueue {
} }
/* package */ void dispatchViewUpdates(final int batchId) { /* package */ void dispatchViewUpdates(final int batchId) {
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIImplementation.dispatchViewUpdates")
.arg("batchId", batchId)
.flush();
try {
// Store the current operation queues to dispatch and create new empty ones to continue // Store the current operation queues to dispatch and create new empty ones to continue
// receiving new operations // receiving new operations
final ArrayList<UIOperation> operations = mOperations.isEmpty() ? null : mOperations; final ArrayList<UIOperation> operations = mOperations.isEmpty() ? null : mOperations;
@ -746,7 +752,13 @@ public class UIViewOperationQueue {
mViewHierarchyUpdateDebugListener.onViewHierarchyUpdateEnqueued(); mViewHierarchyUpdateDebugListener.onViewHierarchyUpdateEnqueued();
} }
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"acquiring mDispatchRunnablesLock")
.arg("batchId", batchId)
.flush();
synchronized (mDispatchRunnablesLock) { synchronized (mDispatchRunnablesLock) {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
mDispatchUIRunnables.add( mDispatchUIRunnables.add(
new Runnable() { new Runnable() {
@Override @Override
@ -797,6 +809,9 @@ public class UIViewOperationQueue {
} }
}); });
} }
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
} }
/* package */ void resumeFrameCallback() { /* package */ void resumeFrameCallback() {