Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

EXC_BAD_ACCESS on didCaptureVideoSampleBuffer delegate method #254

Closed
jinhk86 opened this issue May 23, 2015 · 8 comments
Closed

EXC_BAD_ACCESS on didCaptureVideoSampleBuffer delegate method #254

jinhk86 opened this issue May 23, 2015 · 8 comments
Labels

Comments

@jinhk86
Copy link

jinhk86 commented May 23, 2015

When I implement the delegate method vision: didCaptureVideoSampleBuffer: to get progress, I'm getting crash in PBJVision.m file where calls this delegate method.

if ([_delegate respondsToSelector:@selector(vision:didCaptureVideoSampleBuffer:)]) {
    [_delegate vision:self didCaptureVideoSampleBuffer:bufferToWrite];
}

If I temporarily change bufferToWrite to nil, I'm not getting crash. What's your thought?

@jsdir
Copy link

jsdir commented Jun 18, 2015

I'm also getting this error. Have you found a solution?

@jinhk86
Copy link
Author

jinhk86 commented Jun 18, 2015

I temporarily changed the bufferToWrite variable to nil since I'm not using sampleBuffer variable in the delegate method.

@olivierlesnicki
Copy link

Same issue here - note I'm using the library in a Swift project

@olivierlesnicki
Copy link

An other way is to remove the delegate response by deleting these lines from your ViewController:

  // progress
  func vision(vision: PBJVision, didCaptureVideoSampleBuffer sampleBuffer: CMSampleBuffer) {
  }
  func vision(vision: PBJVision, didCaptureAudioSample sampleBuffer: CMSampleBuffer) {
  }

or

- (void)vision:(PBJVision *)vision didCaptureVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer
{
  //    NSLog(@"captured audio (%f) seconds", vision.capturedAudioSeconds);
}
- (void)vision:(PBJVision *)vision didCaptureAudioSample:(CMSampleBufferRef)sampleBuffer
{
  //    NSLog(@"captured video (%f) seconds", vision.capturedVideoSeconds);
}

@vixentael
Copy link

still have this bug using PBJVision in Swift.
any ideas how to fix it, in case I really need video progress? =)

@crazyjooe
Copy link

Having the same problem in Swift. Not really sure how to fix this if you need CMSampleBufferRef in your delegate, but in other cases this can be solved either by passing nil to sampleBuffer variable or by creating new delegate method that is not sending sampleBuffer variable at all.
In all cases PBJVision source code has to be modified, unfortunately, until this is fixed.

@eserikov7
Copy link

eserikov7 commented Apr 10, 2017

Problem in the metod captureOutput: didOutputSampleBuffer: fromConnection:

        [self _enqueueBlockOnMainQueue:^{
            if ([_delegate respondsToSelector:@selector(vision:didCaptureVideoSampleBuffer:)]) {
                [_delegate vision:self didCaptureVideoSampleBuffer:bufferToWrite];
            }
        }];

_enqueueBlockOnMainQueue - is asynchronous and bufferToWrite release before didCaptureVideoSampleBuffer func of delegate.
For resolve you can comment async func. Like this.

        //[self _enqueueBlockOnMainQueue:^{
            if ([_delegate respondsToSelector:@selector(vision:didCaptureVideoSampleBuffer:)]) {
                [_delegate vision:self didCaptureVideoSampleBuffer:bufferToWrite];
            }
        //}];

or
CFRetain(sampleBuffer);
[self _enqueueBlockOnMainQueue:^{
if ([_delegate respondsToSelector:@selector(vision:didCaptureVideoSampleBuffer:)]) {
[_delegate vision:self didCaptureVideoSampleBuffer:bufferToWrite];
CFRelease(bufferToWrite);
}
}];

@piemonte
Copy link
Owner

@vixentael @crazyjooe if you're using swift, check out github.com/nextlevel/NextLevel

@eserikov7 thanks for the comments, 0.5.1 has this change, should be resolved by updating your pod, are you seeing otherwise?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants