AndEngine RenderTexture Exception: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
Asked Answered
J

1

8

I have developed an Android game which is played by many people. One user out of 100-200 faces an Exception that I cannot make any sense of.

I use a RenderTexture which throws the following Exception when I try to initialize it:

Fatal Exception: org.andengine.opengl.exception.RenderTextureInitializationException
org.andengine.opengl.exception.GLFrameBufferException: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT

It works on 99% of all devices. The init-method looks like this:

public void init(final GLState pGLState) throws GLFrameBufferException, GLException {
    this.savePreviousFramebufferObjectID(pGLState);

    try {
        this.loadToHardware(pGLState);
    } catch (final IOException e) {
        /* Can not happen. */
    }

    /* The texture to render to must not be bound. */
    pGLState.bindTexture(0);

    /* Generate FBO. */
    this.mFramebufferObjectID = pGLState.generateFramebuffer();
    pGLState.bindFramebuffer(this.mFramebufferObjectID);

    /* Attach texture to FBO. */
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, this.mHardwareTextureID, 0);

    try {
        pGLState.checkFramebufferStatus();
    } catch (final GLException e) {
        this.destroy(pGLState);

        throw new RenderTextureInitializationException(e);
    } finally {
        this.restorePreviousFramebufferObjectID(pGLState);
    }

    this.mInitialized = true;
}

It seems like something is wrong with the FrameBuffer-Status...

Update

A list of phones where the crash happened so far:

Sony - Sony Tablet S
TCT - ALCATEL ONE TOUCH 5020A
TCT - ALCATEL ONE TOUCH 6030N
VNPT Technology - VNPT Technology Smart Box
Q-Smart - S32
LGE - LG-E465g
LGE - LG-D682TR
LGE - LG-E451g
LGE - LG-D686
LGE - LG-E470f
HUAWEI - MediaPad 7 Youth
unknown - Bliss Pad B9712KB
samsung - GT-P5110
samsung - GT-I9505
samsung - Galaxy Nexus
samsung - GT-P3110
samsung - GT-P5100
samsung - GT-P3100
samsung - GT-I9105P
samsung - GT-I9082
samsung - GT-I9082L
samsung - GT-I9152
samsung - GT-P3113
E1A - E1A
LNV - LN1107
motorola - XT920
motorola - XT915
asus - ME172V
Jempty answered 26/9, 2016 at 12:18 Comment(0)
A
0

Based on the code you linked to, it looks like you are trying to render to an RGBA8888 texture. This isn't always available on OpenGL ES 2.0 devices, as it dates back to a time when most devices were using 16-bit displays.

The only mandatory formats in OpenGL ES 2.x are documented in the specification under the error code you are getting ...

RGBA8 targets are only available if this extension is exposed:

... so it's highly like that some users are using an older device with a GPU which isn't exposing this extension. To check if the extension is supported use glGetString (see below) with GL_EXTENSIONS:

... and see if the OES_rgb_rgba8 value is present in this list. If it isn't then your only real option is to fall back to something else in the mandatory ES2.x format set such as RGB565 or RGB5_A1.

Anteater answered 26/9, 2016 at 12:42 Comment(16)
Thank you for your answer - I appreciate it very much! Yes, I am trying to render to an RGBA8888 texture. I render Sprites/Textures on it (TextureOptions.BILINEAR_PREMULTIPLYALPHA) - they act as "stamps". What could I change - do you know an alternative? Thank you and have a good day!Jempty
Only render to RGBA8 if the extension is available, and fall back to RGB565 or RGB5_A1 when it isn't. The lack of a decent alpha channel might hurt you a bit though, depending what your sprites are doing, but if the device doesn't support RGBA8 I don't think you'll have much of a choice.Anteater
Thank you! So summarized: The game is not really playable? How can I check if RGBA8000 is supported? Do you know if it is possible to exclude devices (for example via Manifest) that do not support it? Am I right to say that this is a device specific problem (so excluding the problematic devices from downloading the app would "solve" the problem)? Please excuse me for overflowing you with that many question :)! Thank you so much.Jempty
Answer updated on how to check extension availability. Device specific - yes, it should only affect devices with a GPU without the extension string. I'm kinda curious which devices are having problems - most GPUs have supported RGBA8 for a long time - so if you are willing to share please do ;).Anteater
Thank you for the update! Yeah sure - I am now creating a list of all devices. I post it asap - I am waiting for some reports.Jempty
In the particular case of Android you can rely on RGBA8888 being available as a render target format. The reason being that the entire system relies on this (the UI toolkit always renders to RGBA8888) since Android 3.0.Riband
@RomainGuy No it doesn't seem like that. I have published a new game 4 days ago (close to 30k players already): 1 in 100-200 players have the issue... I'll post a list of the devices asap.Jempty
@RomainGuy It's possible for the driver to allow RGBA8 via EGL, but not for FBOs (although I agree it's mightily odd for it to do so). Of course, all of this might just be a bug in a GLES driver ...Anteater
@RomainGuy hm I'm not sure anymore - do you guys know why another class (github.com/SemonCat/AndEngine/blob/master/AndEngine-GLES2/src/…) that also uses RGBA_8888 works but not the mentioned one (github.com/SemonCat/AndEngine/blob/master/AndEngine-GLES2/src/…)?Jempty
I have now added a list of devices on which the crash happened so far...Jempty
From the one's I've checked so far they look like a mixture of SGX Series 5 and Broadcom Videocore devices. For SGX you might have more luck asking on the IMG developer forums why this might not be working, although based on what I've dug up so far there are definitely devices out there which are SGX 531 which do support the OES_rgb8_rgba8 extension, so my original guess as to what is going wrong could be off the mark.Anteater
Any chance this is just a timing issue, and the texture you are trying to use has not been fully allocated yet (e.g. ID assigned, but no texture storage assigned)?Anteater
@Isogen74 That is indeed possible. Hard to tell... I instantiate a RenderTexture (github.com/SemonCat/AndEngine/blob/master/AndEngine-GLES2/src/…) and call renderTexture.load(). As soon as I have a valid GLState I call renderTexture.init(GLState) and there the exception is thrown... I'm really stuck with this. I'm willing to pay you something for solving this - really need a fix. Thank you.Jempty
Let us continue this discussion in chat.Anteater
Yes, I'm in the chat. As I mentioned before. I'm glad to compensate your effort when you "find" the cause...Jempty
I thought it'd be better to give you the bounty instead of nobody. However, I would still very much appreciate any hint and/or ideas on the issue. Thank you.Jempty

© 2022 - 2024 — McMap. All rights reserved.