Scan with allow-duplicates — Nearby presence froze and culled advertising boards#12
Merged
Conversation
Field report on the Release build: every advertising board appeared in Nearby for ~20 seconds, then vanished until the scan was restarted. Root cause: scanForPeripherals ran WITHOUT CBCentralManagerScanOptionAllowDuplicatesKey, so iOS delivered each peripheral's advertisement exactly once per scan session — advertisementLastSeen froze at discovery, the 8 s freshness window expired, and the row was culled forever. (Debug testing masked it: screen navigation restarts the scan, resetting the duplicate filter, and macOS re-delivers more readily than iOS.) Scans now pass allow-duplicates — these are foreground, user-visible scans, the sanctioned use for the energy-costly flag — and the scanner's per-advertisement writes are guarded on actual change (@observable treats same-value dictionary writes as mutations, and unguarded writes would invalidate SwiftUI at advertising rate). advertisementLastSeen updates at 1 s granularity, plenty for the freshness window. Bumps to build 3 for the next upload. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Release-build field report: advertising boards appeared in Nearby for ~20 s, vanished, and never returned until the scan restarted.
Root cause:
scanForPeripheralsran withoutCBCentralManagerScanOptionAllowDuplicatesKey, so iOS delivers each peripheral once per scan session.advertisementLastSeenfroze at discovery → the 8 s freshness window (PR #11) expired → the row was culled, permanently. Debug testing masked it: screen navigation restarts the scan (resetting the duplicate filter) and macOS re-delivers more readily than iOS. A static soak on the scan screen exposed it immediately.Fix: allow-duplicates on both scan start paths (foreground, user-visible scanning — the sanctioned use for the energy-costly flag), plus change-guards on the scanner's per-advertisement dictionary writes so SwiftUI isn't invalidated at advertising rate (
@Observabletreats same-value writes as mutations);advertisementLastSeenupdates at 1 s granularity.Bumps to build 3. Validation: 1040/1040 SPM tests, app builds; the behavioral proof needs the Release archive on a phone — watch a board sit in Nearby indefinitely, then power it off and see it drop within ~8 s.
🤖 Generated with Claude Code