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

[Important] [Windows] Distortion of window while starting up #464

Open
KRTirtho opened this issue Jun 5, 2024 · 10 comments
Open

[Important] [Windows] Distortion of window while starting up #464

KRTirtho opened this issue Jun 5, 2024 · 10 comments

Comments

@KRTirtho
Copy link

KRTirtho commented Jun 5, 2024

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
image

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: KRTirtho/spotube#1553

Thanks for your amazing work and the plugin @lijy91 ❤️
Please fix this as soon as possible. Lots of users are affected by it.

@KRTirtho
Copy link
Author

KRTirtho commented Jun 5, 2024

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

@Linij
Copy link

Linij commented Jul 21, 2024

image
image
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。

@KRTirtho
Copy link
Author

I tried your fix but the issue comes back after opening the app 2/3 times.

@KRTirtho
Copy link
Author

KRTirtho commented Jul 26, 2024

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

@Linij
Copy link

Linij commented Jul 26, 2024

OK,I will try this. Thinks.

@Linij
Copy link

Linij commented Jul 28, 2024

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),
          );
        });
      });
    });  

@maznnwell
Copy link

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.

@KRTirtho
Copy link
Author

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.

@leeys0207
Copy link

leeys0207 commented Oct 26, 2024

I found a hacky solution.

  @override
  void initState() {
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
      await windowManager.maximize();
      await windowManager.unmaximize();
    });
    super.initState();
  }

@Xazin
Copy link

Xazin commented Nov 7, 2024

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.

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

5 participants