Ableton / LinkKit

iOS SDK for Ableton Link, a new technology that synchronizes musical beat, tempo, and phase across multiple applications running on one or more devices.
http://ableton.github.io/linkkit
Other
147 stars 10 forks source link

[ABLLinkNotificationView init] causes unrecognized selector #27

Closed BlipGit closed 7 years ago

BlipGit commented 7 years ago

I'm integrating LinkKit into my iOS app, but I find that as soon as LinkKit wants to show a notification (eg. when a peer connects or disconnects) the app crashes with the following output:

-[AppController window]: unrecognized selector sent to instance 0x17d35c60
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppController window]: unrecognized selector sent to instance 0x17d35c60'

Here's the callstack (I've edited for brevity):

Main Thread (1)Queue : com.apple.main-thread (serial)
...
#9  0x1bf64514 in -[NSObject(NSObject) doesNotRecognizeSelector:] ()
#10 0x1bf6242a in ___forwarding___ ()
#11 0x1be87f08 in _CF_forwarding_prep_0 ()
#12 0x00c6f000 in -[ABLLinkNotificationView init] ()
#13 0x00c6edba in ABLLinkNotificationsShowMessage ()
#14 0x00c47c64 in std::__1::__function::__func<ABLLinkNew::$_6, std::__1::allocator<ABLLinkNew::$_6>, void (unsigned long)>::operator()(unsigned long&&) ()
#15 0x00c479d4 in ___ZZN7ABLLinkC1EdENK3$_4clEm_block_invoke ()
...
#22 0x1be67e80 in CFRunLoopRunInMode ()
#23 0x1d614bfc in GSEventRunModal ()
#24 0x2102282e in -[UIApplication _run] ()
#25 0x2101cf60 in UIApplicationMain ()
...

AppController is the main UIApplication class, specified in main:

UIApplicationMain(argc, argv, nil, @"AppController");

... and declared like this:

@interface AppController : UIResponder <UIApplicationDelegate>
{
    UIWindow*           mpMainWindow;
    OpenGLView*         mpOpenGLView;
...
}

Any ideas about the selector -[ABLLinkNotificationView init] may be attempting to call?

fgo-ableton commented 7 years ago

Thanks for letting us know. We are calling [[UIApplication sharedApplication].delegate.window addSubview:... when showing notifications. Maybe there is something we can improve in a future release. For now, could you check if adding a window property to your controller fixes the issue?

BlipGit commented 7 years ago

Thanks. Adding a window property (to expose my existing mpMainWindow variable) has fixed the problem.

With regards to future improvements, maybe it would be helpful for LinkKit to check if the property/selector exists at start up (using respondsToSelector:) and report in the output window if it doesn't.

I'm mainly a C++ developer (the app's 95% C++) so I've tended to use my C++ naming conventions on the few Obj-C classes I use to help me understand it. Maybe this was a stupid idea and it's just a natural assumption in the Obj-C world that UIApplication will always have a window property ...