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>
Auto-show:
- Navigation initState now subscribes to core.connection.connectionStream
when the persisted overlay_enabled flag is true. The first connected
smart trainer with a FitnessBikeDefinition triggers
TrainerOverlayService.show(...) with the persisted overlay fields.
- Subscription is one-shot (cancels itself after a successful show) and
also checks already-connected devices on mount, so the overlay reopens
whether the trainer was reconnected before or after Navigation mounted.
Debug-log cleanup:
- Removed the `bikecontrol_dart_alive.log` liveness probe, the
`[main:entry]` / `[main:entry/stderr]` print + stderr.writeln, the
`[overlay-main]` step-by-step logs in the sub-window dispatch, the
`[main:wm-spy]` channel-handler wrapper, the `[overlay-run]` /
`[overlay-sub]` action logs in desktop_overlay_window, the
`[overlay-main]` action-receive / dispatch-fail logs in
desktop_overlay_controller, the `[main]` Android handler-retry logs,
and the noisy `[multi_window_native] CreateNewWindow` cerr in the
Windows runner.
- Kept catch handlers as silent (or kDebugMode-guarded) where the
original error path was still useful.
Also: MainFlutterWindow simplified back to NSWindow — the vendored
multi_window_native plugin now creates the overlay sub-window as an
NSPanel with .screenSaver level + .fullScreenAuxiliary itself, so
the main window no longer needs the canBecomeMain/canBecomeKey
NSPanel overrides or the .normal level pin.
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>
`.statusBar` (level 25) plus `.fullScreenAuxiliary` wasn't enough to
keep the trainer overlay above fullscreened trainer apps. `.screenSaver`
(1000) is the highest standard user-space window level and reliably
sits above ordinary fullscreen NSWindow content.
The collection behaviour (canJoinAllSpaces + fullScreenAuxiliary +
stationary + ignoresCycle) is unchanged — the level was the missing
piece.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
User reported the trainer overlay sub-window only appeared after
minimising and restoring the main window, and that it still wasn't
above fullscreened trainer apps. Both rooted in stacking:
- `NSPanel`'s default window level can be `.floating` (3) depending on
style mask, which sits above the sub-window we just elevated to
`.statusBar` (25)... unless the OS re-stacks. Pin self.level to
`.normal` (0) so .statusBar unambiguously wins.
- `window.level = ...` doesn't re-stack the window inside its new level
group. Without an explicit `orderFront(nil)`, the sub-window stays
visually behind the main panel until something forces a restack
(which is what minimising + restoring did). Order it to the front
right after the level change.
Also logs via NSLog whether elevation found the sub-window so we can
confirm next test.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two macOS regressions reported by the user:
- Initial sub-window size way too large. multi_window_native's macOS
plugin hard-codes the sub-window at 1000x1000 with minSize 800x900
(see plugin source createNewWindow ~line 148). Override from Dart
in `_runOverlay`: setMinimumSize(180, 100) then setSize(220, 140).
- Overlay no longer appears above fullscreened trainer apps. The
plugin fires `onEngineCreatedCallback` BEFORE it creates the
NSWindow + sets its contentViewController, so our previous single
`DispatchQueue.main.async { ... }` raced the plugin's own setup and
found nothing in NSApp.windows. Retry up to 30 times (0.1s apart)
until the window with our `engine` appears, then apply
`.statusBar` level + `.fullScreenAuxiliary` collection behaviour.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When MainFlutterWindow was changed from NSWindow to NSPanel, the panel
inherited NSPanel's defaults of canBecomeMain=false and canBecomeKey=false
(designed for utility palettes). As a result, NSApp.mainWindow stayed nil.
multi_window_native's macOS plugin registers the main app's messenger by
looking up `NSApp.mainWindow` in its register(with:) hook (plugin source
line 24). With nil, main's messenger never enters the plugin's static
broadcast list, so secondary-window broadcasts (button taps from the
trainer overlay) fan out to a list that doesn't include main. The Dart
listener on main never fires.
Override canBecomeMain and canBecomeKey so the panel participates as the
app's main window.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop desktop_multi_window entirely; unify macOS + Windows on
multi_window_native. Windows runner re-gets the CreateNewWindow /
CloseWindow / SetMainWindowMethodHandler plumbing with selective
sub-engine registration (only WindowManagerPlugin +
MultiWindowNativePlugin) to avoid the deadlock caused by full
RegisterPlugins on secondary engines. macOS MainFlutterWindow narrows
onEngineCreatedCallback from RegisterGeneratedPlugins to the same two
plugins for consistency.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drops desktop_multi_window 0.3.0 in favour of multi_window_native 1.0.4
on a new branch (feature/trainer-overlay-multi-window-native).
Mechanism is different but the responsibilities map cleanly:
- `MultiWindowNative.createWindow([routeName, argsJson, theme])` spawns
the sub-window; main() detects it via the first arg.
- Communication is broadcast by method name through
`notifyAllWindows` + `registerListener`. Conventions:
main → overlay: trainerOverlay.state
overlay → main: trainerOverlay.action / ready / positionChanged
Each side filters by method name; the API has no per-window targeting.
- The overlay window grabs its windowId via `windowManager.getId()` and
broadcasts `trainerOverlay.ready` so the controller can later close it.
- `notifyUiRendered()` is called after the first frame, per the package's
black-screen workaround on macOS/Windows.
Native shims:
- macOS MainFlutterWindow.swift: re-register plugins on every new
sub-engine via `MultiWindowNativePlugin.onEngineCreatedCallback`. Kept
the `.statusBar` / `.fullScreenAuxiliary` elevation for visibility
above fullscreened trainer apps; the callback now finds the new
sub-window's NSWindow by matching the FlutterViewController's engine.
- Windows flutter_window.cpp: reverted the desktop_multi_window callback;
multi_window_native's Windows wiring requires a more invasive
flutter_window.h / cpp change (SetOnCloseCallback, GetFlutterViewController,
callback registration in main.cpp) which is TBD. The overlay is only
verified on macOS in this branch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
window_manager's setVisibleOnAllWorkspaces+visibleOnFullScreen sets the
right collection-behavior bits but leaves the window at the default
(.normal) level, which Zwift / MyWhoosh on their own fullscreen Space
sit above. Set the sub-window's NSWindow.level to .statusBar and add
.fullScreenAuxiliary + .canJoinAllSpaces + .stationary collection
behavior so it floats above the fullscreen app and stays put across
Space switches.
Done in setOnWindowCreatedCallback (dispatched async since
controller.view.window is nil until the view is hosted), affecting only
sub-windows (currently only the trainer overlay).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add desktop_multi_window ^0.3.0 alongside window_manager. Update
macos/Runner/MainFlutterWindow.swift with the FlutterMultiWindowPlugin
window-created callback so sub-window engines register all generated
plugins automatically. Also includes flutter pub get generated changes to
linux/windows/macos plugin registrants.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>