CoreBluetooth: ~900ms delay between didConnect and completion of service discovery/notification subscription

Overview

We are developing a BLE + UWB accessory. We need to initiate UWB ranging as quickly as possible after establishing a BLE connection with an iPhone.

However, it consistently takes approximately 900–1000 ms from centralManager(_:didConnect:) until the notification subscription (setNotifyValue) reaches the accessory. Most of this delay does not appear to be caused by ATT throughput or accessory response times, but rather by internal iOS processing.

Details (Observed Behavior and Measurements)

We tested this by implementing code on the app side to delay calling discoverServices by 1 second, measuring the processing times for both scenarios (with vs. without delay).

Elapsed time for each phase measured on the app side (CBPeripheralDelegate):

discoverServicesdiscoverServicesPhaseCalling Delaying
didConnectdiscoverServices call0.1 ms(1000 ms delay)
discoverServicesdidDiscoverServices416 ms26 ms
didDiscoverServicesdidDiscoverCharacteristics90 ms60 ms

Key Observations:

  • The most notable finding is that simply delaying the discoverServices call by 1 second reduces the discoverServicesdidDiscoverServices duration from 416 ms to 26 ms. This suggests that iOS is performing some internal processing right after connection, during which ATT service discovery responses appear to be delayed/postponed.
  • Pure ATT discovery (Services + Characteristics) completes in about 86 ms when delayed.
  • The app calls setNotifyValue(true, for:) immediately without delay inside peripheral(_:didDiscoverCharacteristicsFor:error:). However, the accessory receives the CCCD write approximately 400 ms after discovery completes. (Note: This 400 ms is an estimate based on the difference with accessory-side measurements).
  • On the accessory side, completion of the ATT MTU exchange was observed around 380 ms after connection.

Hypothesis

We hypothesize that during the "first ~1 second after connection," iOS is sequentially executing link-layer control procedures (e.g., Feature Exchange, Version Exchange, Data Length Update, PHY Update) as well as ATT MTU exchange. Because these procedures are processed sequentially, ATT service discovery responses may be deprioritized or queued behind them.

We have isolated the issue on the accessory side: the peripheral responds immediately to all requests, confirming that accessory processing delays or ATT throughput limitations are not the cause.

Questions

  1. Is taking several hundred milliseconds to ~1 second from connection establishment (didConnect) to the completion of service discovery and notification subscription expected behavior in iOS?
  2. Is our understanding correct that iOS (CoreBluetooth / Bluetooth Controller) is executing link-layer control procedures during this initial period? If not, what specifically is taking place?
  3. Are there any means to shorten this duration from the app side or via peripheral connection parameters?
  4. Given the significant difference in response time between calling discoverServices immediately vs. delaying it, is there any way to prioritize ATT traffic right after connection or accelerate these procedures?
  5. For accessories that need to begin ranging immediately after connecting, what are the recommended best practices to minimize latency before data communication can start?
Answered by Engineer in 899349022

Your observations and hypothesis is correct. Upon connection the two devices negotiate link-layer parameters. One thing to be careful about is to make sure the peripheral is not requesting parameters that would be rejected by the iOS device, and then having additional rounds of back and forth until they agree on a setup.

This is where examining a packet log would be useful.

As for your questions:

  1. a lot will depend on the peripheral - the speed of responses, quality of connection (are there retries), and what exactly is going on within that 1 second.
  2. Yes, your understanding is correct
  3. There is nothing to be done on the app side. You should examine packet logs, and logs from the peripheral to understand where's the bottleneck. Accessory Design Guidelines for Apple Devices is a good guide to follow to set the connection parameters on the peripheral device correctly to begin with. The optimal set of parameters, while being in the recommended range, will depend on the abilities of the peripheral. Making the connection interval shorter won't help if the peripheral is not able to keep up with it, for example
  4. There is no way to prioritize ATT traffic over link layer, but I am sure the Bluetooth team would love to hear about this
  5. The accessory guide is a good start. But before anything, you must understand where the bottleneck is by examining packet logs.

Argun Tekant /  WWDR Engineering / Core Technologies

Accepted Answer

Your observations and hypothesis is correct. Upon connection the two devices negotiate link-layer parameters. One thing to be careful about is to make sure the peripheral is not requesting parameters that would be rejected by the iOS device, and then having additional rounds of back and forth until they agree on a setup.

This is where examining a packet log would be useful.

As for your questions:

  1. a lot will depend on the peripheral - the speed of responses, quality of connection (are there retries), and what exactly is going on within that 1 second.
  2. Yes, your understanding is correct
  3. There is nothing to be done on the app side. You should examine packet logs, and logs from the peripheral to understand where's the bottleneck. Accessory Design Guidelines for Apple Devices is a good guide to follow to set the connection parameters on the peripheral device correctly to begin with. The optimal set of parameters, while being in the recommended range, will depend on the abilities of the peripheral. Making the connection interval shorter won't help if the peripheral is not able to keep up with it, for example
  4. There is no way to prioritize ATT traffic over link layer, but I am sure the Bluetooth team would love to hear about this
  5. The accessory guide is a good start. But before anything, you must understand where the bottleneck is by examining packet logs.

Argun Tekant /  WWDR Engineering / Core Technologies

CoreBluetooth: ~900ms delay between didConnect and completion of service discovery/notification subscription
 
 
Q