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

Commit cf1170fb authored by John Reck's avatar John Reck
Browse files

Always submit after texture uploads

Ensure GrContext::submit() is always called after either
Bitmap#prepareToDraw() or if DrawFrameTask skipped drawing.

In either case texture uploads & deletions will be scheduled,
but without the submit they won't actually be performed. This
can end up running out of RAM.

Bug: 189393671
Test: manual test app
Change-Id: I57477c64457558487e9e5ec0a979ad9099a8cb2c
parent ab7b0e89
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -207,12 +207,16 @@ bool SkiaPipeline::createOrUpdateLayer(RenderNode* node, const DamageAccumulator


void SkiaPipeline::prepareToDraw(const RenderThread& thread, Bitmap* bitmap) {
void SkiaPipeline::prepareToDraw(const RenderThread& thread, Bitmap* bitmap) {
    GrDirectContext* context = thread.getGrContext();
    GrDirectContext* context = thread.getGrContext();
    if (context) {
    if (context && !bitmap->isHardware()) {
        ATRACE_FORMAT("Bitmap#prepareToDraw %dx%d", bitmap->width(), bitmap->height());
        ATRACE_FORMAT("Bitmap#prepareToDraw %dx%d", bitmap->width(), bitmap->height());
        auto image = bitmap->makeImage();
        auto image = bitmap->makeImage();
        if (image.get() && !bitmap->isHardware()) {
        if (image.get()) {
            SkImage_pinAsTexture(image.get(), context);
            SkImage_pinAsTexture(image.get(), context);
            SkImage_unpinAsTexture(image.get(), context);
            SkImage_unpinAsTexture(image.get(), context);
            // A submit is necessary as there may not be a frame coming soon, so without a call
            // to submit these texture uploads can just sit in the queue building up until
            // we run out of RAM
            context->flushAndSubmit();
        }
        }
    }
    }
}
}
+6 −0
Original line number Original line Diff line number Diff line
@@ -130,6 +130,12 @@ void DrawFrameTask::run() {
    if (CC_LIKELY(canDrawThisFrame)) {
    if (CC_LIKELY(canDrawThisFrame)) {
        dequeueBufferDuration = context->draw();
        dequeueBufferDuration = context->draw();
    } else {
    } else {
        // Do a flush in case syncFrameState performed any texture uploads. Since we skipped
        // the draw() call, those uploads (or deletes) will end up sitting in the queue.
        // Do them now
        if (GrDirectContext* grContext = mRenderThread->getGrContext()) {
            grContext->flushAndSubmit();
        }
        // wait on fences so tasks don't overlap next frame
        // wait on fences so tasks don't overlap next frame
        context->waitOnFences();
        context->waitOnFences();
    }
    }