New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 637236 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Email to this user bounced
Closed: Aug 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 551634



Sign in to add a comment

bluetooth: GATT Notifications are not received after disconnect on Android

Project Member Reported by fbeaufort@chromium.org, Aug 12 2016

Issue description

Version: Chrome Dev (54.0.2826.2) on a Nexus 5X (Android 6.0.1)

[A] can be a heart rate monitor or an android device faking to be a heart rate monitor with https://github.com/WebBluetoothCG/ble-test-peripheral-android
[B] is a Nexus 5X

What steps will reproduce the problem?
(1) [A] Advertise Heart Rate Monitor device
(2) [B] Go to https://googlechrome.github.io/samples/web-bluetooth/notifications.html?service=heart_rate&characteristic=heart_rate_measurement
(3) [B] Click "Start Notifications" button
(4) [A] Click "Notify" button
(5) [B] Notice notifications is received 
(6) [B] Open Chrome Dev Tools and inspect web page
(7) [B] In Console, trigger disconnect/reconnect and start notifications again by entering these lines below:

// Disconnect device
myCharacteristic.service.device.gatt.disconnect()
// Wait & Reconnect after 5s
myCharacteristic.service.device.gatt.connect()
// Wait 1s
myCharacteristic.startNotifications()
.then(_ => { console.log('started'); })
.catch(e => { console.log(e); });

(8) [A] Click "Notify" button

What is the expected output?

[A] I should receive a notification.
 
What do you see instead?

