summaryrefslogtreecommitdiff
path: root/libs/hwui/JankTracker.cpp
diff options
context:
space:
mode:
author Jorim Jaggi <jjaggi@google.com> 2021-02-03 23:19:29 +0100
committer Jorim Jaggi <jjaggi@google.com> 2021-02-17 14:55:22 +0100
commit71db8892acc0c80c343141139bde8cfd3f037c4a (patch)
tree9f40ac7b2cf2d535d24d9e6eacf8c353e8dcabc8 /libs/hwui/JankTracker.cpp
parent5fdf7b8d26f3cd1a2f2fb8a441d40d33270d3b77 (diff)
Add GPU completion to FrameMetrics (1/3)
- Add SurfaceStatsCallback to TransactionCompletedListener - Register a callback in RenderProxy to be called when we have surface stats from SF via the BLAST callback. - Instead of finishing a frame for frame metrics reporting immediately, wait until BLAST callback fires, note GPU completion time and finish frame. - Expose GPU_COMPLETION in FrameMetrics - Modify TOTAL_DURATION to also include GPU_COMPLETION Test: FrameMetricsListenerTest Fixes: 171046219 Change-Id: I16fa1d80cfc4e7a5527c18fec7e885409f17ee4d
Diffstat (limited to 'libs/hwui/JankTracker.cpp')
-rw-r--r--libs/hwui/JankTracker.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp
index ccce403ecfac..4a2e30dd38f2 100644
--- a/libs/hwui/JankTracker.cpp
+++ b/libs/hwui/JankTracker.cpp
@@ -79,7 +79,9 @@ static const int64_t EXEMPT_FRAMES_FLAGS = FrameInfoFlags::SurfaceCanvas;
// and filter it out of the frame profile data
static FrameInfoIndex sFrameStart = FrameInfoIndex::IntendedVsync;
-JankTracker::JankTracker(ProfileDataContainer* globalData) {
+JankTracker::JankTracker(ProfileDataContainer* globalData)
+ : mData(globalData->getDataMutex())
+ , mDataMutex(globalData->getDataMutex()) {
mGlobalData = globalData;
nsecs_t frameIntervalNanos = DeviceInfo::getVsyncPeriod();
nsecs_t sfOffset = DeviceInfo::getCompositorOffset();
@@ -107,6 +109,8 @@ void JankTracker::setFrameInterval(nsecs_t frameInterval) {
}
void JankTracker::finishFrame(const FrameInfo& frame) {
+ std::lock_guard lock(mDataMutex);
+
// Fast-path for jank-free frames
int64_t totalDuration = frame.duration(sFrameStart, FrameInfoIndex::FrameCompleted);
if (mDequeueTimeForgiveness && frame[FrameInfoIndex::DequeueBufferDuration] > 500_us) {
@@ -125,7 +129,11 @@ void JankTracker::finishFrame(const FrameInfo& frame) {
}
}
- LOG_ALWAYS_FATAL_IF(totalDuration <= 0, "Impossible totalDuration %" PRId64, totalDuration);
+ LOG_ALWAYS_FATAL_IF(totalDuration <= 0, "Impossible totalDuration %" PRId64 " start=%" PRIi64
+ " gpuComplete=%" PRIi64, totalDuration,
+ frame[FrameInfoIndex::IntendedVsync],
+ frame[FrameInfoIndex::GpuCompleted]);
+
mData->reportFrame(totalDuration);
(*mGlobalData)->reportFrame(totalDuration);
@@ -188,6 +196,7 @@ void JankTracker::finishFrame(const FrameInfo& frame) {
void JankTracker::dumpData(int fd, const ProfileDataDescription* description,
const ProfileData* data) {
+
if (description) {
switch (description->type) {
case JankTrackerType::Generic:
@@ -227,6 +236,7 @@ void JankTracker::dumpFrames(int fd) {
}
void JankTracker::reset() {
+ std::lock_guard lock(mDataMutex);
mFrames.clear();
mData->reset();
(*mGlobalData)->reset();
@@ -235,6 +245,7 @@ void JankTracker::reset() {
}
void JankTracker::finishGpuDraw(const FrameInfo& frame) {
+ std::lock_guard lock(mDataMutex);
int64_t totalGPUDrawTime = frame.gpuDrawTime();
if (totalGPUDrawTime >= 0) {
mData->reportGPUFrame(totalGPUDrawTime);