macOS Bluetooth PLIST gets crowded with multiple copies of same device

My team is building an app for macOS that scans, connects to, and communicates with our CoreBluetooth app on iOS and Android devices. Recently it has come to our attention that the macOS cache of "known BLE devices" seems to balloon out of control with multiple CBPeripheral entries of what are the same, solitary Android device. When scanning for devices, our logs show repeated discovery of peripherals, with different UUIDs, which are (100% confidence) the exact same devices. We believe that this is due to the Android device intentionally randomly generating at intervals a new BLE MAC address, which would appear to CoreBluetooth as a new-found device.

The main macOS Bluetooth device cache is in:
Code Block
/Library/Preferences/com.apple.Bluetooth.plist

We experience some challenge when it comes to reconnecting to available devices - the CBCentralManagerDelegate method
Code Block
centralManager:didDiscoverPeripheral:advertisementData:rssi:

is getting called for a multitude (20+) copies of what is the same single device (the device is in range).

Eventually, the PLIST file has cached thousands (nearing 5K in my 2-yr old MBPro) of such devices, and at some point connecting is impossible, requiring the removal of the PLIST and the restarting of the Bluetooth daemon.

Is anyone else seeing behavior like this? Is there something our macOS app could do better to avoid this?


macOS Bluetooth PLIST gets crowded with multiple copies of same device
 
 
Q