From 9953e060ba211798cd5efe04afb1bcf4ef5b600a Mon Sep 17 00:00:00 2001 From: Ady Abraham Date: Wed, 24 Jul 2024 22:56:22 -0700 Subject: SF: add a work duration slack when missing a frame When missing a frame, SF usually ends up waiting 1ms for the previous fence to fire. This causes sometimes skipping the next frame as the work duration with the 1ms pushes the vsync one more frame. Bug: 354007767 Flag: com.android.graphics.surfaceflinger.flags.allow_n_vsyncs_in_targeter Test: SF unit tests Change-Id: Ia4e2791c420c17bcbe123bd61cc569695702a40c --- services/surfaceflinger/SurfaceFlinger.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'services/surfaceflinger/SurfaceFlinger.cpp') diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index e32202f788..b2fe5ae5a6 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2164,12 +2164,12 @@ sp SurfaceFlinger::createDisplayEventConnection( return mScheduler->createDisplayEventConnection(cycle, eventRegistration, layerHandle); } -void SurfaceFlinger::scheduleCommit(FrameHint hint) { +void SurfaceFlinger::scheduleCommit(FrameHint hint, Duration workDurationSlack) { if (hint == FrameHint::kActive) { mScheduler->resetIdleTimer(); } mPowerAdvisor->notifyDisplayUpdateImminentAndCpuReset(); - mScheduler->scheduleFrame(); + mScheduler->scheduleFrame(workDurationSlack); } void SurfaceFlinger::scheduleComposite(FrameHint hint) { @@ -2629,7 +2629,10 @@ bool SurfaceFlinger::commit(PhysicalDisplayId pacesetterId, mScheduler->getVsyncSchedule()->getTracker().onFrameMissed( pacesetterFrameTarget.expectedPresentTime()); } - scheduleCommit(FrameHint::kNone); + const Duration slack = FlagManager::getInstance().allow_n_vsyncs_in_targeter() + ? TimePoint::now() - pacesetterFrameTarget.frameBeginTime() + : Duration::fromNs(0); + scheduleCommit(FrameHint::kNone, slack); return false; } } -- cgit v1.2.3-59-g8ed1b