Repository navigation
fix(ble): complete nearby-sensor scans at a registry-owned deadline - #130
Closed
shroominic wants to merge 1 commit into
Closed
shroominic wants to merge 1 commit into
shroominic wants to merge 1 commit into
Conversation
FlutterBluePlusTransport.scan's stream can stay open when flutter_blue_plus stops the physical scan without emitting isScanning == false, so the discovery loop never returned and the Connect-a-sensor panel kept scanning forever. The registry now owns the scan deadline (_activeScanTimeout + _completeScanAtDeadline) so an overrun scan still ends for every consumer, bounds transport cancellation so a wedged cancel cannot hold the lifecycle open, and keeps an assert-gated, identity-free scan diagnostic for debug builds.
Owner
Author
|
Carried by the GS1 consolidation in PR #209 (branch feature/cbio-gs1, head 3eca4f4). This PR is contained in the consolidated line; the merge that carries it is c85f827. Closing as subsumed by the consolidation - not as won't fix. The per-defect evidence stays in this thread, and the carrying commit above is where the change now lives. |
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 #129.
Root cause
AppController.scan()drives aStreamIteratorloop over the registry's discovery stream.FlutterBluePlusTransport.scanbuilds its stream from flutter_blue_plus'scanResultsand only closes it on theisScanning == falsetransition. On the Pixel 6, flutter_blue_plus stopped the physical scan without emitting that transition, so the transport stream never closed, the discovery loop never returned, and the Connect-a-sensor panel spun forever.Device evidence: one
LOW_LATENCYscan ran the full 6006 ms requested timeout and delivered scan results while the UI stayed in the scanning state with no candidates shown. The panel'swaitingbranch renders the empty state, but it is only reachable oncescanningis false, so a scan that never completes hides every discovered sensor behind the spinner.Fix
_activeScanTimeout+_completeScanAtDeadline): a scan that reaches its requested timeout ends even when the transport stream stays open, so every consumer observes completion._scanCancellationTimeout, so a transport that cannot confirm its own cancellation cannot hold the scan lifecycle (and the UI) open. Confirmed cancellations still fail closed and stay latched._debugScanStephelper for debug builds only.RED to GREEN tests
test/cgm_driver_registry_test.darttest/app_controller_persistence_test.dartVerification
All tests passed!(exit 0).flutter analyze:No issues found!adb -s 100.127.252.5:5555) with this build installed: tapping Connect a sensor now ends the spinner and the panel renders "No Bluetooth sensors found / Keep the sensor close and try again." with a retry control and "Can't find your sensor?".Remaining gap (out of scope, not claimed fixed)
This change makes scans complete; it does not claim discovery yield. A separate measurement in the same window showed filtered scans yielding 0 candidates while an unfiltered plugin scan saw 69 advertisements including the FF30 sensor. Discovery yield under
withServicesfiltering is still open and is tracked separately.