EAAccessoryManager notifyObserversThatAccessoryDisconnectedWithUserInfo crashes iOS 11.1.2

App is crashing while a bluetooth device is disconnected. I've seen few related threads and they say


"A notification delegate was not reset to nil. A fix has been applied at version 10.3.79."

Following is crash log:


Triggered by Thread: 0 
Thread 0 name:
Thread 0 Crashed: 
0 libobjc.A.dylib 0x000000018544c430 objc_msgSend + 16 
1 ExternalAccessory 0x000000019c07c4dc -[EAAccessoryManager _notifyObserversThatAccessoryDisconnectedWithUserInfo:] + 104 (EAAccessoryManager.m:909) 
2 ExternalAccessory 0x000000019c07eddc -[EAAccessoryManager _externalAccessoryDisconnected:] + 928 (EAAccessoryManager.m:1537)
3 CoreAccessories 0x00000001a7892ccc __54-[ACCExternalAccessoryProvider ExternalAccessoryLeft:]_block_invoke + 316 (ACCExternalAccessoryProvider.m:453) 
4 libdispatch.dylib 0x0000000185b6d088 _dispatch_call_block_and_release + 24 (init.c:994) 
5 libdispatch.dylib 0x0000000185b6d048 _dispatch_client_callout + 16 (object.m:502) 
6 libdispatch.dylib 0x0000000185b79b74 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016 (inline_internal.h:2500) 
7 CoreFoundation 0x0000000186191eb0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1815) 
8 CoreFoundation 0x000000018618fa8c __CFRunLoopRun + 2012 (CFRunLoop.c:3111) 
9 CoreFoundation 0x00000001860affb8 CFRunLoopRunSpecific + 436 (CFRunLoop.c:3245) 
10 GraphicsServices 0x0000000187f47f84 GSEventRunModal + 100 (GSEvent.c:2245) 
11 UIKit 0x000000018f6842e8 UIApplicationMain + 208 (UIApplication.m:3949) 
12 MYAPP 0x0000000100ab8d58 main + 172 (main.m:16) 
13 libdyld.dylib 0x0000000185bd256c start + 4

Seeing on iOS 13.1.1 iPhone 8


Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x197b003bc objc_opt_respondsToSelector + 20
1  ExternalAccessory              0x1af2eb6fc -[EAAccessoryManager _notifyObserversThatAccessoryDisconnectedWithUserInfo:] + 92
2  ExternalAccessory              0x1af2edd34 -[EAAccessoryManager _externalAccessoryDisconnected:] + 888
3  CoreAccessories                0x1ae04a8c0 __54-[ACCExternalAccessoryProvider ExternalAccessoryLeft:]_block_invoke
4  libdispatch.dylib              0x197a89610 _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x197a8a184 _dispatch_client_callout + 16
6  libdispatch.dylib              0x197a6d35c _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 996
7  CoreFoundation                 0x197d3a3c4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8  CoreFoundation                 0x197d353b8 __CFRunLoopRun + 2004
9  CoreFoundation                 0x197d348bc CFRunLoopRunSpecific + 464
10 GraphicsServices               0x1a1ba0328 GSEventRunModal + 104
11 UIKitCore                      0x19bdca6d4 UIApplicationMain + 1936
12 UtiliGuard                     0x104b5f8d0 main + 17 (main.m:17)
13 libdyld.dylib                  0x197bbf460  + 4


It looks like this is internal iOS code that get called before I receive callback on accesoryDidDisconnect.


- (void)accessoryDidDisconnect:(EAAccessory *)accessory {


Is there anything that I can do in my code to prevent app crashing?

Did you find any solution? I've seen the same error on iPhone SE 2nd generation.

MAIN THREAD - CRASHED
libobjc.A.dylib
objc_opt_respondsToSelector
ExternalAccessory -   [EAAccessoryManager _notifyObserversThatAccessoryDisconnectedWithUserInfo:]
ExternalAccessory -   [EAAccessoryManager _externalAccessoryDisconnected:]
CoreAccessories -     [ACCExternalAccessoryProvider ExternalAccessoryLeft:]
libdispatch.dylib.    _dispatch_call_block_and_release
libdispatch.dylib.    _dispatch_client_callout

Is anyone there, who found the Fix to this issue? I am getting the same crash report on Crashlytics when my Bluetooth device is disconnected.

Do you have any Apple crash reports for that? If so, please post one here. See Posting a Crash Report for advice on how to do that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi eskimo, thanks for looking at this. I've also been having this crash for a year now. I've tested multiple things but as soon as I use registerForLocalNotifications, even if I don't subscribe to EAAccessoryDidConnect when my bluetooth accessory get disconnected when the app is running i'm getting this crash 80% of the time.

I've attached a crash report, i've just redacted the bundle and app name.

Thanks for that.

Combining that with some internal tooling I was able to get a slightly better backtrace:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0  libobjc.A.dylib   … isa_t::getClass(bool) const + 36
1  libobjc.A.dylib   … isa_t::getDecodedClass(bool) const + 36
2  libobjc.A.dylib   … objc_object::ISA(bool) const + 36
3  libobjc.A.dylib   … objc_object::getIsa() const + 40
4  libobjc.A.dylib   … objc_opt_respondsToSelector + 48
5  ExternalAccessory … __76-[EAAccessoryManager _notifyObserversThatAccessoryDisconnectedWithUserInfo:]_block_invoke + 48
6  libdispatch.dylib … _dispatch_call_block_and_release + 32

Frames 3 through 0 all get inlined into frame 4, and this backtrace undoes that.

However, this doesn’t tell us much. I was hoping that this crash report would lead to a bug report tracking this issue, but no dice.

The next time you see this, please trigger a sysdiagnose log immediately afterwards and then file a bug report with that log. For info on how to do that, see our Bug Reporting > Profiles and Logs page.

Please post your bug number, just for the record.

Finally, I’d like to clarify my understanding of this:

when my bluetooth accessory get disconnected when the app is running i'm getting this crash 80% of the time.

It sounds like this:

  1. Your app is happily talking to your accessory using External Accessory framework.

  2. You then disconnect the accessory (turn it off, walk out of range, whatever).

  3. 80% of the time your app crashes in this way.

Is that right?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I don't know why i didn't initially thought of sending a bug report .. Here's the bug number FB12831700

To clarify, that is exactly right. However i should specify that the apps while connected to the accessory is not listening for local notifications the whole time. For a specific flow we start the local notification registration, and then stop it when its done.

During a normal use of the app (thus not in the specific flow) we are not seeing this crash.

EAAccessoryManager notifyObserversThatAccessoryDisconnectedWithUserInfo crashes iOS 11.1.2
 
 
Q