Fix Apple queued write throughput (#271) - #281
Draft
fotiDim wants to merge 2 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves write throughput on Apple platforms by allowing consecutive BLE writes to be pipelined (submitted before prior writes complete) while preserving queue-barrier semantics for non-write operations. It also adds Darwin-side handling for write-without-response backpressure and ensures write-with-response callbacks resolve FIFO to safely support pipelined writes.
Changes:
- Add a pipelining-capable queue path for writes (
queueWrite+ concurrent queue entries) while keeping non-write commands serialized behind write barriers. - Enable
supportsWritePipeliningon iOS/macOS implementations (Pigeon + Web) and use it inUniversalBle.write. - Update Darwin plugin to (a) backpressure writes without response, (b) fail pending writes on disconnect, and (c) resolve write-with-response futures FIFO; add tests + docs/changelog.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/universal_ble_write_queue_test.dart | Adds regression tests for pipelined vs serialized writes and queue-barrier behavior. |
| test/universal_ble_test_mock.dart | Extends the platform mock to satisfy the updated platform interface (readRssi). |
| README.md | Documents Apple/Chromium-on-Apple pipelined write behavior and queue barriers. |
| lib/src/utils/ble_command_queue.dart | Adds queueWrite and routes pipelined writes through concurrent queue adds. |
| lib/src/universal_ble.dart | Uses queueWrite for write() and enables pipelining when the platform supports it. |
| lib/src/universal_ble_web/universal_ble_web.dart | Enables write pipelining on iOS/macOS targets for Web implementation. |
| lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart | Enables write pipelining on iOS/macOS targets for native (Pigeon) implementation. |
| lib/src/queue.dart | Adds addConcurrent and concurrency gating to allow consecutive concurrent items. |
| lib/src/interfaces/universal_ble_platform_interface.dart | Introduces supportsWritePipelining capability flag (default false). |
| darwin/universal_ble/Sources/universal_ble/UniversalBlePlugin.swift | Implements backpressure for write-without-response, disconnect failure for pending writes, and FIFO completion for write-with-response. |
| darwin/universal_ble/Sources/universal_ble/UniversalBleHelper.swift | Adds PendingWriteWithoutResponse helper type. |
| CHANGELOG.md | Notes the Apple pipelined write throughput improvement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
433
to
436
| guard let peripheral = deviceId.findPeripheral(manager: manager) else { | ||
| completion(Result.failure(createFlutterError(code: .deviceNotFound, message: "Unknown deviceId:\(self)"))) | ||
| return | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #271