Skip to content

Commit

Permalink
Report perf counters always when we call flushPendingBatches()
Browse files Browse the repository at this point in the history
Reviewed By: AaaChiuuu

Differential Revision: D5678088

fbshipit-source-id: 35d909a432ece9539bd48e0bf4ddb14d5953a096
  • Loading branch information
alexeylang authored and facebook-github-bot committed Aug 22, 2017
1 parent e063453 commit 4aae843
Showing 1 changed file with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -899,12 +899,12 @@ public void runGuarded() {
flushPendingBatches();
}

private boolean flushPendingBatches() {
private void flushPendingBatches() {
if (mIsInIllegalUIState) {
FLog.w(
ReactConstants.TAG,
"Not flushing pending UI operations because of previously thrown Exception");
return false;
return;
}

final ArrayList<Runnable> runnables;
Expand All @@ -913,18 +913,28 @@ private boolean flushPendingBatches() {
runnables = mDispatchUIRunnables;
mDispatchUIRunnables = new ArrayList<>();
} else {
runnables = null;
return;
}
}

if (runnables == null) {
return false;
}

final long batchedExecutionStartTime = SystemClock.uptimeMillis();
for (Runnable runnable : runnables) {
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;
}

/**
Expand Down Expand Up @@ -969,23 +979,7 @@ public void doFrameGuarded(long frameTimeNanos) {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}

final long flushPendingBatchesStartTime = SystemClock.uptimeMillis();
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;
}
flushPendingBatches();

ReactChoreographer.getInstance().postFrameCallback(
ReactChoreographer.CallbackType.DISPATCH_UI, this);
Expand Down

0 comments on commit 4aae843

Please sign in to comment.