From 7912d80f5a383c91e3d093613dcf05861dc9a2de Mon Sep 17 00:00:00 2001 From: ramindani Date: Wed, 12 Jul 2023 20:37:59 -0700 Subject: [SF] Update to use updateRefreshRateOverlayRate from setActiveMode setActiveMode updates the refresh rate on the overlay when changes the refresh rate not caused by the HWC callback, updating overlay directly created the race condition for the updates. Updates the order to enable the overlay first and then making the call to HWC to enableRefreshRateCallbackDebugEnabled BUG: 279544150 Test: manual test Change-Id: I42eed19242944479e5f9e6edf10565417f358a73 Merged-In: I42eed19242944479e5f9e6edf10565417f358a73 --- services/surfaceflinger/SurfaceFlinger.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'services/surfaceflinger/SurfaceFlinger.cpp') diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index dddc9b50c0..c0d6d72afe 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -7826,19 +7826,22 @@ void SurfaceFlinger::enableRefreshRateOverlay(bool enable) { bool setByHwc = getHwComposer().hasCapability(Capability::REFRESH_RATE_CHANGED_CALLBACK_DEBUG); for (const auto& [id, display] : mPhysicalDisplays) { if (display.snapshot().connectionType() == ui::DisplayConnectionType::Internal) { - if (setByHwc) { - const auto status = - getHwComposer().setRefreshRateChangedCallbackDebugEnabled(id, enable); - if (status != NO_ERROR) { - ALOGE("Error updating the refresh rate changed callback debug enabled"); - return; - } - } - if (const auto device = getDisplayDeviceLocked(id)) { - device->enableRefreshRateOverlay(enable, setByHwc, mRefreshRateOverlaySpinner, - mRefreshRateOverlayRenderRate, - mRefreshRateOverlayShowInMiddle); + const auto enableOverlay = [&](const bool setByHwc) FTL_FAKE_GUARD( + kMainThreadContext) { + device->enableRefreshRateOverlay(enable, setByHwc, mRefreshRateOverlaySpinner, + mRefreshRateOverlayRenderRate, + mRefreshRateOverlayShowInMiddle); + }; + enableOverlay(setByHwc); + if (setByHwc) { + const auto status = + getHwComposer().setRefreshRateChangedCallbackDebugEnabled(id, enable); + if (status != NO_ERROR) { + ALOGE("Error updating the refresh rate changed callback debug enabled"); + enableOverlay(/*setByHwc*/ false); + } + } } } } -- cgit v1.2.3-59-g8ed1b