Web Bluetooth: Expose maxWriteWithoutResponseSize [chromium/src : main]

0 views
Skip to first unread message

Helmut Januschka (Gerrit)

unread,
Jun 24, 2026, 10:51:24 AMJun 24
to warith Akbar, Chromium IPC Reviews, Kinuko Yasuda, Reilly Grant, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chadduffin+wa...@chromium.org, hansberry+wa...@chromium.org, hashimo...@chromium.org, hsuregan+wat...@chromium.org, ipc-securi...@chromium.org, jackshira+wa...@google.com, jiajunz+wat...@google.com, jmedle...@chromium.org, khorimoto+wa...@chromium.org, kinuko...@chromium.org, mac-r...@chromium.org, mattreyno...@chromium.org, nikhilcn+wat...@google.com, odejesu...@chromium.org
Attention needed from Kinuko Yasuda, Reilly Grant and warith Akbar

Helmut Januschka added 6 comments

Patchset-level comments
File-level comment, Patchset 9:
warith Akbar . resolved

sa...@smart-devops.com

Helmut Januschka

Done

File-level comment, Patchset 12:
Helmut Januschka . resolved

aligned this with the spec PR, the attribute is cached in the renderer, seeded from the live platform MTU when characteristics are enumerated, and updated by MTU-change events on the supported platforms that can report changes. macOS/CoreBluetooth has no change event, but the value is settled before characteristic discovery. tried it without caching but that leads to a synchronous blocking mojo call.

File device/bluetooth/bluetooth_device_android.cc
Line 321, Patchset 9: mtu_ = static_cast<uint16_t>(mtu);
Reilly Grant . resolved

Fire the `DeviceMTUChanged` event?

Helmut Januschka

Done

Line 151, Patchset 9: if (mtu > std::numeric_limits<uint16_t>::max()) {
return std::nullopt;
}
return static_cast<uint16_t>(mtu);
Reilly Grant . unresolved

Use a saturating cast so that this just turns into MAX_UINT16 if it's too large. Or does this really even need to be sent as a uint16 over Mojo?

Helmut Januschka

Done. i think it should stay uint16, esp, android they all handle mtu as uint16, and ideas how mojo could be changed?

File device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc
Line 48, Patchset 9: RegisterProperty(kMTUProperty, &mtu);
Reilly Grant . resolved

Why isn't there a constant in the `bluetooth_gatt_characteristic` namespace for this?

Helmut Januschka

Done

