Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2d5a64a authored by Mathias Agopian's avatar Mathias Agopian
Browse files

workaround a deadlock when taking screenshots into a surface

When disconnecting from BufferQueue, we now drain the queue
except the head (which means in the screenshot case we won't
have to block, but we might not have a buffer to show, this
will appear as an error in the log).

Bug: 8362363
Change-Id: If80989aac3c917beea2ebddf3cbb502849d394da
parent dbca4a0e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -995,7 +995,7 @@ void BufferQueue::freeAllBuffersExceptHeadLocked() {
}

status_t BufferQueue::drainQueueLocked() {
    while (mSynchronousMode && !mQueue.isEmpty()) {
    while (mSynchronousMode && mQueue.size() > 1) {
        mDequeueCondition.wait(mMutex);
        if (mAbandoned) {
            ST_LOGE("drainQueueLocked: BufferQueue has been abandoned!");
@@ -1012,7 +1012,7 @@ status_t BufferQueue::drainQueueLocked() {
status_t BufferQueue::drainQueueAndFreeBuffersLocked() {
    status_t err = drainQueueLocked();
    if (err == NO_ERROR) {
        if (mSynchronousMode) {
        if (mQueue.empty()) {
            freeAllBuffersLocked();
        } else {
            freeAllBuffersExceptHeadLocked();