BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.25k stars 4.61k forks source link

OS X: problem with OpenGL Profiler, GPUImageRawDataInput and GPUImageView. #2289

Closed rishigraham closed 8 years ago

rishigraham commented 8 years ago

I had this problem trying to profile a more complex OS X application, but narrowed it down to a very simple test case. I have GPUImageView fed by GPUImageRawDataInput. If I attach OpenGL Profiler and turn tracing on while updating, processing gets stuck in [NSOpenGLContext flushBuffer] (specifically in __psynch_mutexwait). As I said, the test case is very simple, I just have a view controller with a button and custom view of class GPUImageView and the following code in the controller:

-(void)awakeFromNib{
    [super awakeFromNib];
    NSString *fname = [[NSBundle mainBundle] pathForResource:@"TestImage" ofType:@"dat"];
    NSError *err = nil;
    if(!fname){
        err = [NSError errorWithDomain:@"ViewController" code:0
                              userInfo:@{NSLocalizedFailureReasonErrorKey:@"No selected data file!"}];
    }else{
        _rawDataFromFile = [NSData dataWithContentsOfFile:fname
                                                  options:NSDataReadingMappedIfSafe | NSDataReadingUncached
                                                    error:&err];
    }
    if(err){
        [self presentError:err];
        return;
    }
    [self.imageView setFillMode:kGPUImageFillModePreserveAspectRatio];
    [self.imageView setBackgroundColorRed:0.0 green:0.0 blue:0.0 alpha:1.0];
    GLubyte* data = (GLubyte *)[self.rawDataFromFile bytes];
    _inputFilter = [[GPUImageRawDataInput alloc] initWithBytes:data
                                                          size:CGSizeMake(1024, 241)
                                                   pixelFormat:GPUPixelFormatLuminance
                                                          type:GPUPixelTypeUByte];
    [self.inputFilter addTarget:self.imageView];
}

- (IBAction)updateAction:(id)sender {
    if (_inputFilter) {
        [self.inputFilter useNextFrameForImageCapture];
        [self.inputFilter processData];
    }
}
rishigraham commented 8 years ago

Oops: I figured out the problem, and it's not a GPUImage issue. I had the GPUImageView set up as a sublayer of an NSView (in order to put the button in there) but had not turned off the default Core Animation Layer for the parent view. Sorry for the false issue!