From 8d62dc7cc83d661fa460a0a0fa6f3f8b19de3015 Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Wed, 30 Sep 2026 14:02:45 -0400 Subject: [PATCH] fix(#718): stop the BLE MTU floor locking the composer on web Web Bluetooth exposes no ATT MTU to page script; there is no API for it, so `mtuNow` can only ever be the 23-byte default. `effectiveMaxFrameSize` applied the BLE floor on every platform whenever the transport was bluetooth, so web landed on 20 bytes permanently and the channel composer computed a 0-byte limit. That is the #592 symptom on a third platform. Unlike Windows (#686) and Linux (#717), this cannot be fixed by reporting an MTU, because there is none to report. Patching flutter_blue_plus_web would achieve nothing. The floor exists because a raw single characteristic write larger than the PDU is rejected and wedges the send path (#395). That failure mode is not reachable on web: the browser owns fragmentation, and the Web Bluetooth spec caps one write at 512 bytes, rejecting anything larger with InvalidModificationError. maxFrameSize (172) is well inside that, so a write cannot be oversized whatever the link negotiated. Cited rather than assumed, because "just remove the floor" was considered and rejected as the fix for #592. Not unit-testable: `kIsWeb` is a compile-time constant, so a VM test cannot enter this branch and CI runs the suite on the VM only. The floor's behaviour on the other platforms stays covered. Proving this one needs a max-length send over web BLE in a browser, which is the acceptance criterion on #718. Co-Authored-By: Claude Opus 5 --- lib/connector/meshcore_connector.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index c1d8d167..d7072846 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -507,6 +507,19 @@ class MeshCoreConnector extends ChangeNotifier { if (_activeTransport != MeshCoreTransportType.bluetooth) { return maxFrameSize; } + // Web Bluetooth exposes no ATT MTU to page script: there is no API for it, + // so `mtuNow` can only ever be the 23-byte default and the floor below + // would cap every composer at 0-4 bytes forever (#718, the #592 symptom). + // + // The floor exists because a raw single characteristic write larger than + // the PDU is rejected and wedges the send path (#395). That failure mode is + // not reachable here: the browser owns fragmentation, and the Web Bluetooth + // spec caps one write at 512 bytes, rejecting anything larger with + // InvalidModificationError. maxFrameSize (172) is well inside that, so the + // write cannot be oversized no matter what the link negotiated. + if (PlatformInfo.isWeb) { + return maxFrameSize; + } final mtu = _device?.mtuNow ?? 0; // ATT_MTU 23 is the BLE minimum; a single write then carries 23 - 3 = 20 // bytes. An unknown MTU must fall back to that floor, never [maxFrameSize],