[A] Nothing ;(


---

Here are my adb logs:

08-12 12:19:41.823 I/cr_Bluetooth(19369): ChromeBluetoothAdapter created with provided adapterWrapper.
08-12 12:19:41.865 D/BluetoothAdapter(19369): STATE_ON
08-12 12:19:41.868 D/BtGatt.GattService(19265): registerClient() - UUID=1afed0cf-3263-43fb-8397-2a1c367902b3
08-12 12:19:41.868 D/BtGatt.GattService(19265): onClientRegistered() - UUID=1afed0cf-3263-43fb-8397-2a1c367902b3, clientIf=5
08-12 12:19:41.869 D/BluetoothLeScanner(19369): onClientRegistered() - status=0 clientIf=5
08-12 12:19:41.869 D/BtGatt.GattService(19265): start scan with filters
08-12 12:19:41.871 D/BtGatt.ScanManager(19265): handling starting scan
08-12 12:19:41.873 D/BtGatt.ScanManager(19265): configureRegularScanParams() - queue=1
08-12 12:19:41.873 D/BtGatt.ScanManager(19265): configureRegularScanParams() - ScanSetting Scan mode=2 mLastConfiguredScanSetting=-2147483648
08-12 12:19:41.873 D/BtGatt.ScanManager(19265): configureRegularScanParams - scanInterval = 8000configureRegularScanParams - scanWindow = 8000
08-12 12:19:41.882 D/BtGatt.GattService(19265): onScanParamSetupCompleted : 0
08-12 12:19:44.895 D/BluetoothAdapter(19369): STATE_ON
08-12 12:19:44.895 D/BtGatt.GattService(19265): stopScan() - queue size =1
08-12 12:19:44.895 D/BtGatt.ScanManager(19265): stop scan
08-12 12:19:44.895 D/BtGatt.ScanManager(19265): configureRegularScanParams() - queue=0
08-12 12:19:44.895 D/BtGatt.ScanManager(19265): configureRegularScanParams() - ScanSetting Scan mode=-2147483648 mLastConfiguredScanSetting=2
08-12 12:19:44.895 D/BtGatt.ScanManager(19265): configureRegularScanParams() - queue emtpy, scan stopped
08-12 12:19:44.895 D/BtGatt.GattService(19265): unregisterClient() - clientIf=5

// First connection

08-12 12:19:44.901 I/cr_Bluetooth(19369): connectGatt
08-12 12:19:44.902 D/BluetoothGatt(19369): connect() - device: 65:C0:3D:08:3E:FE, auto: false
08-12 12:19:44.902 D/BluetoothGatt(19369): registerApp()
08-12 12:19:44.902 D/BluetoothGatt(19369): registerApp() - UUID=67604b0b-b91c-4152-9fe2-858cce823e4b
08-12 12:19:44.903 D/BtGatt.GattService(19265): registerClient() - UUID=67604b0b-b91c-4152-9fe2-858cce823e4b
08-12 12:19:44.903 D/BtGatt.GattService(19265): onClientRegistered() - UUID=67604b0b-b91c-4152-9fe2-858cce823e4b, clientIf=5
08-12 12:19:44.903 D/BluetoothGatt(19369): onClientRegistered() - status=0 clientIf=5
08-12 12:19:44.903 D/BtGatt.GattService(19265): clientConnect() - address=65:C0:3D:08:3E:FE, isDirect=true
08-12 12:19:44.903 D/bt_btif_config(19265): btif_get_address_type: Device [65:c0:3d:08:3e:fe] address type 1
08-12 12:19:44.903 D/bt_btif_config(19265): btif_get_device_type: Device [65:c0:3d:08:3e:fe] type 2
08-12 12:19:45.245 E/BluetoothRemoteDevices(19265): state12newState0
08-12 12:19:45.248 D/BtGatt.GattService(19265): onConnected() - clientIf=5, connId=5, address=65:C0:3D:08:3E:FE
08-12 12:19:45.248 D/BluetoothGatt(19369): onClientConnectionState() - status=0 clientIf=5 device=65:C0:3D:08:3E:FE
08-12 12:19:45.248 I/cr_Bluetooth(19369): onConnectionStateChange status:0 newState:Connected
08-12 12:19:45.249 D/BluetoothGatt(19369): discoverServices() - device: 65:C0:3D:08:3E:FE
08-12 12:19:45.249 D/BtGatt.GattService(19265): discoverServices() - address=65:C0:3D:08:3E:FE, connId=5
08-12 12:19:45.254 I/TrustAgent.Tracker( 1355): [BluetoothConnectionTracker] Bluetooth connect broadast for Nexus 5X 65:C0:3D:08:3E:FE
08-12 12:19:45.841 D/BtGatt.GattService(19265): onSearchCompleted() - connId=5, status=0
08-12 12:19:45.844 D/BluetoothGatt(19369): onSearchComplete() = Device=65:C0:3D:08:3E:FE Status=0
08-12 12:19:45.844 I/cr_Bluetooth(19369): onServicesDiscovered status:0==OK
08-12 12:19:45.850 D/BluetoothGatt(19369): setCharacteristicNotification() - uuid: 00002a37-0000-1000-8000-00805f9b34fb enable: true
08-12 12:19:45.850 D/BtGatt.GattService(19265): registerForNotification() - address=65:C0:3D:08:3E:FE enable: true
08-12 12:19:45.851 D/BtGatt.GattService(19265): onRegisterForNotifications() - address=null, status=0, registered=1, charUuid=00002a37-0000-1000-8000-00805f9b34fb
08-12 12:19:45.879 I/cr_Bluetooth(19369): onDescriptorWrite status:0==OK
08-12 12:19:49.759 I/cr_Bluetooth(19369): wrapper onCharacteristicChanged.
08-12 12:19:49.760 I/cr_Bluetooth(19369): device onCharacteristicChanged.
08-12 12:19:49.760 I/cr_Bluetooth(19369): onCharacteristicChanged

// Trigger disconnect

08-12 12:19:59.819 I/cr_Bluetooth(19369): BluetoothGatt.disconnect
08-12 12:19:59.820 D/BluetoothGatt(19369): cancelOpen() - device: 65:C0:3D:08:3E:FE
08-12 12:19:59.820 D/BtGatt.GattService(19265): clientDisconnect() - address=65:C0:3D:08:3E:FE, connId=5
08-12 12:19:59.822 D/BtGatt.GattService(19265): onDisconnected() - clientIf=5, connId=5, address=65:C0:3D:08:3E:FE
08-12 12:19:59.823 D/BluetoothGatt(19369): onClientConnectionState() - status=0 clientIf=5 device=65:C0:3D:08:3E:FE
08-12 12:19:59.823 I/cr_Bluetooth(19369): onConnectionStateChange status:0 newState:Disconnected
08-12 12:19:59.823 D/BluetoothGatt(19369): close()
08-12 12:19:59.823 D/BluetoothGatt(19369): unregisterApp() - mClientIf=5
08-12 12:19:59.823 D/BtGatt.GattService(19265): unregisterClient() - clientIf=5
08-12 12:19:59.852 E/BluetoothRemoteDevices(19265): state12newState1
08-12 12:19:59.854 D/BluetoothMapService(19265): onReceive
08-12 12:19:59.854 D/BluetoothMapService(19265): onReceive: android.bluetooth.device.action.ACL_DISCONNECTED
08-12 12:19:59.857 I/TrustAgent.Tracker( 1355): [BluetoothConnectionTracker] Bluetooth disconnect broadast for Nexus 5X 65:C0:3D:08:3E:FE

// Trigger reconnect

08-12 12:20:09.843 I/cr_Bluetooth(19369): connectGatt
08-12 12:20:09.844 D/BluetoothGatt(19369): connect() - device: 65:C0:3D:08:3E:FE, auto: false
08-12 12:20:09.844 D/BluetoothGatt(19369): registerApp()
08-12 12:20:09.844 D/BluetoothGatt(19369): registerApp() - UUID=a1c83849-351e-45a9-be8c-434f2a9628b9
08-12 12:20:09.845 D/BtGatt.GattService(19265): registerClient() - UUID=a1c83849-351e-45a9-be8c-434f2a9628b9
08-12 12:20:09.846 D/BtGatt.GattService(19265): onClientRegistered() - UUID=a1c83849-351e-45a9-be8c-434f2a9628b9, clientIf=5
08-12 12:20:09.846 D/BluetoothGatt(19369): onClientRegistered() - status=0 clientIf=5
08-12 12:20:09.847 D/BtGatt.GattService(19265): clientConnect() - address=65:C0:3D:08:3E:FE, isDirect=true
08-12 12:20:09.847 D/bt_btif_config(19265): btif_get_address_type: Device [65:c0:3d:08:3e:fe] address type 1
08-12 12:20:09.847 D/bt_btif_config(19265): btif_get_device_type: Device [65:c0:3d:08:3e:fe] type 2
08-12 12:20:10.214 E/BluetoothRemoteDevices(19265): state12newState0
08-12 12:20:10.240 I/TrustAgent.Tracker( 1355): [BluetoothConnectionTracker] Bluetooth connect broadast for Nexus 5X 65:C0:3D:08:3E:FE
08-12 12:20:10.242 D/BtGatt.GattService(19265): onConnected() - clientIf=5, connId=5, address=65:C0:3D:08:3E:FE
08-12 12:20:10.242 D/BluetoothGatt(19369): onClientConnectionState() - status=0 clientIf=5 device=65:C0:3D:08:3E:FE
08-12 12:20:10.242 I/cr_Bluetooth(19369): onConnectionStateChange status:0 newState:Connected
08-12 12:20:10.242 D/BluetoothGatt(19369): discoverServices() - device: 65:C0:3D:08:3E:FE
08-12 12:20:10.242 D/BtGatt.GattService(19265): discoverServices() - address=65:C0:3D:08:3E:FE, connId=5
08-12 12:20:10.244 D/BtGatt.GattService(19265): onSearchCompleted() - connId=5, status=0
08-12 12:20:10.245 D/BluetoothGatt(19369): onSearchComplete() = Device=65:C0:3D:08:3E:FE Status=0
08-12 12:20:10.245 I/cr_Bluetooth(19369): onServicesDiscovered status:0==OK

// Start notifications never shows up even it says "started" ;(
 
It may be because notifications are still considered active on Android... see https://chromium.googlesource.com/chromium/src/+/master/content/browser/bluetooth/web_bluetooth_service_impl.cc#612
isActive() doesn't seem to be set on Android. So that's not it ;(

Comment 3 by ortuno@chromium.org, Aug 12 2016

Owner: tom...@opera.com
Status: Started (was: Available)
Tommy's patch should fix this

Comment 4 by pe...@opera.com, Aug 15 2016

@ortuno: just tested with Tommy's patch and it works fine!

https://codereview.chromium.org/2051333004/

Comment 5 by tom...@opera.com, Aug 23 2016

Status: Fixed (was: Started)
The patch is now in (and it has sat on master for 24 hours without being reverted), so this should now be fixed.

Sign in to add a comment