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.
*/
public void dispatchViewUpdates(int batchId) {
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIImplementation.dispatchViewUpdates")
.arg("batchId", batchId)
.flush();
try {
updateViewHierarchy();
mNativeViewHierarchyOptimizer.onBatchComplete();
mOperationsQueue.dispatchViewUpdates(batchId);
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
}
protected void updateViewHierarchy() {
Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIImplementation.updateViewHierarchy");
try {
for (int i = 0; i < mShadowNodeRegistry.getRootNodeCount(); i++) {
int tag = mShadowNodeRegistry.getRootTag(i);
ReactShadowNode cssRoot = mShadowNodeRegistry.getNode(tag);
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIImplementation.notifyOnBeforeLayoutRecursive")
.arg("rootTag", cssRoot.getReactTag())
.flush();
try {
notifyOnBeforeLayoutRecursive(cssRoot);
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
calculateRootLayout(cssRoot);
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIImplementation.applyUpdatesRecursive")
.arg("rootTag", cssRoot.getReactTag())
.flush();
try {
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) {
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
// receiving new operations
final ArrayList<UIOperation> operations = mOperations.isEmpty() ? null : mOperations;
@ -746,7 +752,13 @@ public class UIViewOperationQueue {
mViewHierarchyUpdateDebugListener.onViewHierarchyUpdateEnqueued();
}
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"acquiring mDispatchRunnablesLock")
.arg("batchId", batchId)
.flush();
synchronized (mDispatchRunnablesLock) {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
mDispatchUIRunnables.add(
new Runnable() {
@Override
@ -797,6 +809,9 @@ public class UIViewOperationQueue {
}
});
}
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
}
/* package */ void resumeFrameCallback() {