sf: Defer DispSync initialization
Some DispSync members are initialized based on uninitialized static
members of sf, that are in turn initialized in sf constructor. Fix
the sequence by deferring DispSync initialization.
Current sequence:
sf constructor|-> DispSync constructor -> Access static sf members
|-> Initialize sf static members
New sequence:
sf constructor|-> DispSync constructor
|-> Initialize sf static members
|-> DispSync init -> Access static sf members
Bug: 63671437
Test: "present fences are ignored" not present in SF dumpsys
Change-Id: I618d2bbbbd4e39fc382e67f85dd8d637dd82cf38
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index ac8aa04..bef12ea 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -377,11 +377,16 @@
DispSync::DispSync(const char* name) :
mName(name),
mRefreshSkipCount(0),
- mThread(new DispSyncThread(name)),
- mIgnorePresentFences(!SurfaceFlinger::hasSyncFramework){
+ mThread(new DispSyncThread(name)) {
+}
- mPresentTimeOffset = SurfaceFlinger::dispSyncPresentTimeOffset;
+DispSync::~DispSync() {}
+
+void DispSync::init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset) {
+ mIgnorePresentFences = !hasSyncFramework;
+ mPresentTimeOffset = dispSyncPresentTimeOffset;
mThread->run("DispSync", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE);
+
// set DispSync to SCHED_FIFO to minimize jitter
struct sched_param param = {0};
param.sched_priority = 2;
@@ -389,7 +394,6 @@
ALOGE("Couldn't set SCHED_FIFO for DispSyncThread");
}
-
reset();
beginResync();
@@ -405,8 +409,6 @@
}
}
-DispSync::~DispSync() {}
-
void DispSync::reset() {
Mutex::Autolock lock(mMutex);