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

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

log an error when dequeueBuffer gets a NULL Fence

Bug: 9858745
Change-Id: If35d6a7d770bf0a42d55bc55880a9ddb721fcfd0
parent 87f9b877
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -406,6 +406,13 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, sp<Fence>* outFence, bool async
            returnFlags |= IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION;
        }


        if (CC_UNLIKELY(mSlots[buf].mFence == NULL)) {
            ST_LOGE("dequeueBuffer: about to return a NULL fence from mSlot. "
                    "buf=%d, w=%d, h=%d, format=%d",
                    buf, buffer->width, buffer->height, buffer->format);
        }

        dpy = mSlots[buf].mEglDisplay;
        eglFence = mSlots[buf].mEglFence;
        *outFence = mSlots[buf].mFence;
@@ -416,11 +423,9 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, sp<Fence>* outFence, bool async
    if (returnFlags & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) {
        status_t error;
        sp<GraphicBuffer> graphicBuffer(
                mGraphicBufferAlloc->createGraphicBuffer(
                        w, h, format, usage, &error));
                mGraphicBufferAlloc->createGraphicBuffer(w, h, format, usage, &error));
        if (graphicBuffer == 0) {
            ST_LOGE("dequeueBuffer: SurfaceComposer::createGraphicBuffer "
                    "failed");
            ST_LOGE("dequeueBuffer: SurfaceComposer::createGraphicBuffer failed");
            return error;
        }

+4 −7
Original line number Diff line number Diff line
@@ -94,13 +94,10 @@ public:
            return result;
        }
        *buf = reply.readInt32();
        bool fenceWasWritten = reply.readInt32();
        if (fenceWasWritten) {
            // If the fence was written by the callee, then overwrite the
            // caller's fence here.  If it wasn't written then don't touch the
            // caller's fence.
        bool nonNull = reply.readInt32();
        if (nonNull) {
            *fence = new Fence();
            reply.read(*(fence->get()));
            reply.read(**fence);
        }
        result = reply.readInt32();
        return result;
@@ -209,7 +206,7 @@ status_t BnGraphicBufferProducer::onTransact(
            reply->writeInt32(buf);
            reply->writeInt32(fence != NULL);
            if (fence != NULL) {
                reply->write(*fence.get());
                reply->write(*fence);
            }
            reply->writeInt32(result);
            return NO_ERROR;
+6 −4
Original line number Diff line number Diff line
@@ -175,8 +175,7 @@ int Surface::setSwapInterval(int interval) {
    return NO_ERROR;
}

int Surface::dequeueBuffer(android_native_buffer_t** buffer,
        int* fenceFd) {
int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) {
    ATRACE_CALL();
    ALOGV("Surface::dequeueBuffer");
    Mutex::Autolock lock(mMutex);
@@ -193,6 +192,10 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer,
        return result;
    }
    sp<GraphicBuffer>& gbuf(mSlots[buf].buffer);

    // this should never happen
    ALOGE_IF(fence == NULL, "Surface::dequeueBuffer: received null Fence! buf=%d", buf);

    if (result & IGraphicBufferProducer::RELEASE_ALL_BUFFERS) {
        freeAllBuffers();
    }
@@ -200,8 +203,7 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer,
    if ((result & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) || gbuf == 0) {
        result = mGraphicBufferProducer->requestBuffer(buf, &gbuf);
        if (result != NO_ERROR) {
            ALOGE("dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: %d",
                    result);
            ALOGE("dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: %d", result);
            return result;
        }
    }
+1 −1

File changed.

Contains only whitespace changes.