boinx / DeckLink

ObjC wrapper for the Blackmagic Design DeckLink SDK
MIT License
15 stars 11 forks source link

[DeckLinkDevice devices] crashes #1

Open benoitlahoz opened 8 years ago

benoitlahoz commented 8 years ago

Hi and thank you for your work!

I'm trying to get a list of connected devices with [DeckLinkDevice devices] but it crashes, due to a dispatch_once error. I get this crash log:

2016-05-01 22:46:45.392 StreamKnot[2939:76500] An uncaught exception was raised 2016-05-01 22:46:45.393 StreamKnot[2939:76500] * -[NSArrayM insertObject:atIndex:]: object cannot be nil 2016-05-01 22:46:45.393 StreamKnot[2939:76500] ( 0 CoreFoundation 0x00007fff8c72f4f2 exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff8830973c objc_exception_throw + 48 2 CoreFoundation 0x00007fff8c645ae0 checkForCloseTag + 0 3 DeckLink 0x0000000100145daf +[DeckLinkDevice(Devices) devicesWithIODirection:] + 559 4 DeckLink 0x0000000100145b75 +[DeckLinkDevice(Devices) devices] + 37**

and the error concerns the following lines in once.h (dispatch)

void
_dispatch_once(dispatch_once_t *predicate, dispatch_block_t block)
{
    if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
        dispatch_once(predicate, block);
    }
}

Do you have any clue on what's happening? Thanks!

Ben

achimb commented 8 years ago

Ben,

unfortunately this is to less information to say anything. “dispatch_once” is a very generic function which is called from many places. You stripped the track trace where this exception happened, but this is very important information. Can you provide the complete log?

best,

Achim

On May 1, 2016, at 10:49 PM, oz (Benoît LAHOZ) notifications@github.com wrote:

Hi and thank you for your work!

I'm trying to get a list of connected devices with [DeckLinkDevice devices] but it crashes, due to a dispatch_once error. I get this crash log:

