Skip to content

Scan with allow-duplicates — Nearby presence froze and culled advertising boards#12

Merged
lkasso merged 1 commit into
mainfrom
scan-allow-duplicates
Jul 7, 2026
Merged

Scan with allow-duplicates — Nearby presence froze and culled advertising boards#12
lkasso merged 1 commit into
mainfrom
scan-allow-duplicates

Conversation

@lkasso

@lkasso lkasso commented Jul 7, 2026

Copy link
Copy Markdown
Member

Release-build field report: advertising boards appeared in Nearby for ~20 s, vanished, and never returned until the scan restarted.

Root cause: scanForPeripherals ran without CBCentralManagerScanOptionAllowDuplicatesKey, so iOS delivers each peripheral once per scan session. advertisementLastSeen froze 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 (@Observable treats same-value writes as mutations); advertisementLastSeen updates 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

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>
@lkasso lkasso merged commit 567455a into main Jul 7, 2026
5 checks passed
@lkasso lkasso deleted the scan-allow-duplicates branch July 7, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant