2

Our app uses glreadpixels to capture screen on every frame. On iOS 5 devices, when you receive a text message (or any other notification, I assume), the app crashes on the glreadpixels call.

The crash only happens on iOS 5 with the new style of notifications (the ones that slide down from the top and disappears shortly after). On iOS 4, the old UIAlertView style notifications work fine.

Specifically, the call to glReadPixels() throws an EXEC_BAD_ACCESS error.

The specific call is

glReadPixels(0,0,tx,ty,GL_BGRA_EXT,GL_UNSIGNED_BYTE, buffer);

Where

int tx = 482
int ty = 320

(app is in landscape mode only)

and

GLubyte *buffer = malloc(sizeof(GLubyte)* 4 * tx * ty );

We also tried checking the status of the frame buffer before issuing the read command, glCheckFramebufferStatus(GL_FRAMEBUFFER) always return GL_FRAMEBUFFER_COMPLETE.

Is this a bug in how the new notification pop up is implemented? How can we work around it? If we can some how detect that the notification is about to appear, and pause the call to glreadpixels until it disappears, that would be acceptable as well.

Thanks,

Tim

Kevin
  • 53,822
  • 15
  • 101
  • 132
Tim Shi
  • 83
  • 6

1 Answers1

0

In some rare situations : sms notifications, sometime when the app move from background to foreground, glReadPixels() fail with a beautiful GL_FRAMEBUFFER_COMPLETE

The probleme disappears with a good old glBindFramebuffer before rendering. Theoretically, OpenGL should never 'forget' the bounded framebuffer. Strange.

I'm not sure if it's an bug from apple or from my code. But remember your app shares the opengl context with ios. Let's be pragmatic. I just add the magical glBindFramebuffer.

void render() {
    // !! bind Framebuffer, always, even if already bound. Apple bug ?
    glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);

    // rendering...

    //end rendering
    //     - glBindRenderbuffer(m_color_renderbuffer); // if required
    //     - glDiscardFramebufferEXT(...)

    // read pixels
    glPixelStorei(GL_PACK_ALIGNMENT, 4);
    glReadPixels(...)
}

        glBindRenderbuffer(GL_RENDERBUFFER, m_color_renderbuffer); 
Vivien
  • 768
  • 6
  • 9