更新
(2014-JUN-03)调试器建议在malloc_error_break
(malloc: *** error for object 0x11b102dc0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug)
只是,我不确定我在追踪中看到了什么;似乎没有可行的迹象表明问题是什么。
(2014-JUN-05)在该计划中启用僵尸和malloc现在正在生成以下消息:
2014-06-05 09:55:14.048 *** -[GPUImageFramebuffer activateFramebuffer]: message sent to deallocated instance 0x2e9ffaf90.
显然有一些糟糕的垃圾收集正在进行中?
在模拟器中运行时,我在GPUImage实现中收到崩溃日志。特别是:
崩溃#1
- (void)dealloc
{
[self destroyFramebuffer];
}
...在GPUImageFrameBuffer.m
Line 109
上我收到SIGABRT错误:
malloc: *** error for object 0x10ac7df60: pointer being freed was not allocated
崩溃#2
[self activateFramebuffer];
...在GPUImageFrameBuffer.m
Line 343
上我收到了EXC_BAD_ACCESS错误(但没有任何上下文)。
研究这些,它们似乎是过早解除分配的帧缓冲区引用(在处理完成之前)。有趣的是,它们似乎根本没有出现在我正在测试的设备上。
我需要知道这是否是预期的模拟器行为或是否异常,我应该花更多时间研究问题并调整我的实施?
为了它的价值,我抓住一个UIImage,将它转换为GPUImagePicture(我可能需要重新考虑?),然后返回UIImage。这是我的方法的精简副本:
- (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;
}
}
在CustomFilter类中:
- (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;
}
}
答案 0 :(得分:1)
看起来这已在GPUImage中修复但尚未发布。 0.1.5不包含此提交。以下是提交的链接:https://github.com/BradLarson/GPUImage/commit/423ff362727bf8a1eb71451b4c26b39bcc9187cb
以下是问题主题,已关闭:https://github.com/BradLarson/GPUImage/issues/1472
如果要在podfile中指定最新提交,请使用以下命令:
pod 'GPUImage', :git => 'https://github.com/BradLarson/GPUImage.git'