Skip to content
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

Acrylic Blur does not work on Windows 11 #6465

Closed
trympet opened this issue Aug 25, 2021 · 30 comments · Fixed by #6574 or #7775
Closed

Acrylic Blur does not work on Windows 11 #6465

trympet opened this issue Aug 25, 2021 · 30 comments · Fixed by #6574 or #7775

Comments

@trympet
Copy link
Contributor

trympet commented Aug 25, 2021

Describe the bug
Win2d acrylic blur does not work on Windows 11 build 22000.160. This also breaks TransparencyLevel.Blur if WinUI compositor is enabled.

DWM transparency and blur works fine.

To Reproduce
Steps to reproduce the behavior:

  1. Create new project from template
  2. Set TransparencyLevelHint.AcrylicBlur on the main window.
  3. Set background to null.
  4. Run

This can also be observed in the SampleApp.

Expected behavior
The acrylic layer should not be opaque.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11 22000.160
  • Version 0.10.3; 0.10.7 (master)

Additional context
Side note: ICompositor3.CreateHostBackdropBrush() is not broken in this build of windows. ICompositor2.CreateBackdropBrush() might be though.

@trympet trympet added the bug label Aug 25, 2021
@trympet trympet changed the title AcrylicBlur does not work on Windows 11 22000.160 Acrylic Blur does not work on Windows 11 22000.160 Aug 25, 2021
@trympet trympet changed the title Acrylic Blur does not work on Windows 11 22000.160 Acrylic Blur does not work on Windows 11 Aug 25, 2021
@MarioGK
Copy link

MarioGK commented Aug 26, 2021

I tried it on my project and gives the same result, setting Background to Transparent doesnt fix it as well

@nullshii
Copy link

nullshii commented Oct 5, 2021

Background="null" just crushing application with error Invalid brush string: 'null'.

@Gillibald
Copy link
Contributor

Background="null" -> Background="{x:Null}"

@Nickelony
Copy link

Nickelony commented Nov 14, 2021

Even though this issue is closed, I still have problems on Windows 11 and Acrylic Blur / Mica effects.
On Windows 10, Acrylic Blur works perfectly fine, on Windows 11 it doesn't work at all.
Using Avalonia 0.10.10 and Windows 11 (22000.318)

Even the Avalonia Control Gallery demo doesn't seem to have working acrylic either.

@maxkatz6
Copy link
Member

@Nickelony that's pretty weird, because I used Acrylic yesterday in control catalog just yesterday on win11. On master branch.

@Orkunnnn
Copy link

Yep it is still has the issue on Windows 11 (22000.318).

@maxkatz6 maxkatz6 reopened this Nov 21, 2021
@trympet
Copy link
Contributor Author

trympet commented Nov 21, 2021

@maxkatz6 ControlCatalog works for me on 22000.318 on 32fe95a. Background is not set to AcrylicBlur by default tho, which might cause some confusion.

@DeXP
Copy link

DeXP commented Dec 16, 2021

Still does not works for me. Windows 11 Pro, 22000.376. Avalonia 0.10.10.
I downloaded https://github.com/AvaloniaUI/Avalonia.MusicStore . Build it with VS 2019 (16.11.7). No transparency.
Workaround: One call of SetWindowCompositionAttribute makes it working. Both Background="Transparent" and TransparencyLevelHint="AcrylicBlur" have to be set. I use the same code as here: https://github.com/riverar/sample-win32-acrylicblur/

@maxkatz6
Copy link
Member

SetWindowCompositionAttribute shouldn't be used unless you want to release potentially broken application. It's undocumented API and has history of performance problems on older windows versions.

There must be another fix. Even though acrylic works perfectly with current master in this repo, I haven't tested MusicStore. Might be problem with some combination of custom window decorations.

@Colonial-Dev
Copy link

SetWindowCompositionAttribute shouldn't be used unless you want to release potentially broken application. It's undocumented API and has history of performance problems on older windows versions.

There must be another fix. Even though acrylic works perfectly with current master in this repo, I haven't tested MusicStore. Might be problem with some combination of custom window decorations.

I'm having the same issue. I tried cloning and building MusicStore in VS 2022 and the acrylic is still erroneously opaque.

@DeXP
Copy link

DeXP commented Dec 17, 2021

acrylic works perfectly with current master in this repo

Is it? I've just got latest, built it in VS 2022, and runned the "Avalaonia Control Gallery". Blur works perfectly:
ACG-Blur

But AcrylicBlur don't:
ACG-Acrylic

Mica doesn't works for me as well:
ACG-Mica

P.S. I have Nvidia 1060 GPU and Intel i7 CPU, if it's related 🥇

@trympet
Copy link
Contributor Author

trympet commented Dec 22, 2021

I was able to reproduce by setting ExtendClientAreaToDecorationsHint="True".

DwmExtendFrameIntoClientArea with a non-zero MARGINS struct will cause the client area to turn opaque.

@trympet
Copy link
Contributor Author

trympet commented Dec 22, 2021

acrylic works perfectly with current master in this repo

Is it? I've just got latest, built it in VS 2022, and runned the "Avalaonia Control Gallery". Blur works perfectly: ACG-Blur

But AcrylicBlur don't: ACG-Acrylic

Mica doesn't works for me as well: ACG-Mica

P.S. I have Nvidia 1060 GPU and Intel i7 CPU, if it's related 🥇

Could you verify you're on master with the latest commit? There should be no difference between Blur and AcrylicBlur if composition is enabled. Also, are you running ControlCatalog.NetCore?

