Loading libs/gui/BLASTBufferQueue.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -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"); } Loading @@ -175,6 +186,7 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceCont } BLASTBufferQueue::~BLASTBufferQueue() { TransactionCompletedListener::getInstance()->removeQueueStallListener(this); if (mPendingTransactions.empty()) { return; } Loading Loading @@ -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 libs/gui/ITransactionCompletedListener.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ namespace { // Anonymous enum class Tag : uint32_t { ON_TRANSACTION_COMPLETED = IBinder::FIRST_CALL_TRANSACTION, ON_RELEASE_BUFFER, ON_TRANSACTION_QUEUE_STALLED, LAST = ON_RELEASE_BUFFER, }; Loading Loading @@ -277,6 +278,11 @@ public: callbackId, releaseFence, currentMaxAcquiredBufferCount); } void onTransactionQueueStalled() override { callRemoteAsync<decltype(&ITransactionCompletedListener::onTransactionQueueStalled)>( Tag::ON_TRANSACTION_QUEUE_STALLED); } }; // Out-of-line virtual method definitions to trigger vtable emission in this translation unit (see Loading @@ -297,6 +303,9 @@ status_t BnTransactionCompletedListener::onTransact(uint32_t code, const Parcel& &ITransactionCompletedListener::onTransactionCompleted); case Tag::ON_RELEASE_BUFFER: return callLocalAsync(data, reply, &ITransactionCompletedListener::onReleaseBuffer); case Tag::ON_TRANSACTION_QUEUE_STALLED: return callLocalAsync(data, reply, &ITransactionCompletedListener::onTransactionQueueStalled); } } Loading libs/gui/SurfaceComposerClient.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -447,6 +447,27 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener } } void TransactionCompletedListener::onTransactionQueueStalled() { std::unordered_map<void*, std::function<void()>> callbackCopy; { std::scoped_lock<std::mutex> lock(mMutex); callbackCopy = mQueueStallListeners; } for (auto const& it : callbackCopy) { it.second(); } } void TransactionCompletedListener::addQueueStallListener(std::function<void()> stallListener, void* id) { std::scoped_lock<std::mutex> lock(mMutex); mQueueStallListeners[id] = stallListener; } void TransactionCompletedListener::removeQueueStallListener(void *id) { std::scoped_lock<std::mutex> lock(mMutex); mQueueStallListeners.erase(id); } void TransactionCompletedListener::onReleaseBuffer(ReleaseCallbackId callbackId, sp<Fence> releaseFence, uint32_t currentMaxAcquiredBufferCount) { Loading libs/gui/include/gui/BLASTBufferQueue.h +10 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,14 @@ public: uint64_t getLastAcquiredFrameNum(); void abandon(); /** * Set a callback to be invoked when we are hung. The boolean parameter * indicates whether the hang is due to an unfired fence. * TODO: The boolean is always true atm, unfired fence is * the only case we detect. */ void setTransactionHangCallback(std::function<void(bool)> callback); virtual ~BLASTBufferQueue(); private: Loading Loading @@ -269,6 +277,8 @@ private: // transaction that will be applied by some sync consumer. bool mAppliedLastTransaction = false; uint64_t mLastAppliedFrameNumber = 0; std::function<void(bool)> mTransactionHangCallback; }; } // namespace android Loading libs/gui/include/gui/ITransactionCompletedListener.h +1 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,7 @@ public: virtual void onReleaseBuffer(ReleaseCallbackId callbackId, sp<Fence> releaseFence, uint32_t currentMaxAcquiredBufferCount) = 0; virtual void onTransactionQueueStalled() = 0; }; class BnTransactionCompletedListener : public SafeBnInterface<ITransactionCompletedListener> { Loading Loading
libs/gui/BLASTBufferQueue.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -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"); } Loading @@ -175,6 +186,7 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceCont } BLASTBufferQueue::~BLASTBufferQueue() { TransactionCompletedListener::getInstance()->removeQueueStallListener(this); if (mPendingTransactions.empty()) { return; } Loading Loading @@ -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
libs/gui/ITransactionCompletedListener.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ namespace { // Anonymous enum class Tag : uint32_t { ON_TRANSACTION_COMPLETED = IBinder::FIRST_CALL_TRANSACTION, ON_RELEASE_BUFFER, ON_TRANSACTION_QUEUE_STALLED, LAST = ON_RELEASE_BUFFER, }; Loading Loading @@ -277,6 +278,11 @@ public: callbackId, releaseFence, currentMaxAcquiredBufferCount); } void onTransactionQueueStalled() override { callRemoteAsync<decltype(&ITransactionCompletedListener::onTransactionQueueStalled)>( Tag::ON_TRANSACTION_QUEUE_STALLED); } }; // Out-of-line virtual method definitions to trigger vtable emission in this translation unit (see Loading @@ -297,6 +303,9 @@ status_t BnTransactionCompletedListener::onTransact(uint32_t code, const Parcel& &ITransactionCompletedListener::onTransactionCompleted); case Tag::ON_RELEASE_BUFFER: return callLocalAsync(data, reply, &ITransactionCompletedListener::onReleaseBuffer); case Tag::ON_TRANSACTION_QUEUE_STALLED: return callLocalAsync(data, reply, &ITransactionCompletedListener::onTransactionQueueStalled); } } Loading
libs/gui/SurfaceComposerClient.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -447,6 +447,27 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener } } void TransactionCompletedListener::onTransactionQueueStalled() { std::unordered_map<void*, std::function<void()>> callbackCopy; { std::scoped_lock<std::mutex> lock(mMutex); callbackCopy = mQueueStallListeners; } for (auto const& it : callbackCopy) { it.second(); } } void TransactionCompletedListener::addQueueStallListener(std::function<void()> stallListener, void* id) { std::scoped_lock<std::mutex> lock(mMutex); mQueueStallListeners[id] = stallListener; } void TransactionCompletedListener::removeQueueStallListener(void *id) { std::scoped_lock<std::mutex> lock(mMutex); mQueueStallListeners.erase(id); } void TransactionCompletedListener::onReleaseBuffer(ReleaseCallbackId callbackId, sp<Fence> releaseFence, uint32_t currentMaxAcquiredBufferCount) { Loading
libs/gui/include/gui/BLASTBufferQueue.h +10 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,14 @@ public: uint64_t getLastAcquiredFrameNum(); void abandon(); /** * Set a callback to be invoked when we are hung. The boolean parameter * indicates whether the hang is due to an unfired fence. * TODO: The boolean is always true atm, unfired fence is * the only case we detect. */ void setTransactionHangCallback(std::function<void(bool)> callback); virtual ~BLASTBufferQueue(); private: Loading Loading @@ -269,6 +277,8 @@ private: // transaction that will be applied by some sync consumer. bool mAppliedLastTransaction = false; uint64_t mLastAppliedFrameNumber = 0; std::function<void(bool)> mTransactionHangCallback; }; } // namespace android Loading
libs/gui/include/gui/ITransactionCompletedListener.h +1 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,7 @@ public: virtual void onReleaseBuffer(ReleaseCallbackId callbackId, sp<Fence> releaseFence, uint32_t currentMaxAcquiredBufferCount) = 0; virtual void onTransactionQueueStalled() = 0; }; class BnTransactionCompletedListener : public SafeBnInterface<ITransactionCompletedListener> { Loading