Toggling the "Direct connection" card could wedge: the sheet opened for a
permission that was already granted, and then sat there, because PermissionList
only re-probes on app resume.
ConnectionMethod probed one requirement list, awaited, then re-read
`widget.requirements` on the far side of the gap:
Future.wait(widget.requirements.map((e) => e.getStatus())).then((_) async {
final notDone = widget.requirements.filter((e) => !e.status).toList();
The tiles build that list inside `build()`, so any rebuild in that window hands
back fresh objects whose mutable `status` is still false — and these tiles
rebuild on every isConnected/isStarted tick, plus onChange's own setState. The
probe result was read off objects that were never probed.
Capture the list once per operation instead. This was pre-existing and not
specific to Local Network: di2_ble_tile and openbikecontrol_ble_tile pass
getRemoteControlRequirements() the same way, so they had the same latent race.
Also hoist the requirement lists out of build() into State fields across the
five tiles, so a probed `status` is not discarded every frame.
Separately: LocalNetworkRequirement was only wired into the network tiles, so
onboarding, app start and scanning never checked it at all — every one of those
reads getScanRequirements(). Add it there for iOS and macOS. The list is
filtered to unsatisfied requirements, so it surfaces only on an actual denial.
Note for macOS: keyboard-control-only users will now see a Local Network prompt
they do not need. Accepted deliberately in favour of one list over a
platform-split.
The regression test drives the real race — gate the probe, force a rebuild
mid-flight, release — and fails with "Found 1 widget with type PermissionList"
without the capture fix.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Denial of Apple's Local Network privacy permission is the most common cause of
"BikeControl can't see my trainer app" on iOS and macOS, and it fails
completely silently: Bonjour browses return nothing forever, advertisements
never leave the device, nothing throws. An app watching only for errors cannot
tell "permission is off" from "there is nothing out there".
Apple ships no authorization-status API for it (not iOS 14...26, not macOS
15...26), so the new local_network_permission plugin measures it: an NWListener
and an NWBrowser on _bikecontrol-preflight._tcp, then
browser discovers the listener -> granted
kDNSServiceErr_PolicyDenied (-65570) -> denied
neither, before the deadline -> unknown
unknown is a real outcome, not an error — a device with no usable network never
completes the round trip even when the permission is fine — so everything fails
open on it and only a positive denial blocks the user.
The probe *is* the request: the system prompt fires on the first Bonjour
operation, so there is no separate request step, and after the user answers,
System Settings is the only way back.
- LocalNetworkAccess caches the result (probes cost a real round trip while
getStatus() runs on every tile mount, tap and resume) and collapses
concurrent probes into one, since two listeners on the same service type
would resolve each other.
- LocalNetworkRequirement gates the three LAN tiles: MyWhoosh Link, Zwift mDNS
and OpenBikeControl mDNS. Suppressed in screenshot/demo mode like the rest.
- Diagnostics drop the old guess (inferred from whether a discovery scan
returned anything, which could not tell denied from an empty LAN) for the
measured local-network=granted|denied|unknown.
- _bikecontrol-preflight._tcp added to NSBonjourServices on both platforms;
without it the browse fails for a reason unrelated to the permission.
The Xcode project deployment-target bumps (ios 13.0->15.0, macos 10.15->12.0)
are Flutter's own migration aligning project defaults with the Podfiles; they
happen on any first build.
Verified with real builds on both platforms, not just analysis: flutter build
macos --debug and flutter build ios --no-codesign both succeed, the framework
is linked in, and the preflight service type is present in both built
Info.plists. 35 tests cover the mapping, cache, concurrency and fail-open
behaviour.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Symbolicating a Rouvy user's 6.1 crashes (Shorebird patch build_id
4b7026f5fbf44e52452ba9e557c2c5a0) surfaced two "Null check operator used
on a null value" crashes: async UI callbacks running after their widget
was disposed (the user rapidly re-toggled the Zwift BLE option as
advertising kept failing).
- ZwiftTile.onChange: setState() ran after `await stopAllBleConnections`
on an unmounted state -> guard with `mounted`.
- ConnectionMethod: openPermissionSheet(context, ...) and setState() ran
after `await Future.wait(requirements)` on a defunct context -> guard
both async gaps with `context.mounted` (matching the existing guard at
line 315).
The underlying trigger (Zwift emulator "Data too large" advertise failure
on Rouvy) is tracked separately for the 6.2 branch.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>