OSDN Git Service

sf: Defer DispSync initialization
authorSaurabh Shah <saurshah@codeaurora.org>
Thu, 13 Jul 2017 17:45:07 +0000 (10:45 -0700)
committerDan Stoza <stoza@google.com>
Thu, 27 Jul 2017 21:36:52 +0000 (21:36 +0000)
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
(cherry picked from commit f41745301d5ecfa680dcef3a1948a8a321f80509)

services/surfaceflinger/DispSync.cpp
services/surfaceflinger/DispSync.h
services/surfaceflinger/SurfaceFlinger.cpp

index bd9b8aa..ea04839 100644 (file)
@@ -377,11 +377,16 @@ private:
 DispSync::DispSync(const char* name) :
         mName(name),
         mRefreshSkipCount(0),
-        mThread(new DispSyncThread(name)),
-        mIgnorePresentFences(!SurfaceFlinger::hasSyncFramework){
+        mThread(new DispSyncThread(name)) {
+}
+
+DispSync::~DispSync() {}
 
-    mPresentTimeOffset = SurfaceFlinger::dispSyncPresentTimeOffset;
+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 @@ DispSync::DispSync(const char* name) :
         ALOGE("Couldn't set SCHED_FIFO for DispSyncThread");
     }
 
-
     reset();
     beginResync();
 
@@ -405,8 +409,6 @@ DispSync::DispSync(const char* name) :
     }
 }
 
-DispSync::~DispSync() {}
-
 void DispSync::reset() {
     Mutex::Autolock lock(mMutex);
 
index 82ae795..3c34fb0 100644 (file)
@@ -55,6 +55,8 @@ public:
     explicit DispSync(const char* name);
     ~DispSync();
 
+    void init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset);
+
     // reset clears the resync samples and error value.
     void reset();
 
index 63f260a..d435dbc 100644 (file)
@@ -195,6 +195,8 @@ SurfaceFlinger::SurfaceFlinger()
     hasWideColorDisplay =
             getBool<ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::hasWideColorDisplay>(false);
 
+    mPrimaryDispSync.init(hasSyncFramework, dispSyncPresentTimeOffset);
+
     // debugging stuff...
     char value[PROPERTY_VALUE_MAX];