File third_party/blink/renderer/modules/bluetooth/bluetooth_remote_gatt_characteristic.cc
Line 67, Patchset 9: if (!GetGatt()->connected()) {
Reilly Grant . resolved

This should probably still be update the cached value but maybe not fire an event if disconnected.

Helmut Januschka

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Kinuko Yasuda
  • Reilly Grant
  • warith Akbar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic50b8b342e8b38898914174ea92408089faef32d
Gerrit-Change-Number: 7879985
Gerrit-PatchSet: 15
Gerrit-Owner: Helmut Januschka <hel...@januschka.com>
Gerrit-Reviewer: Helmut Januschka <hel...@januschka.com>
Gerrit-Reviewer: Kinuko Yasuda <kin...@chromium.org>
Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
Gerrit-CC: Chromium IPC Reviews <chrome-ip...@google.com>
Gerrit-CC: gwsq
Gerrit-CC: warith Akbar <sa...@smart-devops.com>
Gerrit-Attention: Reilly Grant <rei...@chromium.org>
Gerrit-Attention: warith Akbar <sa...@smart-devops.com>
Gerrit-Attention: Kinuko Yasuda <kin...@chromium.org>
Gerrit-Comment-Date: Wed, 24 Jun 2026 14:51:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Reilly Grant <rei...@chromium.org>
Comment-In-Reply-To: warith Akbar <sa...@smart-devops.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Reilly Grant (Gerrit)

unread,
Aug 7, 2026, 5:23:14 PM (2 days ago) Aug 7
to Helmut Januschka, Reilly Grant, warith Akbar, Chromium IPC Reviews, Kinuko Yasuda, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chadduffin+wa...@chromium.org, hansberry+wa...@chromium.org, hashimo...@chromium.org, hsuregan+wat...@chromium.org, ipc-securi...@chromium.org, jackshira+wa...@google.com, jiajunz+wat...@google.com, jmedle...@chromium.org, khorimoto+wa...@chromium.org, kinuko...@chromium.org, mac-r...@chromium.org, mattreyno...@chromium.org, nikhilcn+wat...@google.com, odejesu...@chromium.org
Attention needed from Helmut Januschka, Kinuko Yasuda and warith Akbar

Reilly Grant voted and added 1 comment

Votes added by Reilly Grant

Code-Review+1

1 comment

File third_party/blink/renderer/modules/bluetooth/bluetooth_remote_gatt_characteristic.idl
Line 19, Patchset 6: [CallWith=ScriptState, RaisesException] Promise<unsigned short> getMTU();
Reilly Grant . resolved

This change needs a corresponding specification PR and Intent to Ship.

In terms of API shape, I suspect we could add this information to `blink.mojom.WebBluetoothRemoteGATTCharacteristic` so that it is available synchronously, depending on when in the device discovering and connection process the value is known.

Helmut Januschka

spec pr: https://github.com/WebBluetoothCG/web-bluetooth/pull/672
feature entry (i'll pursue getting it through the stages; after the spec PR lands): https://chromestatus.com/feature/5177569273053184

also added a default-off flag, and we can flip it after the i2s


> In terms of API shape, I suspect we could add this information to blink.mojom.WebBluetoothRemoteGATTCharacteristic so that it is available synchronously...

I looked into this across the four backends and I think the async shape is actually the right one, for a correctness reason rather than just plumbing convenience:

The ATT MTU is per-connection, mutable state, and on most platforms it isn't reliably known at characteristic-discovery time.

Reilly Grant

All the implementations I see in this CL read the value synchronously. It seems like we could at least initialize the characteristic with a value, and then hook up an event to propagate the change to the renderer when it changes.

Does that work to implement the currently proposed API shape in your PR?

Helmut Januschka

yep, done exactly that. initial maxWriteWithoutResponseSize (att_mtu - 3) carried in the mojom struct so it reads sync, plus a `maxwritewithoutresponsesizechanged` event wired through WebBluetoothCharacteristicClient (BlueZ DeviceMTUChanged fires it). should now align with the spec PR.

Reilly Grant

The specification change is ready to land once we're sure there aren't any implementation issues. Please send out the "Intent to Prototype" based on your ChromeStatus entry.

Open in Gerrit

Related details

Attention is currently required from:
  • Helmut Januschka
  • Kinuko Yasuda
  • warith Akbar
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic50b8b342e8b38898914174ea92408089faef32d
    Gerrit-Change-Number: 7879985
    Gerrit-PatchSet: 15
    Gerrit-Owner: Helmut Januschka <hel...@januschka.com>
    Gerrit-Reviewer: Helmut Januschka <hel...@januschka.com>
    Gerrit-Reviewer: Kinuko Yasuda <kin...@chromium.org>
    Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
    Gerrit-CC: Chromium IPC Reviews <chrome-ip...@google.com>
    Gerrit-CC: gwsq
    Gerrit-CC: warith Akbar <sa...@smart-devops.com>
    Gerrit-Attention: Helmut Januschka <hel...@januschka.com>
    Gerrit-Attention: warith Akbar <sa...@smart-devops.com>
    Gerrit-Attention: Kinuko Yasuda <kin...@chromium.org>
    Gerrit-Comment-Date: Fri, 07 Aug 2026 21:22:59 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Helmut Januschka <hel...@januschka.com>
    Comment-In-Reply-To: Reilly Grant <rei...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Reilly Grant (Gerrit)

    unread,
    Aug 7, 2026, 5:23:28 PM (2 days ago) Aug 7
    to Helmut Januschka, Reilly Grant, warith Akbar, Chromium IPC Reviews, Kinuko Yasuda, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chadduffin+wa...@chromium.org, hansberry+wa...@chromium.org, hashimo...@chromium.org, hsuregan+wat...@chromium.org, ipc-securi...@chromium.org, jackshira+wa...@google.com, jiajunz+wat...@google.com, jmedle...@chromium.org, khorimoto+wa...@chromium.org, kinuko...@chromium.org, mac-r...@chromium.org, mattreyno...@chromium.org, nikhilcn+wat...@google.com, odejesu...@chromium.org
    Attention needed from Helmut Januschka, Kinuko Yasuda and warith Akbar

    Reilly Grant voted and added 1 comment

    Votes added by Reilly Grant

    Code-Review+0

    1 comment

    Patchset-level comments
    File-level comment, Patchset 15 (Latest):
    Reilly Grant . resolved

    Sorry, that was a mis-click. Not done reviewing.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Helmut Januschka
    • Kinuko Yasuda
    • warith Akbar
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic50b8b342e8b38898914174ea92408089faef32d
      Gerrit-Change-Number: 7879985
      Gerrit-PatchSet: 15
      Gerrit-Owner: Helmut Januschka <hel...@januschka.com>
      Gerrit-Reviewer: Helmut Januschka <hel...@januschka.com>
      Gerrit-Reviewer: Kinuko Yasuda <kin...@chromium.org>
      Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
      Gerrit-CC: Chromium IPC Reviews <chrome-ip...@google.com>
      Gerrit-CC: gwsq
      Gerrit-CC: warith Akbar <sa...@smart-devops.com>
      Gerrit-Attention: Helmut Januschka <hel...@januschka.com>
      Gerrit-Attention: warith Akbar <sa...@smart-devops.com>
      Gerrit-Attention: Kinuko Yasuda <kin...@chromium.org>
      Gerrit-Comment-Date: Fri, 07 Aug 2026 21:23:16 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Reilly Grant (Gerrit)

      unread,
      Aug 7, 2026, 5:48:18 PM (2 days ago) Aug 7
      to Helmut Januschka, Reilly Grant, warith Akbar, Chromium IPC Reviews, Kinuko Yasuda, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chadduffin+wa...@chromium.org, hansberry+wa...@chromium.org, hashimo...@chromium.org, hsuregan+wat...@chromium.org, ipc-securi...@chromium.org, jackshira+wa...@google.com, jiajunz+wat...@google.com, jmedle...@chromium.org, khorimoto+wa...@chromium.org, kinuko...@chromium.org, mac-r...@chromium.org, mattreyno...@chromium.org, nikhilcn+wat...@google.com, odejesu...@chromium.org
      Attention needed from Helmut Januschka, Kinuko Yasuda and warith Akbar

      Reilly Grant added 5 comments

      File content/browser/bluetooth/web_bluetooth_service_impl.cc
      Line 145, Patchset 15 (Latest): return static_cast<uint32_t>(effective_mtu) - kAttWriteCommandHeaderSize;
      Reilly Grant . unresolved

      I don't think an explicit cast is necessary here.

      Line 780, Patchset 15 (Latest): // Notify characteristics on this device that have an active client (i.e. a
      // notify session). MTU is per-connection, so every such characteristic gets
      // the same updated value.
      Reilly Grant . unresolved

      A notify session shouldn't be required to get updates to device MTU. This is an artifact of the fact that the event is sent on the `WebBluetoothCharacteristicClient` pipe which is only present when notifications are enabled instead of the `WebBluetoothServerClient` pipe which is always present.

      Line 145, Patchset 15 (Latest): maximumWriteValueLengthForType:CBCharacteristicWriteWithoutResponse];
      Reilly Grant . unresolved

      On macOS, consider checking this value on the completion of a read or write to see if it has changed so we can inform the renderer.

      File device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
      Line 153, Patchset 15 (Latest): return properties->mtu.value();
      Reilly Grant . unresolved

      Hook up the event for when this property changes. To keep this change small, feel free to implement one platform at a time, keeping only one platform (e.g. Windows) in the main patch.

      File device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc
      Line 24, Patchset 15 (Latest):constexpr char kMTUProperty[] = "MTU";
      Reilly Grant . unresolved

      This should be added to `third_party/cros_system_api/dbus/bluetooth/dbus-constants.h`.

      Gerrit-Comment-Date: Fri, 07 Aug 2026 21:48:06 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Helmut Januschka (Gerrit)

      unread,
      5:31 PM (3 hours ago) 5:31 PM
      to Reilly Grant, warith Akbar, Chromium IPC Reviews, Kinuko Yasuda, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chadduffin+wa...@chromium.org, hansberry+wa...@chromium.org, hashimo...@chromium.org, hsuregan+wat...@chromium.org, ipc-securi...@chromium.org, jackshira+wa...@google.com, jiajunz+wat...@google.com, jmedle...@chromium.org, khorimoto+wa...@chromium.org, kinuko...@chromium.org, mac-r...@chromium.org, mattreyno...@chromium.org, nikhilcn+wat...@google.com, odejesu...@chromium.org
      Attention needed from Kinuko Yasuda, Reilly Grant and warith Akbar

      Helmut Januschka voted and added 7 comments

      Votes added by Helmut Januschka

      Commit-Queue+1

      7 comments

      Patchset-level comments
      File-level comment, Patchset 16 (Latest):
      Helmut Januschka . unresolved

      done, took a while to build and test on mac, windows, linux (that was the easy one)

      thanks for your time, from my pov, this matches the spec PR, but pelase let me know if you want me to address anything.


      about the flag, should we put it into stable, and keep it as killswitch?
      why i am asking, i am curious if this requires intent-to-ship or not.

      File content/browser/bluetooth/web_bluetooth_service_impl.cc
      Line 145, Patchset 15: return static_cast<uint32_t>(effective_mtu) - kAttWriteCommandHeaderSize;
      Reilly Grant . resolved

      I don't think an explicit cast is necessary here.

      Helmut Januschka

      Done

      Line 780, Patchset 15: // Notify characteristics on this device that have an active client (i.e. a

      // notify session). MTU is per-connection, so every such characteristic gets
      // the same updated value.
      Reilly Grant . resolved

      A notify session shouldn't be required to get updates to device MTU. This is an artifact of the fact that the event is sent on the `WebBluetoothCharacteristicClient` pipe which is only present when notifications are enabled instead of the `WebBluetoothServerClient` pipe which is always present.

      Helmut Januschka

      Done. Moved MaxWriteWithoutResponseSizeChanged to the WebBluetoothServerClient pipe so no notify session is needed. DeviceMTUChanged now forwards through FrameConnectedBluetoothDevices to the connection's server client, and on the renderer side BluetoothRemoteGATTServer fans the update out to all live characteristics via BluetoothDevice/BluetoothAttributeInstanceMap

      Line 145, Patchset 15: maximumWriteValueLengthForType:CBCharacteristicWriteWithoutResponse];
      Reilly Grant . resolved

      On macOS, consider checking this value on the completion of a read or write to see if it has changed so we can inform the renderer.

      Helmut Januschka

      Done.

      Line 151, Patchset 9: if (mtu > std::numeric_limits<uint16_t>::max()) {
      return std::nullopt;
      }
      return static_cast<uint16_t>(mtu);
      Reilly Grant . resolved

      Use a saturating cast so that this just turns into MAX_UINT16 if it's too large. Or does this really even need to be sent as a uint16 over Mojo?

      Helmut Januschka

      Done. i think it should stay uint16, esp, android they all handle mtu as uint16, and ideas how mojo could be changed?

      Helmut Januschka

      Done

      File device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
      Line 153, Patchset 15: return properties->mtu.value();
      Reilly Grant . resolved

      Hook up the event for when this property changes. To keep this change small, feel free to implement one platform at a time, keeping only one platform (e.g. Windows) in the main patch.

      Helmut Januschka

      Done. BluetoothRemoteGattServiceBlueZ::GattCharacteristicPropertyChanged now handles the characteristic MTU property and fires DeviceMTUChanged. While hooking this up I consolidated the identical per-platform NotifyDeviceMTUChanged helpers (Android/WinRT/Apple from this CL, plus the pre-existing BlueZ one) into a single BluetoothAdapter::NotifyDeviceMTUChanged in the base class.

      File device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc
      Line 24, Patchset 15:constexpr char kMTUProperty[] = "MTU";
      Reilly Grant . unresolved

      This should be added to `third_party/cros_system_api/dbus/bluetooth/dbus-constants.h`.

      Helmut Januschka
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Kinuko Yasuda
      • Reilly Grant
      • warith Akbar
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic50b8b342e8b38898914174ea92408089faef32d
      Gerrit-Change-Number: 7879985
      Gerrit-PatchSet: 16
      Gerrit-Owner: Helmut Januschka <hel...@januschka.com>
      Gerrit-Reviewer: Helmut Januschka <hel...@januschka.com>
      Gerrit-Reviewer: Kinuko Yasuda <kin...@chromium.org>
      Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
      Gerrit-CC: Chromium IPC Reviews <chrome-ip...@google.com>
      Gerrit-CC: gwsq
      Gerrit-CC: warith Akbar <sa...@smart-devops.com>
      Gerrit-Attention: Reilly Grant <rei...@chromium.org>
      Gerrit-Attention: warith Akbar <sa...@smart-devops.com>
      Gerrit-Attention: Kinuko Yasuda <kin...@chromium.org>
      Gerrit-Comment-Date: Sun, 09 Aug 2026 21:30:44 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages