Report perf counters always when we call flushPendingBatches()

Reviewed By: AaaChiuuu

Differential Revision: D5678088

fbshipit-source-id: 35d909a432ece9539bd48e0bf4ddb14d5953a096
This commit is contained in:
Alexey Lang 2017-08-22 08:34:50 -07:00 committed by Facebook Github Bot
parent e0634531d8
commit 4aae843ebb
1 changed files with 19 additions and 25 deletions

View File

@ -899,12 +899,12 @@ public class UIViewOperationQueue {
flushPendingBatches(); flushPendingBatches();
} }
private boolean flushPendingBatches() { private void flushPendingBatches() {
if (mIsInIllegalUIState) { if (mIsInIllegalUIState) {
FLog.w( FLog.w(
ReactConstants.TAG, ReactConstants.TAG,
"Not flushing pending UI operations because of previously thrown Exception"); "Not flushing pending UI operations because of previously thrown Exception");
return false; return;
} }
final ArrayList<Runnable> runnables; final ArrayList<Runnable> runnables;
@ -913,18 +913,28 @@ public class UIViewOperationQueue {
runnables = mDispatchUIRunnables; runnables = mDispatchUIRunnables;
mDispatchUIRunnables = new ArrayList<>(); mDispatchUIRunnables = new ArrayList<>();
} else { } else {
runnables = null; return;
} }
} }
if (runnables == null) { final long batchedExecutionStartTime = SystemClock.uptimeMillis();
return false;
}
for (Runnable runnable : runnables) { for (Runnable runnable : runnables) {
runnable.run(); runnable.run();
} }
return true;
if (mIsProfilingNextBatch) {
mProfiledBatchBatchedExecutionTime = SystemClock.uptimeMillis() - batchedExecutionStartTime;
mProfiledBatchNonBatchedExecutionTime = mNonBatchedExecutionTotalTime;
mIsProfilingNextBatch = false;
Systrace.beginAsyncSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"batchedExecutionTime",
0,
batchedExecutionStartTime * 1000000);
Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "batchedExecutionTime", 0);
}
mNonBatchedExecutionTotalTime = 0;
} }
/** /**
@ -969,23 +979,7 @@ public class UIViewOperationQueue {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
} }
final long flushPendingBatchesStartTime = SystemClock.uptimeMillis(); flushPendingBatches();
if (flushPendingBatches()) {
if (mIsProfilingNextBatch) {
mProfiledBatchBatchedExecutionTime =
SystemClock.uptimeMillis() - flushPendingBatchesStartTime;
mProfiledBatchNonBatchedExecutionTime = mNonBatchedExecutionTotalTime;
mIsProfilingNextBatch = false;
Systrace.beginAsyncSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"batchedExecutionTime",
0,
flushPendingBatchesStartTime * 1000000);
Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "batchedExecutionTime", 0);
}
mNonBatchedExecutionTotalTime = 0;
}
ReactChoreographer.getInstance().postFrameCallback( ReactChoreographer.getInstance().postFrameCallback(
ReactChoreographer.CallbackType.DISPATCH_UI, this); ReactChoreographer.CallbackType.DISPATCH_UI, this);