OSDN Git Service

surfaceflinger: work around dumpsys lockup
authorChia-I Wu <olv@google.com>
Thu, 2 Mar 2017 00:08:51 +0000 (16:08 -0800)
committerChia-I Wu <olv@google.com>
Thu, 2 Mar 2017 00:36:24 +0000 (16:36 -0800)
Bug: 35806047
Test: manual
Change-Id: I047ddf0ef9eacd4df7da3c9d91118c3f1592a9eb

services/surfaceflinger/DisplayHardware/HWComposer.cpp
services/surfaceflinger/DisplayHardware/HWComposer.h

index 4a281d4..f03491f 100644 (file)
@@ -69,7 +69,8 @@ HWComposer::HWComposer(bool useVrComposer)
       mCBContext(),
       mEventHandler(nullptr),
       mVSyncCounts(),
-      mRemainingHwcVirtualDisplays(0)
+      mRemainingHwcVirtualDisplays(0),
+      mDumpMayLockUp(false)
 {
     for (size_t i=0 ; i<HWC_NUM_PHYSICAL_DISPLAY_TYPES ; i++) {
         mLastHwVSync[i] = 0;
@@ -489,6 +490,8 @@ status_t HWComposer::prepare(DisplayDevice& displayDevice) {
         return NO_ERROR;
     }
 
+    mDumpMayLockUp = true;
+
     uint32_t numTypes = 0;
     uint32_t numRequests = 0;
     auto error = hwcDisplay->validate(&numTypes, &numRequests);
@@ -633,6 +636,9 @@ status_t HWComposer::presentAndGetReleaseFences(int32_t displayId) {
     auto& displayData = mDisplayData[displayId];
     auto& hwcDisplay = displayData.hwcDisplay;
     auto error = hwcDisplay->present(&displayData.lastPresentFence);
+
+    mDumpMayLockUp = false;
+
     if (error != HWC2::Error::None) {
         ALOGE("presentAndGetReleaseFences: failed for display %d: %s (%d)",
               displayId, to_string(error).c_str(), static_cast<int32_t>(error));
@@ -878,6 +884,11 @@ bool HWComposer::isUsingVrComposer() const {
 }
 
 void HWComposer::dump(String8& result) const {
+    if (mDumpMayLockUp) {
+        result.append("HWComposer dump skipped because present in progress");
+        return;
+    }
+
     // TODO: In order to provide a dump equivalent to HWC1, we need to shadow
     // all the state going into the layers. This is probably better done in
     // Layer itself, but it's going to take a bit of work to get there.
index 0713709..20cca39 100644 (file)
@@ -231,6 +231,9 @@ private:
 
     // thread-safe
     mutable Mutex mVsyncLock;
+
+    // XXX temporary workaround for b/35806047
+    mutable std::atomic<bool> mDumpMayLockUp;
 };
 
 class HWComposerBufferCache {