[Important] [Windows] Distortion of window while starting up
After upgrading to Flutter 3.22.1, Window manager is causing the entire UI to be glitched out (distorted) initially after launch.
This is how it looks
If I turn off/comment out windowManager.ensureInitialized and windowManager.waitUntilReadyToShow function calls, the app shows up completely fine except the Title bar is visible (as expected).
There are no errors/exceptions being thrown at the Console. So, I guess this is caused any embedder change in Flutter engine?
Reverting back to Flutter 3.19.x fixes the issue though
Upstream issue: https://github.com/KRTirtho/spotube/issues/1553
Thanks for your amazing work and the plugin @lijy91 ❤️ Please fix this as soon as possible. Lots of users are affected by it.
There were lots of changes in the Windows embeder EGL which probably lead to this kind of issues. Special focus: https://docs.flutter.dev/release/release-notes/release-notes-3.22.0#desktop
I encountered the same problem, but I found a solution that requires modifying the size in the main.cpp default file to be the same as the set minimum value to fix it。
I tried your fix but the issue comes back after opening the app 2/3 times.
There's a workaround suggested by Far Se on Flutter Discord that allows to use Flutter v3.22.x with window_manager in Windows
WidgetsBinding.instance.addPostFrameCallback((Duration timeStamp) async {
if (Theme.of(context).platform != TargetPlatform.windows) return;
await Future<void>.delayed(const Duration(milliseconds: 100), () {
windowManager.getSize().then((Size value) {
windowManager.setSize(
Size(value.width + 1, value.height + 1),
);
});
});
});
Add following in the root App's (the very first widget where MaterialApp or CupertinoApp gets returned) initState method
OK,I will try this. Thinks.
This method is feasible, but I think it may be better。
WidgetsBinding.instance.addPostFrameCallback((Duration timeStamp) async {
if (Theme.of(context).platform != TargetPlatform.windows) return;
await Future<void>.delayed(const Duration(milliseconds: 100), () {
windowManager.getSize().then((Size value) {
windowManager.setSize(
Size(value.width + 1, value.height + 1),
);
windowManager.setSize(
Size(value.width, value.height),
);
});
});
});
I also encountered this issue, but the suggested solution didn't worked for me - on Flutter 3.24.3.
Somewhere in the widget tree, after creating the MaterialApp, a Lottie was being played using a controller - but it was rendering only when it was done loading from the asset file. So I decided to have something rendering while the lottie was loading and it worked.
hey @lijy91 if you can look into this issue when you get time? Lots of users are suffering for this. I'm also not finding any clue why this might happen.
I found a hacky solution.
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
await windowManager.maximize();
await windowManager.unmaximize();
});
super.initState();
}
We also have this issue in AppFlowy, we ended up switching to bitsdojo on windows rather than window_manager.
I want to switch back, but the workarounds are hacky (and not usable for all cases) and ends up with a bad user experience.
On Spotube's case, both window_managerand bitsdojo_window are having the same issue. How well does bitsdojo_window work for AppFlowy?
On Spotube's case, both
window_managerandbitsdojo_windoware having the same issue. How well doesbitsdojo_windowwork for AppFlowy?
It has the same issue, but seems to happen less frequently, not really anything I can prove though.
We prefer window_manager though, but we don't have the expertise to resolve this issue on the native front, nor the manpower atm.