diff options
Diffstat (limited to 'libs/hwui/JankTracker.cpp')
-rw-r--r-- | libs/hwui/JankTracker.cpp | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp index 9d1182819444..ab27a0d00246 100644 --- a/libs/hwui/JankTracker.cpp +++ b/libs/hwui/JankTracker.cpp @@ -18,6 +18,7 @@ #include <errno.h> #include <inttypes.h> +#include <statslog.h> #include <sys/mman.h> #include <algorithm> @@ -27,9 +28,11 @@ #include <cutils/ashmem.h> #include <log/log.h> +#include <sstream> #include "Properties.h" #include "utils/TimeUtils.h" +#include "utils/Trace.h" namespace android { namespace uirenderer { @@ -106,25 +109,23 @@ void JankTracker::setFrameInterval(nsecs_t frameInterval) { mThresholds[kSlowUI] = static_cast<int64_t>(.5 * frameInterval); mThresholds[kSlowSync] = static_cast<int64_t>(.2 * frameInterval); mThresholds[kSlowRT] = static_cast<int64_t>(.75 * frameInterval); - } void JankTracker::finishFrame(const FrameInfo& frame) { // 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 (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]); + nsecs_t forgiveAmount = + std::min(expectedDequeueDuration, frame[FrameInfoIndex::DequeueBufferDuration]); LOG_ALWAYS_FATAL_IF(forgiveAmount >= totalDuration, - "Impossible dequeue duration! dequeue duration reported %" PRId64 - ", total duration %" PRId64, forgiveAmount, totalDuration); + "Impossible dequeue duration! dequeue duration reported %" PRId64 + ", total duration %" PRId64, + forgiveAmount, totalDuration); totalDuration -= forgiveAmount; } } @@ -148,13 +149,28 @@ void JankTracker::finishFrame(const FrameInfo& frame) { for (int i = 0; i < NUM_BUCKETS; i++) { int64_t delta = frame.duration(COMPARISONS[i].start, COMPARISONS[i].end); if (delta >= mThresholds[i] && delta < IGNORE_EXCEEDING) { - mData->reportJankType((JankType) i); - (*mGlobalData)->reportJankType((JankType) i); + mData->reportJankType((JankType)i); + (*mGlobalData)->reportJankType((JankType)i); + } + } + + // Log daveys since they are weird and we don't know what they are (b/70339576) + if (totalDuration >= 700_ms) { + static int sDaveyCount = 0; + std::stringstream ss; + ss << "Davey! duration=" << ns2ms(totalDuration) << "ms; "; + for (size_t i = 0; i < static_cast<size_t>(FrameInfoIndex::NumIndexes); i++) { + ss << FrameInfoNames[i] << "=" << frame[i] << ", "; } + ALOGI("%s", ss.str().c_str()); + // Just so we have something that counts up, the value is largely irrelevant + ATRACE_INT(ss.str().c_str(), ++sDaveyCount); + android::util::stats_write(android::util::DAVEY_OCCURRED, ns2ms(totalDuration)); } } -void JankTracker::dumpData(int fd, const ProfileDataDescription* description, const ProfileData* data) { +void JankTracker::dumpData(int fd, const ProfileDataDescription* description, + const ProfileData* data) { if (description) { switch (description->type) { case JankTrackerType::Generic: @@ -175,33 +191,30 @@ void JankTracker::dumpData(int fd, const ProfileDataDescription* description, co } void JankTracker::dumpFrames(int fd) { - FILE* file = fdopen(fd, "a"); - fprintf(file, "\n\n---PROFILEDATA---\n"); + dprintf(fd, "\n\n---PROFILEDATA---\n"); for (size_t i = 0; i < static_cast<size_t>(FrameInfoIndex::NumIndexes); i++) { - fprintf(file, "%s", FrameInfoNames[i].c_str()); - fprintf(file, ","); + dprintf(fd, "%s", FrameInfoNames[i].c_str()); + dprintf(fd, ","); } for (size_t i = 0; i < mFrames.size(); i++) { FrameInfo& frame = mFrames[i]; if (frame[FrameInfoIndex::SyncStart] == 0) { continue; } - fprintf(file, "\n"); + dprintf(fd, "\n"); for (int i = 0; i < static_cast<int>(FrameInfoIndex::NumIndexes); i++) { - fprintf(file, "%" PRId64 ",", frame[i]); + dprintf(fd, "%" PRId64 ",", frame[i]); } } - fprintf(file, "\n---PROFILEDATA---\n\n"); - fflush(file); + dprintf(fd, "\n---PROFILEDATA---\n\n"); } void JankTracker::reset() { mFrames.clear(); mData->reset(); (*mGlobalData)->reset(); - sFrameStart = Properties::filterOutTestOverhead - ? FrameInfoIndex::HandleInputStart - : FrameInfoIndex::IntendedVsync; + sFrameStart = Properties::filterOutTestOverhead ? FrameInfoIndex::HandleInputStart + : FrameInfoIndex::IntendedVsync; } } /* namespace uirenderer */ |