Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GL Errors on BakedOpRenderer

Tags:

android

I have weird errors on an android emulator MacOsX. This android app is running well on a real device. I've been googling it a lot, but there are few thread discussions about it. I just developed fragment using a basic relative layout. When I run it, I get these errors

08-09 10:07:00.973 4271-4466/com.xxx.xxx E/OpenGLRenderer: GL error: 0x506

08-09 10:07:00.973 4271-4466/com.xxx.xxx A/OpenGLRenderer: GL errors! frameworks/base/libs/hwui/BakedOpRenderer.cpp:98

08-09 10:07:00.973 4271-4466/com.xxx.xxx A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 4466 (RenderThread)

[ 08-09 10:07:00.974 1261: 1261 W/] debuggerd: handling request: pid=4271 uid=10085 gid=10085 tid=4466

Is there anyway to debug it to show more error details or fix this error? This error causes the app to crash.

like image 543
Eldwin Eldwin Avatar asked Oct 29 '22 03:10

Eldwin Eldwin


1 Answers

This isn't quite an answer (yet), but I'm posting in the hope that it'll help get to one.

So, I just hit this on my Pixel XL in chrome, and looking into the source, we're hitting an "assert" in BakedOpRenderer.cpp:

void BakedOpRenderer::endLayer() {
    if (mRenderTarget.stencil) {
        // if stencil was used for clipping, detach it and return it to pool
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
        GL_CHECKPOINT(MODERATE);
        mCaches.renderBufferCache.put(mRenderTarget.stencil);
        mRenderTarget.stencil = nullptr;
    }
    mRenderTarget.lastStencilClip = nullptr;
    mRenderTarget.offscreenBuffer->updateMeshFromRegion();
    mRenderTarget.offscreenBuffer = nullptr; // It's in drawLayerOp's hands now.
    // Detach the texture from the FBO
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
    GL_CHECKPOINT(LOW);
    mRenderState.deleteFramebuffer(mRenderTarget.frameBufferId);
    mRenderTarget.frameBufferId = 0;

}

Where we're hitting the GL_CHECKPOINT(LOW) block.

The macro is defined in GLUtils.h as:

#if DEBUG_OPENGL
#define GL_CHECKPOINT(LEVEL) \
    do { if (DEBUG_OPENGL >= DEBUG_LEVEL_##LEVEL) {\
    LOG_ALWAYS_FATAL_IF(android::uirenderer::GLUtils::dumpGLErrors(),\
        "GL errors! %s:%d", __FILE__, __LINE__);\
} } while (0)
#else
#define GL_CHECKPOINT(LEVEL)
#endif

(DEBUG_OPENGL seems to default to DEBUG_LEVEL_LOW)

The function that actually does the work, dumpGLErrors, is defined in GLUtils.cpp, as:

bool GLUtils::dumpGLErrors() {
#if DEBUG_OPENGL >= DEBUG_LEVEL_HIGH
    // If DEBUG_LEVEL_HIGH is set then every GLES call is already wrapped
    // and asserts that there was no error. So this can just return success.
    return false;
#else
    bool errorObserved = false;
    GLenum status = GL_NO_ERROR;
    while ((status = glGetError()) != GL_NO_ERROR) {
        errorObserved = true;
        switch (status) {
        case GL_INVALID_ENUM:
            ALOGE("GL error:  GL_INVALID_ENUM");
            break;
        case GL_INVALID_VALUE:
            ALOGE("GL error:  GL_INVALID_VALUE");
            break;
        case GL_INVALID_OPERATION:
            ALOGE("GL error:  GL_INVALID_OPERATION");
            break;
        case GL_OUT_OF_MEMORY:
            ALOGE("GL error:  Out of memory!");
            break;
        default:
            ALOGE("GL error: 0x%x", status);
        }
    }
    return errorObserved;
#endif
}

Here, my problem gets weird. You have the GL error: 0x506 line in your log, but I don't.

Your error is an GL_INVALID_FRAMEBUFFER_OPERATION error, and it looks like you need to look into that.

However, if you wanted to get more info, you'd need to recompile the Android hwui lib with something like DEBUG_LEVEL_HIGH, and maybe a other options.

On my side, I have no clue, since the crash in chrome didn't leave the "GL error" in logcat. Grr.

like image 60
Alexander Riccio Avatar answered Nov 15 '22 07:11

Alexander Riccio