Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windowManager.destroy() takes several seconds to complete with Flutter 3.24.0 #478

Open
TomKrauss opened this issue Aug 9, 2024 · 9 comments

Comments

@TomKrauss
Copy link

We use windowManager.destroy() in our application to shut down. This worked smoothly in the past and now with the upgrade to Flutter 3.24.0 it takes several seconds to complete and to finally shutdown the application.

Tested on Windows.

@li9chuan
Copy link

li9chuan commented Aug 9, 2024

I've encountered the same issue. The windowManager.destroy() method is taking several seconds to complete the shutdown process after upgrading to Flutter 3.24.0 on Windows. Previously, it worked smoothly and completed much faster.

@azlekov
Copy link

azlekov commented Aug 14, 2024

Same issue!
Any workaround or how you approach this guys @TomKrauss, @li9chuan?

@TomKrauss
Copy link
Author

Unfortunately no.

@li9chuan
Copy link

The Flutter version has been rolled back to 3.22.3, and window_manager has also been downgraded to 0.3.9 because of issue 483.
@azlekov

@WinXaito
Copy link

Same issue! Any workaround or how you approach this guys @TomKrauss, @li9chuan?

@azlekov I encoutered the same problem. For the moment, I added exit(0); after calling await windowManager.destroy();

So, like that the function onWindowClose() is still called and completed, and with the exit(0);, the app is instantly closed after. Maybe not the best solution, but I didn't encoure any problem at this time.

@override
void onWindowClose() async {
  bool isPreventClose = await windowManager.isPreventClose();
  if (isPreventClose) {
    // ... disposing all my componenents, upgrade prefs, etc.

    // Close app
    await windowManager.destroy();
    exit(0);
  }
}

@AminBhst
Copy link

AminBhst commented Oct 18, 2024

Rolling back Flutter to 3.22.3 and window_manager to 0.3.9 fixes the issue on development runs but the issue still persists for release builds. I also added the exit(0); and it didn't work. Any ideas?

@WinXaito
Copy link

@AminBhst

Rolling back Flutter to 3.22.3 and window_manager to 0.3.9 fixes the issue on development runs but the issue still persists for release builds. I also added the exit(0); and it didn't work. Any ideas?

I had the same problem. The dll window_manager_plugin.dll is not correctly updated. So, you can remove the DLL (folder build\windows\x64\runner\Release or do a flutter clean and build your app again. This should work. (So you can use flutter 3.24 with window_manager 0.3.9 with the exit(0); and it should work fine.

@AminBhst
Copy link

@AminBhst

Rolling back Flutter to 3.22.3 and window_manager to 0.3.9 fixes the issue on development runs but the issue still persists for release builds. I also added the exit(0); and it didn't work. Any ideas?

I had the same problem. The dll window_manager_plugin.dll is not correctly updated. So, you can remove the DLL (folder build\windows\x64\runner\Release or do a flutter clean and build your app again. This should work. (So you can use flutter 3.24 with window_manager 0.3.9 with the exit(0); and it should work fine.

Thank you. I did try a flutter clean as well but to no avail. Starting to give up on this lol

@7Eltantawy
Copy link

#502 I have tried this and it works well for me.

  @override
  Future onWindowClose() async {
    final bool isPreventClose = await windowManager.isPreventClose();
    if (!isPreventClose) return;
    if (!mounted) return;

    final result = await showAskExitDialog(context);
    if (result == null || !result) return;

    await windowManager.setPreventClose(false);
    await windowManager.close();
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants