-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Transparent Window Randomly Losing Transperancy #156
Comments
Could you please share a simple app that reproduces the issue? |
Sure, here's a simple one setup via Template Studio. It was too big to upload directly via GitHub. It seems to be mostly reproducible when resizing via the lower right corner, unless it's just a weird coincidence. The window may also randomly close whilst resizing. I'm on Windows 11 Pro - Version 10.0.22631 Build 22631 Edit: I grabbed a quick video to help showcase how I get the issue to occur. Bug.mp4 |
I was able to reproduce the closing of the window. I never saw the transparency disappear, but did observe closing. No message/error was sent. To track what's going on, I added this to overlay window: this.Closed += OverlayWindow_Closed;
this.AppWindow.Closing += AppWindow_Closing;
this.AppWindow.Destroying += AppWindow_Destroying;
}
private void AppWindow_Destroying(Microsoft.UI.Windowing.AppWindow sender, object args)
{
}
private void AppWindow_Closing(Microsoft.UI.Windowing.AppWindow sender, Microsoft.UI.Windowing.AppWindowClosingEventArgs args)
{
}
private void OverlayWindow_Closed(object sender, WindowEventArgs args)
{
} Then the problem went away, which led me to believe this is WinAppSDK issue with references getting lost. So in MainPage.xaml.cs I created a variable to hold a reference to the Overlay window instead of just declaring a local reference to it in your click handler, and again problem went away, confirming you found an interesting C#WinRT issue, and not a WinUIEx issue. Again I haven't been able to repro your transparency issue, but I do wonder if it also gets addressed by keeping a reference to the window? |
I do wonder if you're hitting this issue that's been an issue on Windows for YEARS microsoft/WindowsAppSDK#4068 |
Very interesting, since there can potentially be more than one of these windows I'm now adding their references to a When my window does this however it doesn't affect any other windows. Only the window I'm resizing. Tried doing some more testing;
I'm guessing some SDK version differences between us if you can't reproduce it? Unless it's hardware/driver related. |
most likely hardware related. We're using the same version since I'm using your project to repro. I'm closing this out since this doesn't seem to be caused by WinUIEx itself - all the transparency rendering and maintaining it is handled by WinUI. |
Could also be this: microsoft/microsoft-ui-xaml#8423 |
I tried updating it and sadly, no difference. I also tried disabling the Guess maybe I should post my findings as an issue over there instead? |
@dotMorten - Not quite. You are creating a new brush for clearing the background on each call. WinUIEx/src/WinUIEx/TransparentTintBackdrop.cs Lines 103 to 112 in a830af7
This simply hits a limit at some point and then you cannot create any more new brushes - then the transparency gets lost. To reproduce, you just need to move the window around for a while and be a bit patient, then it will happen. You should create the brush once and cache it. On dispose, pinvoke DeleteObject, etc.. |
@softworkz Nice find. Not sure what I was thinking there :-) |
In my case it's usually "first, try whether it works and do it right later". And then forget about it... ;-) |
This is mostly reproducible when moving a window around close to the edges of a monitor, or when resizing a lot/quickly.
These windows are usually a green tint, but if I resize them quickly with my mouse they will bug out like this and only a restart seems to fix it.
Not quite sure how to debug and potentially fix this.
This is the window style I use;
The intended purpose is for the windows to be used as a sort of overlay and this styling disable the horrendously annoying aero snapping.
The text was updated successfully, but these errors were encountered: