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>
- Ignore toggles during the transient starting/stopping states (in-flight
guard) so a double-press can't double-start or stop-during-start.
- macOS: reset the recorder handle when start() throws, so one failure no
longer permanently blocks recording (only stop() nilled it before).
- iOS: remove the broadcast picker view after triggering so a 1x1 view doesn't
accumulate on the key window on every start.
- Report failures via recordError (was debugPrintStack, which vanishes in
release builds). Adds an in-flight-toggle guard test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
WGC/D3D surfaces are top-down, but the MF SinkWriter's RGB32->NV12
conversion treats uncompressed RGB as bottom-up, so feeding our top-down
buffer through produced a vertically-flipped (upside-down) recording.
Cancel the fixed flip by writing each source row into the mirrored
destination row, handing MF a bottom-up buffer. Same number of memcpys,
no extra cost.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The interop interface lives in the ABI namespace
::Windows::Graphics::DirectX::Direct3D11, not the winrt projection
namespace pulled in via `using namespace`. The bare name was undeclared
(C2065), cascading into C2672 and C3536. Fully qualify it (with leading
:: so `using namespace winrt;` doesn't misroute it).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Root cause for "buttons don't work / window won't close, but ONLY for
the auto-opened overlay" was timing inside the vendored plugin's
register(with:):
if let mainFlutterWindow = NSApp.mainWindow, ... {
let messenger = controller.engine.binaryMessenger
messengers.append(messenger)
}
For the MAIN engine, `register(with:)` runs from
`MainFlutterWindow.awakeFromNib` — BEFORE the window is shown and
promoted to NSApp.mainWindow. The guard fails, main's messenger is
never appended to the static broadcast list, and any sub-window
broadcasting back through `notifyAllWindows` only echoes to itself.
The bug stayed hidden when the overlay was opened manually from the
settings page (the user did this minutes after launch, so by the time
the SUB engine register fired it could read NSApp.mainWindow and
add main's messenger as a side effect). It surfaced the moment we
added auto-show — BLE reconnects fast on a paired trainer, so the
sub-engine register fires while NSApp.mainWindow is still being set up.
Fix the register to append `registrar.messenger` directly (the
registrar already gives you exactly the right messenger for the
engine being registered), guarded by a contains-check to stay
idempotent. The NSApp.mainWindow path now only wires the window
delegate when it does happen to be set.
Also: `registerMessenger` no longer short-circuits when the
messenger is already in the list — it still calls
`setupChannelHandler` so the per-controller closure that handles
`notifyUiReady` -> `makeKeyAndOrderFront(nil)` is wired for the
sub-window. Skipping it would leave the auto-opened sub-window
invisible because no one would bring it forward.
Plus the closeWindow handler in the same file: I had it call
`self.closeWindow(window)` for each secondary, but
`window.close()` synchronously fires the `windowWillClose`
delegate, which calls `self.closeWindow(window)` again — the inner
call removes the entry and the outer call's
`secondaryWindowControllers.remove(at: index)` crashes on a stale
index. Now it just calls `window.close()` and lets the delegate
path do the one-pass cleanup.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fixes the user-reported bugs after the auto-show landed:
1. Auto-opened overlay buttons did nothing
The trainer emulator rebinds a fresh FitnessBikeDefinition each time
its transport restarts (e.g. when a trainer app connects), so the
`def` captured at show() time can already be stale by the time the
user taps + / −. Action handlers now re-resolve through a new
`LiveDefinitionLookup` callback on every dispatch. Navigation's
auto-show and OverlaySettingsSection's manual show both pass a
lookup that reads `device.emulator.activeDefinition` live.
2. Toggling "Show overlay during ride" off didn't close the panel
The vendored macOS plugin's `closeWindow` handler ignored its args
and called `closeWindow(NSApp.mainWindow)`, which either terminated
the app or no-op'd silently. Patched it to honor
`isMainWindow: false` and close the (single) secondary window.
3. "Error in overlay.position.decode: Unexpected character: light"
The vendored macOS plugin packs the Dart entrypoint args in the
order [routeName, theme, argsJson]; the Windows runner uses
`std::map` iteration order. The sub-window was indexing `args[1]`
blindly. Now it scans `args[1..]` for the first JSON-looking
payload with `x`/`y`.
Also:
- TrainerOverlayController.show now takes optional `liveDef`; all
three implementations (desktop, android, ios) thread it through.
- Navigation initState no longer early-`return`s after auto-show, so
the post-frame system-UI / changelog logic still runs.
- All silent `catch (_) {}` blocks in the overlay code now forward
via `recordError(e, s, context: '...')`. New project memory
entry [feedback_record_error.md] documents the rule.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace [.titled, .closable, .resizable, .nonactivatingPanel,
.utilityWindow] with [.borderless, .resizable, .nonactivatingPanel].
The Flutter content fills the panel and handles dragging via
window_manager.startDragging(); a system title bar adds nothing.
Also enables isMovableByWindowBackground as a fallback drag affordance
and removes the now-redundant standardWindowButton hiding.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The trainer overlay is dismissed by toggling the setting in the
main app, not by the panel's own close button. Hide the close,
miniaturize, and zoom buttons via `standardWindowButton(...)`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous commit vendored the pub.dev 1.0.4 release. The
GitHub repo (https://github.com/Swatimishra8/multi_window_native)
is ahead of pub.dev at 1.0.5 and contains improvements that
matter for the trainer-overlay use case:
- `windowDidBecomeKey` delegate to resume Flutter's render
pipeline on focus — fixes sub-windows freezing after the
main app regains focus.
- `applicationShouldHandleReopen` for dock-icon restore.
- Delayed (0.1s) cleanup of secondary windows in `closeWindow`
so Flutter's onWindowClose callbacks finish executing.
- `generateUniqueTitle`/`registerWindowTitle`/`unregisterWindowTitle`
bridge methods.
- Native Windows implementation in the package itself
(we still use our own runner/main.cpp wiring; the package's
Windows code is unused but harmless).
Re-applied the NSPanel substitution in `createNewWindow`:
.nonactivatingPanel + .utilityWindow style, level .screenSaver,
collectionBehavior including .fullScreenAuxiliary, initial size
220x140 / minSize 160x80 — so the sub-window sits above
fullscreened trainer apps from the moment it's shown.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Forked the upstream package
(https://github.com/Swatimishra8/multi_window_native) into
packages/multi_window_native and pinned pubspec to the path dep.
Key macOS change in the vendored plugin's createNewWindow:
- NSPanel instead of NSWindow with styleMask = [.titled, .closable,
.resizable, .nonactivatingPanel, .utilityWindow].
- isFloatingPanel = true, becomesKeyOnlyIfNeeded = true,
hidesOnDeactivate = false.
- level = .screenSaver (highest standard user-space level).
- collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary,
.stationary, .ignoresCycle].
- Initial size dropped from 1440x900 / minSize 800x900 to 220x140 /
minSize 160x80 (closer to what the trainer overlay needs).
With those properties set at construction time, the sub-window sits
above fullscreened trainer apps from the moment it's shown — no more
retry loop chasing the window after the fact.
MainFlutterWindow.swift's onEngineCreatedCallback no longer needs the
elevation retry; it just calls RegisterGeneratedPlugins on the new
engine and leaves the window-level work to the plugin.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>