Plugin teardown runs on the UI thread after the window is gone, and
universal_ble can block it for many seconds (waiting for a pending connect to
time out) or for good (a GATT Close that never returns). The Store health
report shows these as hangs in universal_ble_plugin.dll during
FlutterDesktopViewControllerDestroy.
When the main window closes, a watchdog ends the process if it is still alive
3 seconds later. Nothing is left to save at that point, and Windows releases
the Bluetooth handles with the process.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- After the window closes, the process can take seconds to exit:
universal_ble waits for a pending connect to a saved, absent trainer to
time out, and Windows ignores cancelling it.
- In that time a new launch found the hidden window by its "BikeControl"
title, handed off to the exiting instance and quit, so nothing opened.
- The title is cleared as the main window closes, so a relaunch starts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Alt-F4 or the close button on the main window left the overlay on screen
and the process running: nothing closed the overlay, so its engine was
only torn down after the message loop had ended, and that shutdown hangs.
- The overlay window and engine are now destroyed as the main window
closes, while the message loop still runs.
Co-Authored-By: Claude Opus 5.5 <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>
Confirmed via the [main:wm-spy] diagnostic that broadcasts from the
sub-window weren't reaching main's Dart. Root cause: two copies of
MultiWindowNativePlugin exist in the binary.
The plugin DLL (built by flutter pub get) has its own static
`messengers_` field. We also compile multi_window_native_plugin.cpp
directly into the runner so wWinMain can call
MultiWindowNativePlugin::SetCreateWindowCallback etc. — the runner
has a SECOND copy of those statics. They don't share state.
Previous flow:
- Runner's RegisterMessenger (called by SetMainWindowMethodHandler)
adds main → RUNNER's messengers_.
- Sub-engine plugin was registered via the DLL's
MultiWindowNativePluginRegisterWithRegistrar, which calls the
DLL's BroadcastToAll on broadcast → DLL's messengers_ (empty
except for the sub itself).
Fix: stop registering the DLL plugin on the sub-engine. Instead wire
the MethodChannel handler directly in CreateNewWindow — same logic
SetMainWindowMethodHandler uses on the main engine — so the sub-window's
broadcasts go through the RUNNER's copy of BroadcastToAll and iterate
the same messengers_ list that contains main.
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>
Add `desktop_multi_window: ^0.3.0` alongside `multi_window_native: ^1.0.4`.
On Windows the sub-window is now spawned via `WindowController.create` with a
JSON `role=trainer-overlay` argument (detected in `main()` before any heavy
bootstrap), and state/actions flow over `WindowMethodChannel(kOverlayChannel)`.
macOS continues using `MultiWindowNative.createWindow` / `notifyAllWindows` /
`registerListener` unchanged.
Windows runner reverts all `multi_window_native` plumbing:
`SecondaryWindowContext`, `CreateNewWindow`, `CloseWindow`,
`SetMainWindowMethodHandler`, and the plugin source compiled directly into the
runner are removed. `flutter_window.cpp` instead registers
`DesktopMultiWindowSetWindowCreatedCallback` so every sub-engine gets plugins.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Dart prints don't appear in the console for the sub-engine even though
native milestones fire correctly. Need to determine whether:
(a) Dart main() actually runs but its print/stderr output isn't
reaching the console attached to `flutter run`, or
(b) Dart main() never runs at all.
Add a roundtrip diagnostic:
- Native registers a MethodCallHandler on
`bike_control/sub_engine_ping` for the sub-engine.
- Dart main() invokes that channel as its first await.
- Native prints "[multi_window_native] sub-engine PING received" when
the call lands.
If the PING line appears: Dart IS running — the issue is print routing.
If it doesn't: Dart never starts and we have to look at engine setup.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`set_dart_entrypoint("main")` looks like a no-op but it routes the
sub-engine through the named-entry-point lookup path, which (at least
on Windows in this app) resolves to nothing — the engine reports OK,
the controller is alive, but Dart main() is never invoked. Removing
the override lets the engine use its built-in default of `main`, which
the snapshot already exposes.
Symptom this addresses: only the four native milestone prints appear
in the console after toggling the overlay
(`FlutterViewController created`, `Win32 window created`, `RegisterPlugins
done`, `SetChildContent done`), and zero output from `[main:entry]`
in Dart.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Only "CreateNewWindow with 3 arg(s)" appears in the console, no Dart
prints. That means either (a) the sub-engine never invokes Dart main(),
or (b) Dart prints from the sub-engine aren't reaching the attached
console. Add:
- print() + stderr.writeln() at the VERY TOP of main(), before anything
that could throw — confirms Dart entry-point resolution.
- std::cerr at every milestone inside CreateNewWindow — confirms the
native side gets through FlutterViewController/Win32Window/
RegisterPlugins/SetChildContent without bailing silently.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The example's CreateNewWindow creates the FlutterViewController first
(making its view HWND a top-level WS_POPUP) and then reparents it via
SetChildContent. Eagerly calling ShowWindow before the engine has
signalled its first frame means we present an unpainted surface, and
the engine can land in a "frame already presented" state where it
never repaints — matching the user's "even a flat red Container
doesn't show" symptom.
Restructure CreateNewWindow to match FlutterWindow::OnCreate exactly:
- Create the Win32 window first.
- Use the host's actual client area to size the FlutterViewController.
- Defer ShowWindow + SetForegroundWindow to SetNextFrameCallback so we
only show the window once the engine has a frame ready to display.
- ForceRedraw to nudge the engine into producing that first frame.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two issues caused the sub-window to show as "all white initially, white
box on black after resize":
- The runner's CreateNewWindow skipped FlutterWindow::OnCreate's engine
kickoff (`SetNextFrameCallback` + `ForceRedraw`). The sub-window's
engine then never spontaneously painted and stayed at its construction
metrics; a manual resize forced a paint but with the old 220x100
surface, hence the "white box that doesn't follow the window".
Replicating the same boot sequence in CreateNewWindow.
- The Scaffold background used `Theme.of(context).colorScheme.background`,
which resolves to near-white under shadcn's light theme, masking the
gear card on its near-white surface. Win32 doesn't do real transparency
without WS_EX_LAYERED anyway, so use an explicit opaque dark colour
(0xFF111114) — gives the window a clear chrome regardless of the
user's system theme.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>