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

[WinUI][dotnet8] - New window blinks when loading a content. #10259

Open
rodirigos opened this issue Dec 27, 2024 · 17 comments
Open

[WinUI][dotnet8] - New window blinks when loading a content. #10259

rodirigos opened this issue Dec 27, 2024 · 17 comments
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@rodirigos
Copy link

Describe the bug

In .NET 7, windows wait to render the content before opening. In .NET 8 and later, an unintended flicker occurs while loading this content. This flicker comes with a default background. It also occurs using MAUI.

Steps to reproduce the bug

1 - Create multiple windows with some content and an alternative background color.

Expected behavior

It should open like in dotnet7, appearing all the window with a rendered content. (not a flickering before opening).

Screenshots

Image

NuGet package version

None

Windows version

No response

Additional context

No response

@rodirigos rodirigos added the bug Something isn't working label Dec 27, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Dec 27, 2024
@danielancines
Copy link

I have a MDI large application for a Bank in .net Maui, using Pinvoke.SetParent and not able to migrate to .net 8 and 9 because of this behavior.

@lfmouradasilva
Copy link

Same issue here. This is a breaking change, and it’s blocking me from updating my application.

@fpedrolucas95
Copy link

I'm also experiencing this flickering issue in a .NET Maui desktop application. This is a significant blocker for updating to .NET 8 and 9, as it creates a poor user experience.

@Elwilton
Copy link

I’m facing the same issue. I’m trying to migrate from .NET 7 to .NET 8 and having problems with the presentation of new screens.

@lgztx96
Copy link

lgztx96 commented Dec 28, 2024

Similar problems exist when using the C++ language.
Image

@MasterOliver21
Copy link

I encountered the same problem in some tests I did while migrating the .NET version. Because of that, I had to pause the migration.

@rodirigos
Copy link
Author

rodirigos commented Dec 30, 2024

Here's some example using WinUI
https://github.com/rodirigos/NewWindowTest
There's already an example in Maui with a more appealing issue

@lhak
Copy link

lhak commented Jan 1, 2025

@rodirigos You can set the RequestedTheme property of the StackPanel (the window content) to ElementTheme.Dark if you want the window background color to be black.

@danielancines
Copy link

danielancines commented Jan 2, 2025

@rodirigos You can set the RequestedTheme property of the StackPanel (the window content) to ElementTheme.Dark if you want the window background color to be black.

Yes, the window background was black and behavior is the same, but less visible.

Image

@rodirigos
Copy link
Author

@rodirigos You can set the RequestedTheme property of the StackPanel (the window content) to ElementTheme.Dark if you want the window background color to be black.

Same behavior. Only changed the color to show the delay. As you can see in the example above, the labels inside the content still have the same issue.

@castorix
Copy link

castorix commented Jan 2, 2025

@rodirigos You can set the RequestedTheme property of the StackPanel (the window content) to ElementTheme.Dark if you want the window background color to be black.

Same behavior. Only changed the color to show the delay. As you can see in the example above, the labels inside the content still have the same issue.

I have the same problem in .NET 7.0 (Windows 10 22H2, Windows App SDK 1.6.241114003, slow PC)
Test with your sample (I just changed colors, size, ...) :

Image

@lhak
Copy link

lhak commented Jan 2, 2025

One issue here is that all windows are created and shown on the UI thread, so there is never a chance for the content to render until all windows are visible. Moving the call of window.Activate() to a low priority dispatcher call with DispatcherQueue.TryEnqueue might improve things.

However, in my experience, some delay between the window background and the XAML content showing cannot currently be avoided. I guess a fix would require more work in winui to pre-render the content before the window is visible.

@danielancines
Copy link

One issue here is that all windows are created and shown on the UI thread, so there is never a chance for the content to render until all windows are visible. Moving the call of window.Activate() to a low priority dispatcher call with DispatcherQueue.TryEnqueue might improve things.

However, in my experience, some delay between the window background and the XAML content showing cannot currently be avoided. I guess a fix would require more work in winui to pre-render the content before the window is visible.

Thanks for the advice, but the problem is that @lgztx96 described previously, one window, delay to load the content.
This behavior was noticed after update a .net Maui application to .net 8 in this issue: dotnet/maui#26849 (comment)

#10259 (comment)

@lhak
Copy link

lhak commented Jan 3, 2025

One issue here is that all windows are created and shown on the UI thread, so there is never a chance for the content to render until all windows are visible. Moving the call of window.Activate() to a low priority dispatcher call with DispatcherQueue.TryEnqueue might improve things.
However, in my experience, some delay between the window background and the XAML content showing cannot currently be avoided. I guess a fix would require more work in winui to pre-render the content before the window is visible.

Thanks for the advice, but the problem is that @lgztx96 described previously, one window, delay to load the content. This behavior was noticed after update a .net Maui application to .net 8 in this issue: dotnet/maui#26849 (comment)

#10259 (comment)

I have not noticed any major changes of this delay using different .net and winui versions. However, I can confirm that the maui version from @rodirigos is drastically slower than the winui one. So I guess the regression is caused by changes in the maui code.

@lfmouradasilva
Copy link

Hi. Any update on this?

@fpedrolucas95
Copy link

Any update about this issue?

@Elwilton
Copy link

Any update on this issue?
My team and I had to pause a migration because of this issue.
Do we have any predictions for a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

9 participants