Files
swiftcontrol/packages/multi_window_native/macos
Jonas Acker 0f0a5be485 fix(macos): closing the gear overlay no longer crashes BikeControl later
Closing the overlay never stopped its Flutter engine: multi_window_native
cleaned up in windowWillClose, but window_manager makes itself the window's
delegate as soon as the overlay engine initialises it, so that never ran.
The engine kept running against the closed window, redrew on every state
broadcast and eventually crashed the raster thread on a null texture in
impeller::Canvas::SetupRenderPass (App Store crash, 7.2.1, macOS 26.6).

Reproduced with a release build that opens and closes the overlay in a loop
(crash after 187 cycles); with this change it ran 2000 cycles clean.

- Closing from Dart goes through closeWindow() instead of the delegate.
- The window leaves the list before close(), so a windowWillClose that does
  arrive can't re-enter close() (that recursed until the main thread's
  stack overflowed).
- The engine shuts down while its view is still attached; the view is
  released 0.5 s later. Detaching first crashed in FlutterCompositor::Present
  on a frame still queued for the removed view.
- Each overlay's messengers are tracked and removed on close. Only
  engine.binaryMessenger was removed, not the registrar messenger its
  plugins added, so broadcasts went to every overlay ever opened.
- The window is hidden again after shutdown: one closed while starting up
  could be shown again by its own window_manager call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 18:13:32 +02:00
..