Bluetooth sometimes reported as OFF when it's actually turned on

To make this clear up front: This bug report is not about the new behavior of the control center. Even though the bug is probably related.


Environment:

iOS 11.0.3 & 11.1.2

iPhone 7 & iPhone X


Bug Report:

  • The state of the central manager is sometimes reported as CBManagerStatePoweredOff even though Bluetooth is shown as turned on in the control center and the settings
  • The wrong state is not restricted to one app but affects all apps that are using CoreBluetooth
  • We weren't able to connect to our device (when ignoring the reported off state)
  • This issue appeared multiple times in our office alone, so we assume it to be quite widespread
  • Toggling Bluetooth resolved the issue
  • Restarting apps had no effect
  • We had the feeling it is related to toggling the airplane mode — at least that's how we managed to reproduce it


Analysis:

I retrieved a sysdiagnose file after one occurrence. These are the steps I took:

  • I played around with turning Bluetooth and the airplane mode on and off
  • I wasn't able to reproduce the issue and locked the device
  • Sometime later I installed our app via Xcode and the issue manifested. That's when I triggered sysdiagnose


Here you see some depicted log entries that seemed relevant to me. Unfortunately, I haven't found the logs about changing the state of the Bluetooth toggle. But I can provide the full sysdiagnose archive upon request.


default    2017-11-28 17:04:39.882932 +0100    symptomsd-helper    AirplaneMode OFF,  Wi-Fi administratively ON, Cellular data switch administratively ON, RNF administratively ON

debug      2017-11-28 17:13:34.625110 +0100    OUR-APP    Sending XPC message 1: {
    kCBMsgArgName = "our.bundle.identifier";
    kCBMsgArgOptions =     {
        kCBInitOptionShowPowerAlert = 0;
    };
    kCBMsgArgType = 0;
    kCBMsgArgVersion = 20161219;
}

default    2017-11-28 17:13:34.626054 +0100    bluetoothd    Access level is less than kXPCAccessLevelSystem for session "our.bundle.identifier-central-4454-269". Restricted state operation not allowed

default    2017-11-28 17:13:34.626901 +0100    bluetoothd    Registering central session "our.bundle.identifier-central-4454-269" with backgrounding: on, persistence: off
default    2017-11-28 17:13:34.627434 +0100    bluetoothd    Session "our.bundle.identifier-central-4454-269" : needsRestrictedStateOperation = 0, overrideRestrictedState = 0 , blacklistMode = 1
default    2017-11-28 17:13:34.627438 +0100    bluetoothd    Sending 'state updated' event with state "Off" to session "our.bundle.identifier-central-4454-269"

default    2017-11-28 17:13:34.775454 +0100    bluetoothd    Received XPC message "CBMsgIdRetrievePeripheralsWithIdentifiers" from session "our.bundle.identifier-central-4454-269"
error      2017-11-28 17:13:34.775457 +0100    bluetoothd    Ignoring XPC message as state is "Off"

default    2017-11-28 17:13:52.513918 +0100    sysdiagnose    request: sysdiagnose (stackshot only) keychord: Power + Volume Up

Replies

>This bug report


Forum posts like yoursmake for interesting conversation, but they don't qualify as bug reports.


Feel free to use the bug reporter link, below right, adding your report # to your thread for reference, thanks and good luck.

I also encountered the same problem, do not know how to solve it, we have no good way?

When Bluetooth is toggled in Control Center it enables blacklistMode which can be seen in the provided log. This allows devices/apps with permission to remain connected (example: Apple Watch) while disconnecting others. When toggling it back on, their is a bug that does not fully disable blacklistMode. Apps will then be told Bluetooth is still off when it isn't.


The creation of a new session while in blacklistMode seems to be part of what causes the issue so the best way we have found to mitigate the effect of this issue is to not create a new central session on Bluetooth state change. Only create a new session when your app is opened or if it is closed and re-opened. It's still possible to encounter this but it will happen far less frequently as it requires a few extra steps to manifest. Otherwise once experiencing the issue, toggle Bluetooth in Control Center once or twice and you should recover the connection.

for many good reasons, I am still using iOS10 SDKm so I can't easily check. has been this solved in one of the next versions?

Hello , thank's for posting. it's very interesting and very important, because I think everyone how work with bluetooth had this problem. I had this problem too . Of course it's the Apple OS bug.

Hi,


Do we have any update on the solution for this known bug in iOS?