iNKORE-NET / UI.WPF.Modern

Modern (Fluent 2) styles and controls for your WPF applications
https://docs.inkore.net/ui-wpf-modern
GNU Lesser General Public License v2.1
332 stars 29 forks source link

UI stops rendering #7

Closed Valkirie closed 11 months ago

Valkirie commented 1 year ago

My application has a window that is never closed but only Hidden/Shown and from time to time it'll stop rendering. I'm able to "fix" the issue by force rendering this specific window with the below, at the cost of slow rendering over CPU.

protected override void OnSourceInitialized(EventArgs e)
{
    WindowInteropHelper helper = new WindowInteropHelper(this);
    HwndSource hwndSource = HwndSource.FromHwnd(helper.EnsureHandle());

    // workaround: fix the stalled UI rendering, at the cost of forcing the window to render over CPU at 30fps
    if (hwndSource != null)
    {
        // hwndSource.CompositionTarget.RenderMode = RenderMode.Default;
        hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly;
    }

    base.OnSourceInitialized(e);
}

Issue seams to be known across the internet: https://github.com/dotnet-campus/wpf-issues/tree/master/BitmapCache

After digging around, I found the cause in a new Style that was using a BitmapCacheBrush with a BitmapCache.

With issue

image

Expected

image

NotYoojun commented 1 year ago

Ok, thanks for reporting. recently im trying to find a way to fix it..

NotYoojun commented 1 year ago

Hi! I tried a lot, but this issue didnt happen on my computer. so sorry and i have no idea how to fix it. I need help ๐Ÿ˜จ๐Ÿ˜ญ๐Ÿ˜ข

Valkirie commented 1 year ago

Hi! I tried a lot, but this issue didnt happen on my computer. so sorry and i have no idea how to fix it. I need help ๐Ÿ˜จ๐Ÿ˜ญ๐Ÿ˜ข

Interesting. I had the feeling it was vendor specific : AMD. But am not sure. It was mainly triggered by switching apps and going from and into games.

NotYoojun commented 1 year ago

That sucks. Both my CPU and graphics card are made by Intel. So sorry that I can't handle this bug. ๐Ÿ˜ž

NotYoojun commented 11 months ago

I tried a lot, but still unable to solve this. Sorry for that. ๐Ÿ˜ฎโ€๐Ÿ’จ๐Ÿ˜ž

NotYoojun commented 11 months ago

Sorry i cant fix this. so im afraid that i have to close this issue. if anyone finds a way to fix this, pls reopen and create a pull request. thanks :(