diff options
| author | 2021-12-21 10:30:50 -0800 | |
|---|---|---|
| committer | 2022-04-15 15:38:44 -0700 | |
| commit | 4c1b646994a5878b792eaf6358756206d8fe1433 (patch) | |
| tree | 0dd8755bb82e15865183cdf167f5fd9bd9401162 /libs/gui/BLASTBufferQueue.cpp | |
| parent | 1527529f4eccca13d2e1f897abd881c6ffd94dfe (diff) | |
SurfaceFlinger: Report stuck fences to client
It's ocassionally observed in traces that the GPU is hung
resulting in fences failing to fire. This normally propagates
back up as an ANR in dequeueBuffers or onFrameAvailable. The ANR
might then pass from the app team, to the HWUI team, to the WM
team, and then if we are lucky enough to get a trace, to the
GPU team. In this CL we allow the client process to monitor
this situation itself, and proactively trigger an ANR with
a more useful and informative message than "stuck in
dequeueBuffers"
Bug: 216160569
Test: Existing tests pass
Change-Id: I3ff93bf57d24268ac57734dfed2df185985ffe1f
Diffstat (limited to 'libs/gui/BLASTBufferQueue.cpp')
| -rw-r--r-- | libs/gui/BLASTBufferQueue.cpp | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index c2793ac5de..dbccf30fae 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -165,6 +165,17 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, bool updateDestinati      mCurrentMaxAcquiredBufferCount = mMaxAcquiredBuffers;      mNumAcquired = 0;      mNumFrameAvailable = 0; + +    TransactionCompletedListener::getInstance()->addQueueStallListener( +        [&]() { +            std::function<void(bool)> callbackCopy; +            { +                std::unique_lock _lock{mMutex}; +                callbackCopy = mTransactionHangCallback; +            } +            if (callbackCopy) callbackCopy(true); +        }, this); +      BQA_LOGV("BLASTBufferQueue created");  } @@ -175,6 +186,7 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceCont  }  BLASTBufferQueue::~BLASTBufferQueue() { +    TransactionCompletedListener::getInstance()->removeQueueStallListener(this);      if (mPendingTransactions.empty()) {          return;      } @@ -1113,4 +1125,9 @@ bool BLASTBufferQueue::isSameSurfaceControl(const sp<SurfaceControl>& surfaceCon      return SurfaceControl::isSameSurface(mSurfaceControl, surfaceControl);  } +void BLASTBufferQueue::setTransactionHangCallback(std::function<void(bool)> callback) { +    std::unique_lock _lock{mMutex}; +    mTransactionHangCallback = callback; +} +  } // namespace android |