From 4aae843ebb59c7aca0bae090445d45f1ae1bf679 Mon Sep 17 00:00:00 2001 From: Alexey Lang Date: Tue, 22 Aug 2017 08:34:50 -0700 Subject: [PATCH] Report perf counters always when we call flushPendingBatches() Reviewed By: AaaChiuuu Differential Revision: D5678088 fbshipit-source-id: 35d909a432ece9539bd48e0bf4ddb14d5953a096 --- .../react/uimanager/UIViewOperationQueue.java | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index 506214023c7c79..62b231a2a679a1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -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 runnables; @@ -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; } /** @@ -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);