Merge "SF: Fix ADPF regression due to wrong present fence" into udc-dev am: 01201564a7 am: 20e8741904
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/23353722
Change-Id: Id9df1aded472b401855233e07eed5de2288ebbae
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 267bc23..95911d8 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2655,12 +2655,15 @@
mTimeStats->recordFrameDuration(frameTime.ns(), systemTime());
- // Send a power hint hint after presentation is finished
+ // Send a power hint after presentation is finished.
if (mPowerHintSessionEnabled) {
- const nsecs_t pastPresentTime =
- getPreviousPresentFence(frameTime, vsyncPeriod)->getSignalTime();
+ // Now that the current frame has been presented above, PowerAdvisor needs the present time
+ // of the previous frame (whose fence is signaled by now) to determine how long the HWC had
+ // waited on that fence to retire before presenting.
+ const auto& previousPresentFence = mPreviousPresentFences[0].fenceTime;
- mPowerAdvisor->setSfPresentTiming(TimePoint::fromNs(pastPresentTime), TimePoint::now());
+ mPowerAdvisor->setSfPresentTiming(TimePoint::fromNs(previousPresentFence->getSignalTime()),
+ TimePoint::now());
mPowerAdvisor->reportActualWorkDuration();
}