diff options
| author | 2021-07-03 02:22:12 +0000 | |
|---|---|---|
| committer | 2021-07-09 00:32:29 +0000 | |
| commit | 07d35cb7dcb6e078968f72c831de555b060424a3 (patch) | |
| tree | 0a51f5bcde952717e835a767e5f974c144a95da5 /libs/hwui/JankTracker.cpp | |
| parent | c701a4c904600cb5457d0ebc2821d7e837e26f96 (diff) | |
Properly protect mFrameMetricsReporter
This field actually requires a special lock, mFrameMetricsReporterMutex.
But there isn't a GUARDED_BY annotation for it. And even if there was,
the compiler feature of -Wthread-safety was not active in this code, so
this error would not have been caught.
To fix this, enable the compiler annotation and add GUARDED_BY
annotation to mFrameMetricsReporter.
And finally, use this lock to properly protect this field.
Bug: 192330836
Test: atest hwui_unit_tests
Change-Id: I76950bfa01bbd7ccdc54c4e8c114430b5aeddf1a
Diffstat (limited to 'libs/hwui/JankTracker.cpp')
| -rw-r--r-- | libs/hwui/JankTracker.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp index dd977c32f531..34e5577066f9 100644 --- a/libs/hwui/JankTracker.cpp +++ b/libs/hwui/JankTracker.cpp @@ -99,7 +99,7 @@ JankTracker::JankTracker(ProfileDataContainer* globalData) mFrameIntervalLegacy = frameIntervalNanos; } -void JankTracker::calculateLegacyJank(FrameInfo& frame) { +void JankTracker::calculateLegacyJank(FrameInfo& frame) REQUIRES(mDataMutex) { // Fast-path for jank-free frames int64_t totalDuration = frame.duration(sFrameStart, FrameInfoIndex::SwapBuffersCompleted); if (mDequeueTimeForgivenessLegacy && frame[FrameInfoIndex::DequeueBufferDuration] > 500_us) { @@ -257,7 +257,7 @@ void JankTracker::finishFrame(FrameInfo& frame, std::unique_ptr<FrameMetricsRepo } } -void JankTracker::recomputeThresholds(int64_t frameBudget) { +void JankTracker::recomputeThresholds(int64_t frameBudget) REQUIRES(mDataMutex) { if (mThresholdsFrameBudget == frameBudget) { return; } @@ -308,7 +308,7 @@ void JankTracker::dumpFrames(int fd) { dprintf(fd, "\n---PROFILEDATA---\n\n"); } -void JankTracker::reset() { +void JankTracker::reset() REQUIRES(mDataMutex) { mFrames.clear(); mData->reset(); (*mGlobalData)->reset(); |