2016-05-01 22:46:45.392 StreamKnot[2939:76500] An uncaught exception was raised 2016-05-01 22:46:45.393 StreamKnot[2939:76500] *\ -[NSArrayM insertObject:atIndex:]: object cannot be nil 2016-05-01 22:46:45.393 StreamKnot[2939:76500] ( 0 CoreFoundation 0x00007fff8c72f4f2 exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff8830973c objc_exception_throw + 48 2 CoreFoundation 0x00007fff8c645ae0 checkForCloseTag + 0 3 DeckLink 0x0000000100145daf +[DeckLinkDevice(Devices) devicesWithIODirection:] + 559 4 DeckLink 0x0000000100145b75 +[DeckLinkDevice(Devices) devices] + 37

and the error concerns the following lines in once.h (dispatch)

void _dispatch_once(dispatch_once_t _predicate, dispatch_block_t block) { if (DISPATCH_EXPECT(_predicate, ~0l) != ~0l) { dispatch_once(predicate, block); } } Do you have any clue on what's happening? Thanks!

Ben

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/boinx/DeckLink/issues/1

benoitlahoz commented 8 years ago

Thank you Achim,

The crash is happening in a singleton. The complete crash log isn't very informative (at least for me). For information, I use GStreamer. Could it be that the GstDeckLink plugin is loaded somewhere and already imports the DeckLinkAPI?

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: -[__NSArrayM insertObject:atIndex:]: object cannot be nil' * First throw call stack: ( 0 CoreFoundation 0x00007fff8edcb4f2 exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff8a9a573c objc_exception_throw + 48 2 CoreFoundation 0x00007fff8ece1ae0 checkForCloseTag + 0 3 DeckLink 0x0000000100145daf +[DeckLinkDevice(Devices) devicesWithIODirection:] + 559 4 DeckLink 0x0000000100145b75 +[DeckLinkDevice(Devices) devices] + 37 5 PiplStream 0x000000010009e1a4 -[PiplInputsManager init] + 164 6 PiplStream 0x000000010009e0c2 34+[PiplInputsManager sharedManager]_block_invoke + 50 7 libdispatch.dylib 0x00000001000cdcc5 _dispatch_client_callout + 8 8 libdispatch.dylib 0x00000001000cdcbb dispatch_once_f + 506 9 PiplStream 0x000000010009e068 +[PiplInputsManager sharedManager] + 136 10 PiplStream 0x000000010009e59b +[PiplInputsManager videoDevices] + 43 11 StreamKnot 0x00000001000118a8 -[SKMainToolbar setupAddMenu] + 264 12 StreamKnot 0x000000010001178f -[SKMainToolbar awakeFromNib] + 127 13 CoreFoundation 0x00007fff8ed41cef -[NSSet makeObjectsPerformSelector:] + 223 14 AppKit 0x00007fff8f743f2f -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1192 15 AppKit 0x00007fff8f8546ab -[NSNib _instantiateNibWithExternalNameTable:options:] + 677 16 AppKit 0x00007fff8f8542fb -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 143 17 AppKit 0x00007fff8f853590 -[NSViewController loadView] + 270 18 AppKit 0x00007fff8f7c0aaa -[NSViewController _loadViewIfRequired] + 75 19 AppKit 0x00007fff8f7c0a15 -[NSViewController view] + 30 20 AppKit 0x00007fff8fa194d7 -[NSPopover showRelativeToRect:ofView:preferredEdge:] + 193 21 StreamKnot 0x0000000100014db4 -[AppDelegate showPopover:] + 212 22 StreamKnot 0x0000000100014e94 -[AppDelegate togglePopover:] + 100 23 libsystem_trace.dylib 0x00007fff8d17d07a _os_activity_initiate + 75 24 AppKit 0x00007fff8f9e0e89 -[NSApplication sendAction:to:from:] + 460 25 AppKit 0x00007fff8f9f2fde -[NSControl sendAction:to:] + 86 26 AppKit 0x00007fff8fe4fc90 -[NSStatusBarButtonCell _sendActionFrom:] + 164 27 libsystem_trace.dylib 0x00007fff8d17d07a _os_activity_initiate + 75 28 AppKit 0x00007fff8f9f148a -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2693 29 AppKit 0x00007fff8fa39fd0 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 744 30 AppKit 0x00007fff8fe4f473 -[NSStatusBarButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 327 31 AppKit 0x00007fff8f9efbb4 -[NSControl mouseDown:] + 669 32 AppKit 0x00007fff8ff44469 -[NSWindow _handleMouseDownEvent:isDelayedEvent:] + 6322 33 AppKit 0x00007fff8ff4544d -[NSWindow _reallySendEvent:isDelayedEvent:] + 212 34 AppKit 0x00007fff8f98463d -[NSWindow sendEvent:] + 517 35 AppKit 0x00007fff8fe528e9 -[NSStatusBarWindow sendEvent:] + 281 36 AppKit 0x00007fff8f904b3c -[NSApplication sendEvent:] + 2540 37 AppKit 0x00007fff8f76bef6 -[NSApplication run] + 796 38 AppKit 0x00007fff8f73546c NSApplicationMain + 1176 39 StreamKnot 0x0000000100006612 main + 34 40 libdyld.dylib 0x00007fff9474f5ad start + 1 )**

The [DecklinkDevice devices] method is called in the init method of my singleton, where I would like to get all connected devices (AVFoundation and Blackmagic) :

+ (id) sharedManager

{

    static PiplInputsManager *shared = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{

        shared = [[self alloc] init];

    });

    return shared;

}

- (instancetype) init

{

    self = [super init];

    if (self)
    {

        NSLog(@"%@", [DeckLinkDevice devices]); // HERE

        NSArray *devices = [AVCaptureDevice devices];
        NSMutableArray *videoDevices = [[NSMutableArray alloc] init];
        NSMutableArray *audioDevices = [[NSMutableArray alloc] init];

        for (AVCaptureDevice *device in devices)
        {
            if ([device hasMediaType:AVMediaTypeVideo])
            {

                [videoDevices addObject:device];

            } else if ([device hasMediaType:AVMediaTypeAudio])
            {

                [audioDevices addObject:device];

            }

        }

        _videoDevices = [videoDevices copy];
        _audioDevices = [audioDevices copy];

    }

    return self;

}

Maybe I misuse the method you provided and I have to initialize an instance of something before the call ?

Best,

Ben

achimb commented 8 years ago

I pushed a fix fort it. However you should be seeing a console log for a certain decklink device which caused this crash, can you sent this to me?

best,

Achim

On 02 May 2016, at 09:29, oz (Benoît LAHOZ) notifications@github.com wrote:

Thank you Achim,

The crash is happening in a singleton. There's not much information, the complete crash log isn't very informative (at least for me).

