App Crash on GPUImageVideoCamera at glDrawArrays

445 Views Asked by At

As i integrated GPUImage for one of our Application. I found frequently crashes on one Point. My Source Code is described Here.

glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D, chrominanceTexture);
glUniform1i(yuvConversionChrominanceTextureUniform, 5);

glUniformMatrix3fv(yuvConversionMatrixUniform, 1, GL_FALSE, _preferredConversion);

glVertexAttribPointer(yuvConversionPositionAttribute, 2, GL_FLOAT, 0, 0, squareVertices);
glVertexAttribPointer(yuvConversionTextureCoordinateAttribute, 2, GL_FLOAT, 0, 0,                [GPUImageFilter textureCoordinatesForRotation:internalRotation]);
glDisableVertexAttribArray(GL_TRIANGLE_STRIP);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

While debugging we found that Crash is occurred at glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) this line.

Can any one help me about this crash.

//Declaration In Inrterface

GPUImageVideoCamera *videoCamera; GPUImageOutput *filter; @property (weak, nonatomic) IBOutlet GPUImageView *cameraView;

//Implementation //To Blend image on live video

filter = [[GPUImageNormalBlendFilter alloc] init];
[videoCamera addTarget:filter];
[filter addTarget:cameraView];

    GPUImagePicture *overlayImage = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:[arrayOfFrames objectAtIndex:index]] smoothlyScaleOutput:YES];
    [overlayImage processImage];
    [overlayImage addTarget:filter];

We are applying filter using given sequence. GPUImageVideoCamera —> GPUImageNormalBlendFilter —> GPUImageView

(void)convertYUVToRGBOutput;
{
@autoreleasepool {
@try {
[GPUImageContext setActiveShaderProgram:yuvConversionProgram];

    int rotatedImageBufferWidth = imageBufferWidth, rotatedImageBufferHeight = imageBufferHeight;

    if (GPUImageRotationSwapsWidthAndHeight(internalRotation))
    {
        rotatedImageBufferWidth = imageBufferHeight;
        rotatedImageBufferHeight = imageBufferWidth;
    }

    outputFramebuffer = [[GPUImageContext sharedFramebufferCache] fetchFramebufferForSize:CGSizeMake(rotatedImageBufferWidth, rotatedImageBufferHeight) textureOptions:self.outputTextureOptions onlyTexture:NO];
    [outputFramebuffer activateFramebuffer];

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    static const GLfloat squareVertices[] = {
        -1.0f, -1.0f,
        1.0f, -1.0f,
        -1.0f,  1.0f,
        1.0f,  1.0f,
    };

    glActiveTexture(GL_TEXTURE4);
    glBindTexture(GL_TEXTURE_2D, luminanceTexture);
    glUniform1i(yuvConversionLuminanceTextureUniform, 4);

    glActiveTexture(GL_TEXTURE5);
    glBindTexture(GL_TEXTURE_2D, chrominanceTexture);
    glUniform1i(yuvConversionChrominanceTextureUniform, 5);

    glUniformMatrix3fv(yuvConversionMatrixUniform, 1, GL_FALSE, _preferredConversion);

    glVertexAttribPointer(yuvConversionPositionAttribute, 2, GL_FLOAT, 0, 0, squareVertices);
    glVertexAttribPointer(yuvConversionTextureCoordinateAttribute, 2, GL_FLOAT, 0, 0, [GPUImageFilter textureCoordinatesForRotation:internalRotation]);
    glDisableVertexAttribArray(GL_TRIANGLE_STRIP);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);  <—-  Causes Crash Over here

}
@catch (NSException *exception) {
    NSLog(@"Exception:%@",exception.description);
}
0

There are 0 best solutions below