[Refactor] Migrate to official Flutter multi-window support and replace desktop_multi_window
Pre-flight checks
Problem statement
The current multi-window implementation relies on the desktop_multi_window plugin, which presents several significant challenges:
- Linux Instability: The plugin causes crashes on Linux (likely due to EGL/GLX context issues with multiple engines), forcing the project to disable multi-window support on that platform.
- Multi-Engine Overhead:
desktop_multi_window spawns a full Flutter Engine for every window. This is resource-intensive.
- Storage/Hive File Locking: Because each engine runs in a separate process/thread context, Hive's file-based locking prevents multiple windows from accessing the same database. This forces a complex architecture where only the main window has DB access, and others must use a memory-cached "remote" storage that syncs via method channels.
- Complex Data Sync: Synchronizing state (settings, emulator state, etc.) between multiple engines is error-prone and requires significant boilerplate code (see
app_storage.dart and app_data_sync.dart).
Proposed solution
Refactor the multi-window logic to use official Flutter Multi-View / Multi-Window support once it matures (expected targeted focus in 2026).
Planned Changes
- Remove
desktop_multi_window: Deprecate and eventually remove the third-party plugin.
- Unified Flutter Engine: Leverage Flutter's native multi-view architecture which allows multiple windows to share a single Flutter Engine.
- Simplify Persistence: Revert to a unified Hive storage model where all "views" can safely access the same data context without multi-engine locking issues.
- Unified State Management: Simplify Riverpod/State management as all windows will share the same Dart isolate.
Alternatives considered
- Stick with
desktop_multi_window and try to fix Linux stability (unlikely to be worth the effort compared to waiting for first-party support).
- Use a different multi-engine IPC solution (doesn't solve the memory overhead or the fundamental multi-engine complexity).
Scope
- Frontend (Flutter)
- Build / CI / tooling
Additional context
- Official Flutter Tracking Issue: Flutter Multi-Window / Multi-View Support #142845
- Relevant Labels:
topic: multi-window, a: desktop
- Current affected files:
lib/platform/desktop_window_manager.dart
lib/persistence/app_storage.dart
lib/windows/app_data_sync.dart
[Refactor] Migrate to official Flutter multi-window support and replace desktop_multi_window
Pre-flight checks
Problem statement
The current multi-window implementation relies on the
desktop_multi_windowplugin, which presents several significant challenges:desktop_multi_windowspawns a full Flutter Engine for every window. This is resource-intensive.app_storage.dartandapp_data_sync.dart).Proposed solution
Refactor the multi-window logic to use official Flutter Multi-View / Multi-Window support once it matures (expected targeted focus in 2026).
Planned Changes
desktop_multi_window: Deprecate and eventually remove the third-party plugin.Alternatives considered
desktop_multi_windowand try to fix Linux stability (unlikely to be worth the effort compared to waiting for first-party support).Scope
Additional context
topic: multi-window,a: desktoplib/platform/desktop_window_manager.dartlib/persistence/app_storage.dartlib/windows/app_data_sync.dart