*\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSArrayM insertObject:atIndex:]: object cannot be nil' *\ First throw call stack: ( 0 CoreFoundation 0x00007fff8edcb4f2 exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff8a9a573c objc_exception_throw + 48 2 CoreFoundation 0x00007fff8ece1ae0 checkForCloseTag + 0 3 DeckLink 0x0000000100145daf +[DeckLinkDevice(Devices) devicesWithIODirection:] + 559 4 DeckLink 0x0000000100145b75 +[DeckLinkDevice(Devices) devices] + 37 5 PiplStream 0x000000010009e1a4 -[PiplInputsManager init] + 164 6 PiplStream 0x000000010009e0c2 __34+[PiplInputsManager sharedManager]_block_invoke + 50 7 libdispatch.dylib 0x00000001000cdcc5 _dispatch_client_callout + 8 8 libdispatch.dylib 0x00000001000cdcbb dispatch_once_f + 506 9 PiplStream 0x000000010009e068 +[PiplInputsManager sharedManager] + 136 10 PiplStream 0x000000010009e59b +[PiplInputsManager videoDevices] + 43 11 StreamKnot 0x00000001000118a8 -[SKMainToolbar setupAddMenu] + 264 12 StreamKnot 0x000000010001178f -[SKMainToolbar awakeFromNib] + 127 13 CoreFoundation 0x00007fff8ed41cef -[NSSet makeObjectsPerformSelector:] + 223 14 AppKit 0x00007fff8f743f2f -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1192 15 AppKit 0x00007fff8f8546ab -[NSNib _instantiateNibWithExternalNameTable:options:] + 677 16 AppKit 0x00007fff8f8542fb -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 143 17 AppKit 0x00007fff8f853590 -[NSViewController loadView] + 270 18 AppKit 0x00007fff8f7c0aaa -[NSViewController _loadViewIfRequired] + 75 19 AppKit 0x00007fff8f7c0a15 -[NSViewController view] + 30 20 AppKit 0x00007fff8fa194d7 -[NSPopover showRelativeToRect:ofView:preferredEdge:] + 193 21 StreamKnot 0x0000000100014db4 -[AppDelegate showPopover:] + 212 22 StreamKnot 0x0000000100014e94 -[AppDelegate togglePopover:] + 100 23 libsystem_trace.dylib 0x00007fff8d17d07a _os_activity_initiate + 75 24 AppKit 0x00007fff8f9e0e89 -[NSApplication sendAction:to:from:] + 460 25 AppKit 0x00007fff8f9f2fde -[NSControl sendAction:to:] + 86 26 AppKit 0x00007fff8fe4fc90 -[NSStatusBarButtonCell _sendActionFrom:] + 164 27 libsystem_trace.dylib 0x00007fff8d17d07a _os_activity_initiate + 75 28 AppKit 0x00007fff8f9f148a -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2693 29 AppKit 0x00007fff8fa39fd0 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 744 30 AppKit 0x00007fff8fe4f473 -[NSStatusBarButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 327 31 AppKit 0x00007fff8f9efbb4 -[NSControl mouseDown:] + 669 32 AppKit 0x00007fff8ff44469 -[NSWindow _handleMouseDownEvent:isDelayedEvent:] + 6322 33 AppKit 0x00007fff8ff4544d -[NSWindow _reallySendEvent:isDelayedEvent:] + 212 34 AppKit 0x00007fff8f98463d -[NSWindow sendEvent:] + 517 35 AppKit 0x00007fff8fe528e9 -[NSStatusBarWindow sendEvent:] + 281 36 AppKit 0x00007fff8f904b3c -[NSApplication sendEvent:] + 2540 37 AppKit 0x00007fff8f76bef6 -[NSApplication run] + 796 38 AppKit 0x00007fff8f73546c NSApplicationMain + 1176 39 StreamKnot 0x0000000100006612 main + 34 40 libdyld.dylib 0x00007fff9474f5ad start + 1 )**

The [DecklinkDevice devices] method is called in the init method of my singleton, where I would like to get all connected devices (AVFoundation and Blackmagic) :

  • (id) sharedManager

{

static PiplInputsManager *shared = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{

    shared = [[self alloc] init];

});

return shared;

}

  • (instancetype) init

{

self = [super init];

if (self)
{

    NSLog(@"%@", [DeckLinkDevice devices]); // HERE

    NSArray *devices = [AVCaptureDevice devices];
    NSMutableArray *videoDevices = [[NSMutableArray alloc] init];
    NSMutableArray *audioDevices = [[NSMutableArray alloc] init];

    for (AVCaptureDevice *device in devices)
    {
        if ([device hasMediaType:AVMediaTypeVideo])
        {

            [videoDevices addObject:device];

        } else if ([device hasMediaType:AVMediaTypeAudio])
        {

            [audioDevices addObject:device];

        }

    }

    _videoDevices = [videoDevices copy];
    _audioDevices = [audioDevices copy];

}

return self;

} Maybe I misuse the method you provided and I have to initialize an instance of something before the call ?

Best,

Ben

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/boinx/DeckLink/issues/1#issuecomment-216122997