Open kjean667 opened 1 year ago
Hello kjean667, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
@Sergio0694 any of this looks familiar to you? Is there some Win2D or other device check we may be missing for WindowsAppSDK that we wouldn't need to do in UWP? (Or maybe this is an issue there too?)
That at Microsoft.Graphics.Canvas.Effects.GaussianBlurEffect..ctor()
line is suspect, that shouldn't possibly crash (and that "class not registered" is weird in this context). As a sanity check, does just creating new GaussianBlurEffect()
also fail in the VM?
@Sergio0694 Yes, new GaussianBlurEffect()
fails and throws an unhandled exception if run in code behind when for example the Loaded event is triggered by a Page
.
Stack trace of new GaussianBlurEffect()
:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.Runtime.InteropServices.COMException (0x80040154): Klassen har inte registrerats (0x80040154 (REGDB_E_CLASSNOTREG))
at WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName)
at WinRT.ActivationFactory`1..ctor()
at System.RuntimeType.CreateInstanceOfT()
--- End of inner exception stack trace ---
at System.RuntimeType.CreateInstanceOfT()
at System.Activator.CreateInstance[T]()
at WinRT.WeakLazy`1.get_Value()
at WinRT.ActivationFactory`1.ActivateInstance[I]()
at Microsoft.Graphics.Canvas.Effects.GaussianBlurEffect..ctor()
at PipelineVisualFactoryBug.MainPage.MainPage_Loaded(Object sender, RoutedEventArgs e)
at WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler.EventState.<GetEventInvoke>b__1_0(Object sender, RoutedEventArgs e)
at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e)
As a side note, the unhandled exception does not crash the application (but is still thrown as an unhandled exception) if it is triggered from the MainWindow (class Window) object. However if the blur effect is created by a Page
it will crash the application. I.e. if the MainWindow contains a Page reference that uses GaussianBlurEffect it will crash the entire application. In my stack trace above, the MainWindow.xaml contains a Page called MainPage. The MainPage code behind looks like this in the stack trace above:
public sealed partial class MainPage : Page
{
private GaussianBlurEffect blur;
public MainPage()
{
InitializeComponent();
Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
blur = new GaussianBlurEffect();
}
}
I also received error reports from users for the same issue, and it doesn't seem to be limited to just VMs. The user is running Windows 11 (10.0.22621.1555) on a Dell desktop model, OptiPlex 980, and reported the same error.
To test it out, I installed the WinUI3-developed app on a VM and found that the Fallback Color wasn't displayed correctly. In contrast, the UWP-developed app displayed the Blur effect correctly despite having the same code.
I didn't encounter the issue on the devices I tested, but after the app was released, several errors were reported on various devices, and I'm not sure of the cause.
Describe the bug
Using PipelineVisualFactory effects in XAML, such as BlurEffect or GrayscaleEffect from the CommunityToolkit.WinUI.UI.Media library, throws an unhandled exception when application is run on a virtual machine (Hyper-V).
This may cause the application to crash.
Regression
Unknown
Reproducible in sample app?
Steps to reproduce
In Visual Studio, create a new project using the template "Blank App, Packaged (WinUI 3 in Desktop)".
Add the nuget package CommunityToolkit.WinUI.UI.Media to the project.
Use the following XAML in MainWindow.xaml:
Package the application into an msix and install the package in a Windows installation running in a Hyper-V VM.
Start the application.
Check the EventLog in Windows, where the exception will be logged under the Program category.
Expected behavior
Either:
The application shall not crash.
Stack trace for the unhandled exception
Windows Build Number
Other Windows Build number
Windows 10 22H2 (Build 19045.2006)
App minimum and target SDK version
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
17.5.1
Device form factor
Desktop
Nuget packages
CommunityToolkit.WinUI.UI.Media (7.1.2) Microsoft.Windows.SDK.BuildTools (10.0.22621.755) Microsoft.WindowsAppSDK (1.2.221109.1) System.Diagnostics.EventLog (7.0.0)
Additional context
Application is built as 64-bit and run on a Hyper-V VM under Windows 10 21H2 (19044.2604) on an Intel Core i5-7500T CPU.
Help us help you
No.