Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Issue 2708513002: bluetooth: Post a task when sending GATT events to simulate another thread. (Closed)

Created:
3 years, 10 months ago by ortuno
Modified:
3 years, 9 months ago
Reviewers:
scheib
CC:
agrieve+watch_chromium.org, chromium-reviews, ortuno+watch_chromium.org, scheib+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

bluetooth: Post a task when sending GATT events to simulate another thread. On Android, Bluetooth GATT events arrive on a different thread so we post them on the UI thread when they arrive. There have been a couple of bugs where multiple events arrive at the same time so when the task on the UI thread runs, it runs with invalid information. To simulate this behavior we wrap ThreadUtils in ThreadUtilsWrapper and in tests always post a task. For example: SimulateGattCharacteristicValueChanged(std::vector<uint8_t>({1, 2})); SimulateGattCharacteristicValueChanged(std::vector<uint8_t>({2, 1})); base::RunLoop().RunUntilIdle(); In this case the first SimulateGattCharacteristicValueChanged() sets characteristic's value to {1, 2} then posts a task to notify the clients. Then the second SimulateGattCharacteristicValueChanged() gets called and sets the characteritic's value to {2, 1} and posts a task to notify the clients. When the first posted task runs it sees the value is {2, 1} and notifies of this value. Which is incorrect. The first of a set of patches to fix race conditions in Android: [1] Post a task when sending GATT events. (This patch). [2.1] Close and null out BluetoothGatt on the UI Thread http://crrev.com/2702163002 [2.2] Copy characteristic's value before posting task http://crrev.com/2707823002 BUG=691407 Review-Url: https://codereview.chromium.org/2708513002 Cr-Commit-Position: refs/heads/master@{#455034} Committed: https://chromium.googlesource.com/chromium/src/+/9409d055c1933a95f40b7fb2ff08fa26a97f4e08

Patch Set 1 #

Total comments: 2

Patch Set 2 : Remove unnecessary if statement #

Messages

Total messages: 19 (13 generated)
ortuno
jyasskin: PTAL
3 years, 10 months ago (2017-02-21 10:44:25 UTC) #9
ortuno
scheib: PTAL
3 years, 9 months ago (2017-02-27 23:06:27 UTC) #11
scheib
lgtm https://codereview.chromium.org/2708513002/diff/1/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java File device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java (right): https://codereview.chromium.org/2708513002/diff/1/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java#newcode94 device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java:94: return; Is this ever expected to happen? I ...
3 years, 9 months ago (2017-03-04 18:47:05 UTC) #12
ortuno
Thanks! https://codereview.chromium.org/2708513002/diff/1/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java File device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java (right): https://codereview.chromium.org/2708513002/diff/1/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java#newcode94 device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java:94: return; On 2017/03/04 at 18:47:05, scheib wrote: > ...
3 years, 9 months ago (2017-03-07 03:40:52 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2708513002/20001
3 years, 9 months ago (2017-03-07 03:41:56 UTC) #16
commit-bot: I haz the power
3 years, 9 months ago (2017-03-07 05:08:08 UTC) #19
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as
https://chromium.googlesource.com/chromium/src/+/9409d055c1933a95f40b7fb2ff08...

Powered by Google App Engine
This is Rietveld 408576698