Improve handling of hwcomposer with unsupported present fences
An implementation such as HWC2OnFbAdapter always returns -1 for the
present fence. FrameTimeline should not ignore invalid fences in
mPendingPresentFences, since in this case every fence is invalid,
resulting in resource leaks. Similarly, PresentLatencyTracker should not
be used if HWC doesn't support present fences.
Test: no logspam running on starnix (fuchsia), which uses framebuffer
Test: booted emulator, no behavior change
Test: booted panther, no behavior change
Change-Id: I4a11edc443a1cd3a395fc8f97b93a5474d11fe31
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 6961f7c..609c2f5 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2430,7 +2430,9 @@
const TimePoint compositeTime =
TimePoint::fromNs(mCompositionEngine->getLastFrameRefreshTimestamp());
const Duration presentLatency =
- mPresentLatencyTracker.trackPendingFrame(compositeTime, presentFenceTime);
+ !getHwComposer().hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)
+ ? mPresentLatencyTracker.trackPendingFrame(compositeTime, presentFenceTime)
+ : Duration::zero();
const auto& schedule = mScheduler->getVsyncSchedule();
const TimePoint vsyncDeadline = schedule.vsyncDeadlineAfter(presentTime);