@DeXP
Copy link

DeXP commented Dec 23, 2021

Yup, sorry, you are correct - I was running ControlCatalog.Desktop. The NetCore version works good. Except the case with BorderOnly for AcrylicBlur - it makes the window non transparent.
What's the diffrence between them? My project is able to use Blur as well, but not AcrylicBlur or Mica. It's targeted for net5.0

@DeXP
Copy link

DeXP commented Dec 23, 2021

I've create a minimalistic app for testing AcrylicBlur. VS 2022, Avalonia 0.10.11. https://github.com/DeXP/Avalonia.AcrylicBlur.Sample
I've changed the theme to dark, set width and height of the window, also set TransparencyLevelHint="AcrylicBlur" and Background="Transparent".
But the blur does not working for me. What am I missing?
image

@trympet
Copy link
Contributor Author

trympet commented Dec 25, 2021

The NetCore version works good. Except the case with BorderOnly for AcrylicBlur - it makes the window non transparent.

Yes! Not quite sure why that's the case. My guess is that it is a win11 issue, since I'm unable to reproduce on win10. It is likely caused by DwmExtendFrameIntoClientArea with non-zero MARGINS.

What's the diffrence between them? My project is able to use Blur as well, but not AcrylicBlur or Mica. It's targeted for net5.0

The projects have different implicit rendering options in their program.cs-file. Netcore / net6.0 uses opengl + winui compositor; netframework uses opengl without winui compositor. Winui compositor is required for acrylic and mica. It is configured in Win32PlatformOptions.

You're probably experiencing issues due to the bug above. Try setting ExtendClientAreaToDecorationsHint to false. 😄

@DeXP
Copy link

DeXP commented Dec 25, 2021

Thank you very much, @trympet . UseWindowsUIComposition = true did the blur for me. Commit to sample project
image
However, I have the same issue as you - transparency do not work when ExtendClientAreaToDecorationsHint set to true 😄

@gargakshit
Copy link

I got Mica to work with ExtendClientAreaToDecorationHint by using UseWindowsUIComposition = true along with ExtendClientAreaChromeHints = PreferSystemChrome

Preview of mica composition on Windows 11

<Window
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vm="using:Avalonia.NETCoreMVVMApp1Fs.ViewModels"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
    x:Class="[ClassHere]"
    Icon="/Assets/avalonia-logo.ico"
    Title="[TitleHere]"
    TransparencyLevelHint="Mica"
    Background="{x:Null}"
    ExtendClientAreaToDecorationsHint="True"
    ExtendClientAreaChromeHints="PreferSystemChrome">
    <!-- ... -->
</Window>

@DeXP
Copy link

DeXP commented Jan 12, 2022

@gargakshit Does it works for you after publishing the application in Self-contained mode?

@gargakshit
Copy link

@gargakshit Does it works for you after publishing the application in Self-contained mode?

Building with dotnet publish -c Release -o build-release -r win-x64 --self-contained, it doesn't seem to work. It shows a black screen. Omitting the --self-contained flag shows similar results.

@trympet
Copy link
Contributor Author

trympet commented Jan 20, 2022

@gargakshit Does it works for you after publishing the application in Self-contained mode?

Building with dotnet publish -c Release -o build-release -r win-x64 --self-contained, it doesn't seem to work. It shows a black screen. Omitting the --self-contained flag shows similar results.

Could you try setting the RID to win10-x64? win-x64 has had issues with libgles not being copied to the output directory.

@DeXP
Copy link

DeXP commented Jan 20, 2022

win10-x64 made Mica work for me after publishing. av_libglesv2.dll was added. Will the application work on earlier Windows? Like 8 etc.

@gargakshit
Copy link

@gargakshit Does it works for you after publishing the application in Self-contained mode?

Building with dotnet publish -c Release -o build-release -r win-x64 --self-contained, it doesn't seem to work. It shows a black screen. Omitting the --self-contained flag shows similar results.

Could you try setting the RID to win10-x64? win-x64 has had issues with libgles not being copied to the output directory.

Using the command dotnet publish -c Release -o build-release -r win10-x64 --self-contained, it does work for me.

@gargakshit
Copy link

win10-x64 made Mica work for me after publishing. av_libglesv2.dll was added. Will the application work on earlier Windows? Like 8 etc.

According to Microsoft's documentation, it appears as a solid fallback color when running on windows versions below 22000. I am not sure how this translates to Avalonia as I personally do not have a windows 8 or 10 machine to test.

@trympet
Copy link
Contributor Author

trympet commented Jan 20, 2022

win10-x64 made Mica work for me after publishing. av_libglesv2.dll was added. Will the application work on earlier Windows? Like 8 etc.

I think win7-x64 should also work 😁

@DeXP
Copy link

DeXP commented Jan 21, 2022

win8-x64 works, thank you. win7-x64 is not able to publish as a single file executable.

@kekekeks
Copy link
Member

I suspect that some versions of windows require a compatibility manifest to work properly.

@maxkatz6 IIRC you've had issues with manifest previously. Could you post instructions here?

@maxkatz6
Copy link
Member

maxkatz6 commented Jan 21, 2022

Well, you can try to add app.manifest file with supported win10 os there. Visual Studio can generate one. It helped me with layered styled windows, probably it can somehow help with winui composition. Although I don't remember having problems with it without app.manifest.

@Bum-Ho12
Copy link

The problem is still there, following the official documentation for the implementation still doesn't work on windows 11 23H2

@Bum-Ho12
Copy link

AcrylicBlur that is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet