MixinNetwork / flutter-plugins

🧱 Flutter plugins used in Mixin Messenger.
MIT License
443 stars 192 forks source link

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

Open thomasgi1 opened 1 year ago

thomasgi1 commented 1 year ago

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:

LEggcookies commented 8 months ago

I encountered the same issue.