iPhone 5s not connecting to nearby device

Originator:blackcode.fr
Number:rdar://45520028 Date Originated:24/10/2018
Status:Opened Resolved:
Product:iOS + SDK Product Version:
Classification:CoreBluetooth Reproducible:YES
 
Summary:

iPhone 5s iOS 11.4 and 12.0.1 sometimes doesn't connect to Bluetooth Smart peripheral. Obvious Chronic bluetoothd daemon instability.

Steps to Reproduce:

Scan a device and then try to connect to it. 

Expected Results:

The iPhone connects to the peripheral.

Actual Results:

Sometimes, the iPhone 5s will not connect to a bluetooth peripheral. It can be like this for a few minutes, where every connect attempt will result in an infinite wait while other iPhones with the same app can connect to the device. Moreover, while bluetoothd is not connecting, it can still see advertising from the peripheral.

We have been able to do bluetooth sniffing to see that when it happens, the iPhone 5s is not sending any connect request to the peripheral while the peripheral is advertising. I have also noticed that everytime this happens, the bluetoothd daemon does exactly the same thing which is:

Switching state to connecting, then cancelling, then cancelled, then idle and then on iOS 12.0.1 only back to connecting. On iOS 11.4 it did not even switch back to connecting and stayed idle. (see log file). When this happens, no error is sent to the app and nothing happens.

Reproduced with different iOS apps: our apps, and also nRFConnect and LightBlue.

We have been running the tests with apps without restarting them or resetting any memory state, doing you can have connection working correctly for 10-15 minutes and then not work for 5 minutes and then back to normal.

When bluetoothd seemed stuck, it seems that asking to connect from a different centralManager from another app unlocks the issue. Trying to cancel with disconnect and connect again with the same central does NOT work, it has to be another process/centralManager that asks for connect. Still, using another app is not necessary to fix the issue, just trying again a few moments or minutes later with the same app and the same instance of centralManager in the same memory context works.

We had an occurence on iOS 11.4 where we kept waiting and the connection happened 7 minutes after requesting the connection.

We also had an occurence on iOS 12.0.1 of the bluetoothd daemon being completely lost and unable to connect to any peripheral, maintaining state to connecting for each peripheral even though the apps where telling it to disconnect after a app timeout (that was with the LightBlue app). I had to go in the Settings app to reset Bluetooth to fix the issue.

Personally I have used my personal iPhone 5s daily for development with CoreBluetooth apps for 3 years since it came out in 2013 with iOS 8 up to iOS 10 and have never seem anything but stelar performance and reliability while using these APIs. I don't know what happened since iOS 11 but it is very concerning to see the performance and reliability of an Apple device weaken years after release without any apparent reason.

Version/Build:

iOS 11.4 and iOS 12.0.1

Configuration:

iPhone 5s used only rarely for coding, bugging and testing.

Comments

Log bluetoothd connection error

default 15:55:08.351724 +0200 bluetoothd Connect called to "3179BCF9-F77E-F951-9BAE-48FC3853763E"

default 15:55:08.351900 +0200 bluetoothd Current state when trying to connect Idle(0)

default 15:55:08.352113 +0200 bluetoothd Adding device to connecting list

default 15:55:08.352350 +0200 bluetoothd Adding device "3179BCF9-F77E-F951-9BAE-48FC3853763E" with address "" to connection whitelist, waiting for controlller to complete.

default 15:55:08.354041 +0200 bluetoothd Device "" Added to Whitelist with status:0

default 15:55:08.355097 +0200 bluetoothd Added device "3179BCF9-F77E-F951-9BAE-48FC3853763E" to connection whitelist

default 15:55:08.368408 +0200 bluetoothd Next connection parameters are: window - 0x30, interval - 0x30

default 15:55:08.368529 +0200 bluetoothd Starting auto connection for 1 devices

default 15:55:08.368867 +0200 bluetoothd Success, setting new connectionState

default 15:55:08.369472 +0200 bluetoothd Setting new connection state Idle(0) --> Connecting(1), current Connection Manager state Active(0)

default 15:55:14.289426 +0200 bluetoothd Reducing connection timing after 6 seconds

default 15:55:14.289584 +0200 bluetoothd Cancelling 1 pending connection

default 15:55:14.289690 +0200 bluetoothd Setting new connection state Connecting(1) --> Cancelling(2), current Connection Manager state Active(0)

default 15:55:14.294609 +0200 bluetoothd LE Connection Cancelled with status 0

default 15:55:14.294873 +0200 bluetoothd Pending connection(s) canceled successfully

default 15:55:14.295162 +0200 bluetoothd LE Connection complete for handle 0x0 address with status 702

default 15:55:14.295275 +0200 bluetoothd Setting new connection state Cancelling(2) --> Cancelled(3), current Connection Manager state Active(0)

default 15:55:14.295406 +0200 bluetoothd handleConnectionCompleteCallback address= handle=0x0 status=702 connectionIsActive=0

default 15:55:14.295513 +0200 bluetoothd Received connection complete event after successful cancellation. Parsing pending operations and processing pending connections

default 15:55:14.295613 +0200 bluetoothd Connection complete after successful connection cancelation

default 15:55:14.295788 +0200 bluetoothd Setting new connection state Cancelled(3) --> Idle(0), current Connection Manager state Active(0)

default 15:55:14.295926 +0200 bluetoothd Idle, checking Connection Manager state

default 15:55:14.296042 +0200 bluetoothd Connection Manager state is settled

default 15:55:14.296198 +0200 bluetoothd Next connection parameters are: window - 0x30, interval - 0x1e0

default 15:55:14.296324 +0200 bluetoothd Starting auto connection for 1 devices

default 15:55:14.296436 +0200 bluetoothd Success, setting new connectionState

default 15:55:14.296603 +0200 bluetoothd Setting new connection state Idle(0) --> Connecting(1), current Connection Manager state Active(0)

By blackcode.fr at Oct. 24, 2018, 3:05 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!