summaryrefslogtreecommitdiff
path: root/libs/hwui/JankTracker.cpp
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2016-07-29 10:08:16 -0700
committer John Reck <jreck@google.com> 2016-07-29 10:08:16 -0700
commitfb5c675b7e1fee074f19cf1866b5dda0785dbe64 (patch)
tree54c983e39ad8a3ee94062b8c509054ba87c9c81d /libs/hwui/JankTracker.cpp
parent942ad98481be73e1f4efe0e6837d8930ec4d9d6b (diff)
parent67daab6a1e0897cd0528a19071eeb9f4a2b00b49 (diff)
resolve merge conflicts of 67daab6 to nyc-mr1-dev-plus-aosp
Change-Id: I35f867b8d6408a7eae9cf5643f0908259de90cb1
Diffstat (limited to 'libs/hwui/JankTracker.cpp')
-rw-r--r--libs/hwui/JankTracker.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp
index ebe9c4240221..ed6b211eef1b 100644
--- a/libs/hwui/JankTracker.cpp
+++ b/libs/hwui/JankTracker.cpp
@@ -16,6 +16,7 @@
#include "JankTracker.h"
#include "Properties.h"
+#include "utils/TimeUtils.h"
#include <algorithm>
#include <cutils/ashmem.h>
@@ -119,11 +120,27 @@ static uint32_t frameTimeForFrameCountIndex(uint32_t index) {
return index;
}
-JankTracker::JankTracker(nsecs_t frameIntervalNanos) {
+JankTracker::JankTracker(const DisplayInfo& displayInfo) {
// By default this will use malloc memory. It may be moved later to ashmem
// if there is shared space for it and a request comes in to do that.
mData = new ProfileData;
reset();
+ nsecs_t frameIntervalNanos = static_cast<nsecs_t>(1_s / displayInfo.fps);
+#if USE_HWC2
+ nsecs_t sfOffset = frameIntervalNanos - (displayInfo.presentationDeadline - 1_ms);
+ nsecs_t offsetDelta = sfOffset - displayInfo.appVsyncOffset;
+ // There are two different offset cases. If the offsetDelta is positive
+ // and small, then the intention is to give apps extra time by leveraging
+ // pipelining between the UI & RT threads. If the offsetDelta is large or
+ // negative, the intention is to subtract time from the total duration
+ // in which case we can't afford to wait for dequeueBuffer blockage.
+ if (offsetDelta <= 4_ms && offsetDelta >= 0) {
+ // SF will begin composition at VSYNC-app + offsetDelta. If we are triple
+ // buffered, this is the expected time at which dequeueBuffer will
+ // return due to the staggering of VSYNC-app & VSYNC-sf.
+ mDequeueTimeForgiveness = offsetDelta + 4_ms;
+ }
+#endif
setFrameInterval(frameIntervalNanos);
}
@@ -213,6 +230,19 @@ void JankTracker::addFrame(const FrameInfo& frame) {
mData->totalFrameCount++;
// Fast-path for jank-free frames
int64_t totalDuration = frame.duration(sFrameStart, FrameInfoIndex::FrameCompleted);
+ if (mDequeueTimeForgiveness
+ && frame[FrameInfoIndex::DequeueBufferDuration] > 500_us) {
+ nsecs_t expectedDequeueDuration =
+ mDequeueTimeForgiveness + frame[FrameInfoIndex::Vsync]
+ - frame[FrameInfoIndex::IssueDrawCommandsStart];
+ if (expectedDequeueDuration > 0) {
+ // Forgive only up to the expected amount, but not more than
+ // the actual time spent blocked.
+ nsecs_t forgiveAmount = std::min(expectedDequeueDuration,
+ frame[FrameInfoIndex::DequeueBufferDuration]);
+ totalDuration -= forgiveAmount;
+ }
+ }
uint32_t framebucket = frameCountIndexForFrameTime(totalDuration);
// Keep the fast path as fast as possible.
if (CC_LIKELY(totalDuration < mFrameInterval)) {