Skip to content

[Refactor] Migrate to official Flutter multi-window support #85

@mikai233

Description

@mikai233

[Refactor] Migrate to official Flutter multi-window support and replace desktop_multi_window

Pre-flight checks

  • I searched existing issues for duplicates.
  • This is not a general support question.

Problem statement

The current multi-window implementation relies on the desktop_multi_window plugin, which presents several significant challenges:

  1. 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.
  2. Multi-Engine Overhead: desktop_multi_window spawns a full Flutter Engine for every window. This is resource-intensive.
  3. 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.
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions