Open Dealman opened 5 months ago
Could you please share a simple app that reproduces the issue? Also which version of Windows?
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.
https://github.com/dotMorten/WinUIEx/assets/7038067/a87b4df6-a1aa-4c8c-9887-1155833950f2
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 https://github.com/microsoft/WindowsAppSDK/issues/4068
Very interesting, since there can potentially be more than one of these windows I'm now adding their references to a List
and potentially a Dictionary
in the future. Hasn't closed on me yet, the transparency however is very reproducible by just resizing it for a while.
When my window does this however it doesn't affect any other windows. Only the window I'm resizing.
Tried doing some more testing;
Desktop Window Manager
does restore some level of transparency, but they're still glitchy.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: https://github.com/microsoft/microsoft-ui-xaml/issues/8423 It was fixed in the latest 1.5exp2. Perhaps you could confirm with that version whether you still see it?
I tried updating it and sadly, no difference. I also tried disabling the SystemBackdrop
on my main window but the issue persists. I've also updated my GPU drivers to the latest.
Guess maybe I should post my findings as an issue over there instead?
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.
@dotMorten - Not quite. You are creating a new brush for clearing the background on each call.
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 :-)
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.