-
Notifications
You must be signed in to change notification settings - Fork 697
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
UWP apps freeze for few seconds when system theme/accent color changes #3536
Comments
I don't think this is a winui issue, its a system/uwp issue. @MikeHillberg or @jevansaks do you think there is anything we can do from our side? |
Someone would need to debug it. I recommend a WPA trace with CPU Precise events (with call stacks) to see what's causing the app to wake when it finally unblocks (which would tell us what the app is getting stuck on). I'll take a trace now and see if anything jumps out at me. |
I got a trace of the Alarms app running the stopwatch where I did a theme change and I saw that the stopwatch stopped updating for ~2 seconds so that showed that the UI thread was freezing in this scenario. In WPA's CPU Precise view I see no activity for 2 seconds: So I look in there for the ready thread stacks and I see most of them being awoken here:
I wonder if it's possible to avoid Acrylic calling this IsFullScreenMode API during theme change, it seems like this API requires a synchronous call into explorer.exe and explorer.exe gets blocked a lot during theme change so that's going to cause our call to get blocked. |
Oh ... hmm ... so it's because we're switching AcrylicBrush instances between Light and Dark theme which is causing the OnConnected call to be made and the AcrylicBrush needs to discover that state from scratch. But I still think we can probably watch for and cache the IsFullScreenMode flag in MaterialHelper instead of calling it each time an AcrylicBrush gets connected for the first time. |
Hi @jevansaks, thanks for looking into this! |
Is your app one that I can install myself? Can you share it? |
Absolutely, here you go: https://www.microsoft.com/en-us/p/unigram-a-telegram-universal-experience/9n97zckpd60q |
@FrayxRulez I don't have a Telegram login ... is there a way to skip it and still see your main UI with the theme change animation? |
Currently it is possible to switch to test servers only after the first login, but if you need so, I can add a toggle to switch earlier. |
Hi @jevansaks, if you update to version 5741 you can login this way:
|
Thanks, @FrayxRulez ! Actually the background of NavigationView's pane is Acrylic. I confirmed that it's there by setting a breakpoint on MIcrosoft.UI.Xaml!AcrylicBrush::OnConnected and seeing that it fires on theme change, so I suspect my fix will help you too. |
... I'm sorry, being it collapsed most of the time I completely forgot about it. |
I confirmed that my change fixes the issue for Alarms so can you try out the latest CI build? Here's the nupkg from the CI: https://dev.azure.com/ms/_apis/resources/Containers/7941289/drop?itemPath=drop%2FMicrosoft.UI.Xaml.2.5.0-ci.201109002.nupkg |
It seems that I'm not authorized to access the page |
Actually, I just tried and I see absolutely no difference using debug configuration :( |
Thanks for trying it! Would you be able to share out (just attached to the comment in github) the appx for me to side-load? Or if you don't want to share broadly, you can email me or DM me on Twitter. |
@FrayxRulez I'll also need the public key cert it was signed with, I can't install that bundle without it! |
Thanks, that made it work. So on my machine this makes the theme change instantaneous (once your app gets the notification), whereas before I was seeing the Unigram app get the theme change notification but then be blocked. I don't see the app freeze anymore. But I do notice that each window seems to change one at a time, so I wonder if the problem is that on your machine there's an app that's running that is blocking the notification from getting to your window right away? Try closing all other apps and see if that helps? (Or run in Windows Sandbox) |
Hi @jevansaks sorry for the late reply. |
What do you mean by "frozen"? Like you can't move the window or you can't click inside it or what? |
All of them so far, I get west-est resize cursor and clicks get processed after the freeze |
I'm about to go on vacation so I won't have time to help on this for at least a couple of weeks. Anyone else should be able to do the same kind of investigation I did (see above comment about using WPR to record the scenario and WPA to investigate). Use the CPU Precise view and filter to your process. The "ready thread" stack after the app unfreezes will tell you where it was stuck before that. |
This repros everywhere, even in a vm, and is well known, so not sure why you need traces from us? |
@riverar Are you talking about (1) a specific app with a dynamic setting to change its own theme hanging or (2) are you talking about the whole system hanging when you change the theme in Settings? If (1), the only issue I saw was the one I fixed. If (2), please file an issue in Feedback Hub since that's an OS issue and not a WinUI one. |
@jevansaks Windows 10 grinds to a halt when changing theme. I suspect that's the underlying issue that @FrayxRulez is referring to here. Agree though, this is more of an OS issue than anything MUX related. It's not very productive to even talk about theme change performance relative to the app when the entire system is locked up. |
I think we got distracted by the discussion in this thread about the hang that repros when the app changes its own theme. We addressed that. But the remaining issue needs to be filed as a Feedback Hub report. @riverar can you do that and link the feedback URL? I will help it find the right home. |
I'm seeing this behavior on Windows 11 Pro / 21H2 / 22000.856. I had a background slideshow enabled with images switched every 1 minute. I also had "Accent color" set to "Automatic", and both "Show accent color on Start and taskbar" and "Show accent color on title bars and windows borders" enabled. What happened, is, every minute, following happened:
This is on brand new DELL XPS 19 9520 running 12th Gen Intel(R) Core(TM) i9-12900HK. Neither Windows Update not Dell Command showed any updates pending, from I'm assuming I had everything "latest". The issue stopped appearing after I switched the "Accent color" setting to "Manual" and turned off "Show accent color on Start and taskbar" and "Show accent color on title bars and windows borders". |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Describe the bug
All UWP apps seem to be affected by this bug, some of them less (I guess simpler UI tree) and some more.
Whenever the system theme changes, the apps will freeze for few seconds (1-5?).
Something interesting that we found out while researching about this behavior:
RequestedTheme
inApp
.RequestedTheme
from code behind is instant, and it works so nicely that I've added animations for that:Steps to reproduce the bug
Steps to reproduce the behavior:
Expected behavior
The app won't freeze, and the user can continue to interact with it. This is specially important if they have automatic theme/accent color switch based on current system wallpaper, and they have a wallpaper playlist enabled.
Screenshots
Version Info
The text was updated successfully, but these errors were encountered: