Open sitanshu-joshi opened 10 years ago
What, exactly, are you trying to do? Could you provide some description of your setup and the code you use to set up your filter pipeline?
I don't know of many causes for glDrawArrays() crashes, outside of you trying to draw when your application is in the background (which you can't do with OpenGL ES).
//Declaration In Inrterface
GPUImageVideoCamera videoCamera;
GPUImageOutput
//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);
}
} }
At least one problem in the above is that you're not holding on to overlayImage. You're declaring it as a local variable, but this needs to be an instance variable or it will be deallocated the instant you leave your setup method. This will cause a crash.
I have no idea why you'd try to use @try in any part of this code, since try-catch are generally not used in Objective-C and will cause memory leaks under ARC.
Thanks Brad for your suggestion, but if we create Property of overlayImage then it crashed app. And without Property of overlayImage it crash app randomly , not overtime(Mostly crash when applying frame first time after app login.)
I meet a similar problem, how did you solve it, can you share it? thank you
Hi,
As i integrated GPUImage i see crashes at glDrawArrays when we select any frame on first time. This is became very serious issue on our DevOps.
It would be great if any one can help me.