[WinUI][dotnet8] - New window blinks when loading a content.
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
NuGet package version
None
Windows version
No response
Additional context
No response
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.
Same issue here. This is a breaking change, and it’s blocking me from updating my application.
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.
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.
Similar problems exist when using the C++ language.
I encountered the same problem in some tests I did while migrating the .NET version. Because of that, I had to pause the migration.
Here's some example using WinUI https://github.com/rodirigos/NewWindowTest There's already an example in Maui with a more appealing issue
@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.
@rodirigos You can set the RequestedTheme property of the StackPanel (the window content) to
ElementTheme.Darkif you want the window background color to be black.
Yes, the window background was black and behavior is the same, but less visible.
@rodirigos You can set the RequestedTheme property of the StackPanel (the window content) to
ElementTheme.Darkif 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.
@rodirigos You can set the RequestedTheme property of the StackPanel (the window content) to
ElementTheme.Darkif 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, ...) :
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.
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 withDispatcherQueue.TryEnqueuemight 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: https://github.com/dotnet/maui/issues/26849#issuecomment-2566178140
https://github.com/microsoft/microsoft-ui-xaml/issues/10259#issuecomment-2564163096
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 withDispatcherQueue.TryEnqueuemight 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)
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.
Any update about this issue?
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?
Hi team, is there any update on this issue? We’re currently blocked from upgrading our app to the latest .NET version due to this problem. Unfortunately, we’re stuck on an unsupported version with thousands of clients in production, and it’s becoming increasingly critical. Resolving this would allow us to ensure better support and stability for our users. Any guidance or progress on this would be greatly appreciated.
Any update about this issue?
Hi guys, .net Maui team, at issue Maui Issue said the issue is on WinUi and tell us to get some help in this issue, could you help us?
This issue is blocking our app with 1k+ users to upgrade to .net 8 and forcing us to run in .net 7 (out of support).
This looks very similar to MSFT:53079949 internally. That internal thread is a little more narrow - seems like there's a single frame when SW_SHOW'ing a window where the background of the HWND is black, before any xmal gets painted into it.
Maybe the two are different root causes, but they do feel similar.
@zadjii-msft is there any workaround to avoid this behavior?
Hi @rodirigos , can you please us by providing the repro project, so that to help us in further investigation here?
Hi. The project can be found in this link https://github.com/rodirigos/NewWindowTest I suggest to take a look on MAUI since the issue is more appealing in that plataform,
By making the windows layered (alpha 0 then 255 on first CompositionTarget.Rendering frame, it is better :
Hey do you have any static fonction to make this please ? This seems to be enough for most apps. Even AI struggles to make as functional as your video.
By making the windows layered (alpha 0 then 255 on first CompositionTarget.Rendering frame, it is better :
Hey do you have any static fonction to make this please ? This seems to be enough for most apps. Even AI struggles to make as functional as your video.
In fact, I just tested again, but when I create bigger windows than in the GIF, the blinking can still be seen 🤔 So it seems better, but not a good solution...