Skip to content

[desktop_multi_window] Closing window does not free resources, when plugin is used together with window_manager #293

@thomasgi1

Description

@thomasgi1

When the desktop_multi_window plugin is used in combination with the window_manager plugin on MacOS, then resources are not freed, when closing a window. The reason for that is the FlutterWindow extension:

extension FlutterWindow: NSWindowDelegate {
  func windowWillClose(_ notification: Notification) {
    delegate?.onClose(windowId: windowId)
  }

  func windowShouldClose(_ sender: NSWindow) -> Bool {
    delegate?.onClose(windowId: windowId)
    return true
  }
}

which overrides the windowWillClose and windowShouldClose members. However, the window_manager plugin does the same by extending the NSWindowDelegate protocol. Since extensions cannot replace existing implementations the FlutterWindow extension has no effect, so that the delegate?.onClose() function never gets called leaving the whole isolate responsible for the closed window im memory.

Version:

  • Flutter Version: 3.13.6
  • OS: macOS 12.7
  • plugin: desktop_multi_window 0.2.0 + window_manager 0.3.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions