[web-bluetooth] Bluetooth device connection promise not resolving if device times out

Open
#668 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 13 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
api, web-dev

Research direction

Open the web-bluetooth/automatic-reconnect example at automatic-reconnect.html and reproduce the Wahoo sensor timeout sequence in Chrome 79 on macOS. Start by comparing the reconnect flow after gattserverdisconnected with the behavior after bluetoothDevice.gatt.disconnect(). Done means a timed-out bluetoothDevice.gatt.connect() no longer leaves the requestDevice() chooser stalled and the connection promise reaches a defined outcome.

Written by the indexing model from the issue text.

Description

There seems to be a bug in the web-bluetooth/automatic-reconnect example or in the way web bluetooth is implemented in Chrome.
I have already filed a bug-report for Chrome, but since this may relate to API changes the bug may be caused by the fact that the sample code is out of date.

The problem:
Bluetooth device connection promise not resolving if device times out.

Steps to reproduce the problem:

  1. Launch Chrome
  2. Go to: https://googlechrome.github.io/samples/web-bluetooth/automatic-reconnect.html
  3. Click Scan button
  4. Select BTLE device
    (Tested with Wahoo Cadence Sensor and Wahoo Heart Rate Sensor)
  5. Wait for the device to connect
  6. Let the sensor rest until it disconnects
  7. Wait for the 'gattserverdisconnected' event to be triggered and the first reconnect cycle to start
  8. The program will stall and the requestDevice() chooser will stop responding

What is the expected behavior?
The bluetoothDevice.gatt.connect() call should time out after some time if the client can not connect to the server. This does happen if the client disconnects but not the server (The BT device).

What went wrong?
The bluetoothDevice.gatt.connect() Promise seems to never get resolved. This does only happen if the device times out. If the device is removed via bluetoothDevice.gatt.disconnect() the API behaves as expected.

Chrome version: 79.0.3945.130 Channel: stable
OS Version: OS X 10.15.2

Dominant language
JavaScript
Stars
5.9k
Forks
2.4k
Avg merge
12d 12h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GoogleChrome/samples

All issues in GoogleChrome/samples

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.