summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ram Indani <ramindani@google.com> 2022-06-23 05:23:19 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-06-23 05:23:19 +0000
commita489cfaec733b1db4c04ca47187e9a9c6c37adbb (patch)
tree858cea16807c5dd45529666c696bcf872d146cb6
parent2fae49744f0f52b7ab992fdac0efe32096fc7808 (diff)
parenta556d071c1731df6103c8eb86a52503b962c33bc (diff)
Merge "SF: Fix deadlock while stopping idle timer" into tm-qpr-dev
-rw-r--r--services/surfaceflinger/Scheduler/Scheduler.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 08a1edea60..727cb0817e 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -25,6 +25,7 @@
#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
#include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h>
#include <configstore/Utils.h>
+#include <ftl/fake_guard.h>
#include <gui/WindowInfo.h>
#include <system/window.h>
#include <ui/DisplayStatInfo.h>
@@ -94,9 +95,13 @@ void Scheduler::startTimers() {
}
void Scheduler::setRefreshRateConfigs(std::shared_ptr<RefreshRateConfigs> configs) {
+ // The current RefreshRateConfigs instance may outlive this call, so unbind its idle timer.
{
- // The current RefreshRateConfigs instance may outlive this call, so unbind its idle timer.
- std::scoped_lock lock(mRefreshRateConfigsLock);
+ // mRefreshRateConfigsLock is not locked here to avoid the deadlock
+ // as the callback can attempt to acquire the lock before stopIdleTimer can finish
+ // the execution. It's safe to FakeGuard as main thread is the only thread that
+ // writes to the mRefreshRateConfigs.
+ ftl::FakeGuard guard(mRefreshRateConfigsLock);
if (mRefreshRateConfigs) {
mRefreshRateConfigs->stopIdleTimer();
mRefreshRateConfigs->clearIdleTimerCallbacks();