Reputation: 72825
Updates
(2014-JUN-03) Debugger recommended setting a breakpoint on malloc_error_break
(malloc: *** error for object 0x11b102dc0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug)
Only, I'm not really sure what I'm looking at in the trace; there seems to be no viable indication of what the problem is.
(2014-JUN-05) Enabling zombies and malloc in the scheme is now producing messages like these:
2014-06-05 09:55:14.048 *** -[GPUImageFramebuffer activateFramebuffer]: message sent to deallocated instance 0x2e9ffaf90.
Clearly there's some bad garbage collection going on?
I'm getting a log of crashes in my GPUImage implementation when running in the simulator. In particular:
Crash #1
- (void)dealloc
{
[self destroyFramebuffer];
}
...in GPUImageFrameBuffer.m
on Line 109
I get a SIGABRT error:
malloc: *** error for object 0x10ac7df60: pointer being freed was not allocated
Crash #2
[self activateFramebuffer];
...in GPUImageFrameBuffer.m
on Line 343
I get a EXC_BAD_ACCESS error (but without any context).
Researching these, they appear to be frame buffer references that have been deallocated too soon (before the processing has completed). Interestingly, they don't seem to occur at all on the device I'm testing with.
I need to know whether this is expected simulator behavior or whether it's abnormal, and I should be spending more time researching the problems and adjust my implementation?
For what it's worth, I'm grabbing a UIImage, converting it to GPUImagePicture (which maybe I need to rethink?), and then returning back the UIImage. Here's a stripped down copy of my method:
- (UIImage*)processWithFilters
{
// Mutable array of filters, for dynamic iteration through only those filters which require applying
NSMutableArray* filterChain = [NSMutableArray new];
GPUImagePicture *source = [[GPUImagePicture alloc] initWithImage:self];
CustomFilter* customFilter;
customFilter = [[CustomFilter alloc] initWithLookupImageName:@"ImageNamedSomething.jpg"];
[filterChain addObject:customFilter];
GPUImageBrightnessFilter *brightnessFilter = [GPUImageBrightnessFilter new];
brightnessFilter.brightness = 0.5;
[filterChain addObject:brightnessFilter];
GPUImageContrastFilter *contrastFilter = [GPUImageContrastFilter new];
contrastFilter.contrast = 0.5;
[filterChain addObject:contrastFilter];
GPUImageSaturationFilter *saturationFilter = [GPUImageSaturationFilter new];
saturationFilter.saturation = 1.2;
[filterChain addObject:saturationFilter];
GPUImageHazeFilter *hazeFilter = [GPUImageHazeFilter new];
hazeFilter.distance = -0.2;
hazeFilter.slope = -0.2;
[filterChain addObject:hazeFilter];
GPUImageWhiteBalanceFilter *whiteBalanceFilter = [GPUImageWhiteBalanceFilter new];
whiteBalanceFilter.temperature = 6000;
[filterChain addObject:whiteBalanceFilter];
__block UIImage* returnImage;
if (filterChain.count > 0)
{
[filterChain enumerateObjectsUsingBlock:^(id filter, NSUInteger idx, BOOL *stop) {
if (idx == 0) {
[source addTarget:filter];
}
if (idx < filterChain.count - 1) {
GPUImageFilter *nextFilter = [filterChain objectAtIndex:idx + 1];
[filter addTarget:nextFilter];
}
[filter useNextFrameForImageCapture];
if (idx == filterChain.count - 1) {
[source processImage];
returnImage = [filter imageFromCurrentFramebuffer];
}
}];
kAppIsProcessingImage = NO;
return returnImage;
}
else
{
kAppIsProcessingImage = NO;
return self;
}
}
In the CustomFilter class:
- (id)initWithLookupImageName:(NSString*)imageName
{
if (!(self = [super init]))
{
return nil;
}
_imageName = imageName;
NSString* cachesDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
NSString *imagesPath = [cachesDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"lookupimages/%@",_imageName]];
@try {
UIImage* image = [UIImage imageWithContentsOfFile:imagesPath];
lookupImageSource = [[GPUImagePicture alloc] initWithImage:image];
GPUImageLookupFilter *lookupFilter = [[GPUImageLookupFilter alloc] init];
[self addFilter:lookupFilter];
[lookupImageSource addTarget:lookupFilter atTextureLocation:1];
[lookupImageSource processImage];
self.initialFilters = [NSArray arrayWithObjects:lookupFilter, nil];
self.terminalFilter = lookupFilter;
return self;
}
@catch (NSException *exception) {
// fatal error happened here uh oh!
return self;
}
}
Upvotes: 2
Views: 528
Reputation: 711
It looks like this is fixed in GPUImage but not released yet. 0.1.5 does not contain this commit. Here is a link to the commit: https://github.com/BradLarson/GPUImage/commit/423ff362727bf8a1eb71451b4c26b39bcc9187cb
And Here is the issue thread , which is closed: https://github.com/BradLarson/GPUImage/issues/1472
If you want to specify the latest commit in a podfile, use the following:
pod 'GPUImage', :git => 'https://github.com/BradLarson/GPUImage.git'
Upvotes: 1