Repository navigation
Conversation
Regenerate the Pigeon outputs with 29.0.10 (from 26.3.4). The generated Kotlin and Swift channels are now coroutine/async based, so the native plugins had to be adapted: - Android: bridge the previous callback implementations to the new suspend interface, deliver Dart callbacks from coroutines, and depend on kotlinx-coroutines-android. - Darwin: bridge the completion-based implementations to the new async protocol, deliver Dart callbacks with @mainactor Tasks, and answer peripheral read/write requests asynchronously. - Windows: only generated helpers (operator<<, PigeonInternalToString) were added; the abstract interfaces are unchanged, so no hand-written changes were needed. - Tests: adapt MtuCompletionTest and DisconnectCloseTest to the suspend API and provide a Main dispatcher on the JVM. No change to the public Dart API.
- Share one fire-and-forget helper per platform (Kotlin `fireAndForget`, Swift `DartCallbackSender.sendToDart`) instead of duplicated per-plugin helpers, and log delivery failures instead of swallowing them. - Bound peripheral read/write requests so a dropped Dart reply cannot pin the CoreBluetooth/GATT request open (10s), then answer the central with a failure. - Add a shared `MainDispatcherTest` base for JVM tests that deliver through Dispatchers.Main. - Add a CI job that regenerates the Pigeon outputs and fails if they drift from the pinned version.
…al indirection - Darwin: the pending-request registries (`…Future`, availability/permission handlers) now hold `CheckedContinuation` instead of completion closures. The generated async protocol methods are the single entry point; the old `…Impl` methods are gone (the continuation-taking logic is now an overload of the same name). Added a `CheckedContinuation.finish(_:)` helper to avoid the Swift 6 `Error`/`any Error` ambiguity of `resume(with:)`. - Android: keep the callback-driven GATT logic but remove the `…Internal` naming noise (same-name overloads taking a `(Result<T>) -> Unit`), matching Darwin. - Cancellation wiring is intentionally not part of this change (it needs thread-safe pending-request removal and its own tests).
Note the two pieces intentionally left out of the migration: coroutine/async cancellation wiring (both platforms) and converting the Android pending-request registries to CancellableContinuation as done on Darwin.
…ridging The Pigeon 29 migration converted the iOS-only AccessorySetupKit picker to CheckedContinuation but left several references in the old closure shape, so the iOS target did not compile: - pickerCompletion now stores the continuation instead of a closure - showPicker assigns the continuation parameter (not the removed completion) - completePicker resumes the stored continuation - requestDevice/unPair pass continuation: instead of a trailing closure Also: - capture the advertising state locally before deferred Dart delivery so a later state change cannot alter the value sent to Dart - stop swallowing genuine CancellationException in the Android peripheral awaitReply timeout bridge
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.
Regenerates the Pigeon outputs with 29.0.10 (from 26.3.4). Pigeon 29 changes the generated channel shape, not just formatting: the Kotlin channel methods become
suspendand the Swift ones becomeasync throws, so the hand-written plugins had to be adapted.Changes
lib/src/universal_ble.g.dart,UniversalBle.g.kt,UniversalBle.g.swift,windows/.../universal_ble.g.{h,cpp}), Dart file formatted.suspendinterface (suspendCancellableCoroutine), deliver Dart callbacks from coroutines on the main dispatcher, and addkotlinx-coroutines-android. Peripheral read/write requests await the Dart reply and respond from a coroutine.asyncprotocol (withCheckedThrowingContinuation), deliver Dart callbacks viaTask { @MainActor in ... }, and answer peripheral read/write requests asynchronously (no semaphores, to avoid a main-actor deadlock).operator<<,PigeonInternalToString); the abstract interfaces are unchanged, so no hand-written changes were needed.MtuCompletionTestandDisconnectCloseTestadapted to the suspend API;kotlinx-coroutines-testadded to provide a Main dispatcher on the JVM.No change to the public Dart API; still 3.1.1.
Verification
cd example/android && gradle :universal_ble:testDebugUnitTest— passed (51 tests)flutter build macos --debug— builtflutter analyze— no issuesflutter test— passed (285 tests)Notes
flutter build windows+ ctest.UniversalBlePlugin.{kt,swift},UniversalBlePeripheralPlugin.{kt,swift}, the two Android tests, andandroid/build.gradle.