SF: Update InputFlinger outside main thread
Avoids parceling data inside main thread and hot path. Also
avoids any binder contention with one way binder calls. See
bug for more details.
Re landing with the following changes:
Don't discard input commands if input dispatcher is not
available. This can happen if system server crashes and
recovers. We want to keep input commands until
input dispatcher becomes available.
Bug: 206380308
Test: presubmit
Test: systrace
Test: flickertests
Test: health/microbench/display/microbench-test-suite
Change-Id: If0344abdeb28c8a409eb2f641c1e78d53e6f59b2
diff --git a/services/surfaceflinger/BackgroundExecutor.h b/services/surfaceflinger/BackgroundExecutor.h
index 6f6d305..6db7dda 100644
--- a/services/surfaceflinger/BackgroundExecutor.h
+++ b/services/surfaceflinger/BackgroundExecutor.h
@@ -16,6 +16,7 @@
#pragma once
+#include <android-base/thread_annotations.h>
#include <utils/Singleton.h>
#include <condition_variable>
#include <mutex>
@@ -33,10 +34,10 @@
private:
std::mutex mMutex;
- std::condition_variable mWorkAvailableCv;
+ std::condition_variable mWorkAvailableCv GUARDED_BY(mMutex);
+ bool mDone GUARDED_BY(mMutex) = false;
+ std::vector<std::function<void()>> mTasks GUARDED_BY(mMutex);
std::thread mThread;
- bool mDone = false;
- std::vector<std::function<void()>> mTasks;
};
} // namespace android