Windows icon indicating copy to clipboard operation
Windows copied to clipboard

AttachedCardShadow sample in gallery crashes under Windows App SDK

Open Arlodotexe opened this issue 1 year ago • 1 comments

Describe the bug

When running the gallery with the Wasdk head on the latest main commit, the AttachedCardShadow sample will crash the app:

image

Exception message:

Cannot create an RCW factory for implementation type 'Microsoft.Graphics.Canvas.Geometry.CanvasGeometry', because it doesn't have a [WinRTImplementationTypeRcwFactory] derived attribute on it. The fallback path for older projections is not trim-safe, and isn't supported in AOT environments. Make sure to reference updated projections.

Stack trace:

   at WinRT.ComWrappersSupport.CreateFactoryForImplementationType(String runtimeClassName, Type implementationType)
   at WinRT.ComWrappersSupport.CreateTypedRcwFactory(Type implementationType, String runtimeClassName)
   at WinRT.ComWrappersSupport.CreateTypedRcwFactory(Type implementationType)
   at WinRT.DefaultComWrappers.CreateObject(IntPtr externalComObject)
   at System.Runtime.InteropServices.ComWrappers.CallCreateObject(ComWrappersScenario scenario, ComWrappers comWrappersImpl, IntPtr externalComObject, CreateObjectFlags flags)
   at System.Runtime.InteropServices.ComWrappers.<TryGetOrCreateObjectForComInstanceInternal>g____PInvoke|18_0(ObjectHandleOnStack __comWrappersImpl_native, Int64 __wrapperId_native, IntPtr __externalComObject_native, IntPtr __innerMaybe_native, CreateObjectFlags __flags_native, ObjectHandleOnStack __wrapper_native, ObjectHandleOnStack __retValue_native)
   at WinRT.ComWrappersSupport.CreateRcwForComObject[T](IntPtr ptr, Boolean tryUseCache)
   at WinRT.MarshalInspectable`1.FromAbi(IntPtr ptr)
   at Microsoft.Graphics.Canvas.Geometry.CanvasGeometry.FromAbi(IntPtr thisPtr)
   at ABI.Microsoft.Graphics.Canvas.Geometry.CanvasGeometry.FromAbi(IntPtr thisPtr)
   at ABI.Microsoft.Graphics.Canvas.Geometry.ICanvasGeometryStaticsMethods.CreateRoundedRectangle(IObjectReference _obj, ICanvasResourceCreator resourceCreator, Single x, Single y, Single w, Single h, Single radiusX, Single radiusY)
   at Microsoft.Graphics.Canvas.Geometry.CanvasGeometry.CreateRoundedRectangle(ICanvasResourceCreator resourceCreator, Single x, Single y, Single w, Single h, Single radiusX, Single radiusY)
   at CommunityToolkit.WinUI.Media.AttachedCardShadow.GetShadowClip(AttachedShadowElementContext context) in /_/components/Media/src/Shadows/AttachedCardShadow.cs:line 194
   at CommunityToolkit.WinUI.AttachedShadowBase.UpdateShadowClip(AttachedShadowElementContext context) in /_/components/Extensions/src/Shadows/AttachedShadowBase.cs:line 256
   at CommunityToolkit.WinUI.AttachedShadowBase.OnElementContextInitialized(AttachedShadowElementContext context) in /_/components/Extensions/src/Shadows/AttachedShadowBase.cs:line 153
   at CommunityToolkit.WinUI.Media.AttachedCardShadow.OnElementContextInitialized(AttachedShadowElementContext context) in /_/components/Media/src/Shadows/AttachedCardShadow.cs:line 97
   at CommunityToolkit.WinUI.AttachedShadowElementContext.Initialize(Boolean forceIfNotLoaded) in /_/components/Extensions/src/Shadows/AttachedShadowElementContext.cs:line 126
   at CommunityToolkit.WinUI.AttachedShadowElementContext.OnElementLoaded(Object sender, RoutedEventArgs e) in /_/components/Extensions/src/Shadows/AttachedShadowElementContext.cs:line 169
   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)

This behavior is not present when running the gallery under UWP.

Steps to reproduce

1. Clone the repo
2. Generate the gallery solution, include the Media component and the wasdk multitarget/head.
3. Build and deploy the wasdk gallery 
4. Navigate to the AttachedCardShadow sample page and observe crash.

Expected behavior

No crash

Screenshots

No response

Code Platform

  • [ ] UWP
  • [X] WinAppSDK / WinUI 3
  • [ ] Web Assembly (WASM)
  • [ ] Android
  • [ ] iOS
  • [ ] MacOS
  • [ ] Linux / GTK

Windows Build Number

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [ ] Windows 10 21H2 (Build 19044)
  • [ ] Windows 10 22H2 (Build 19045)
  • [ ] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • [ ] Windows 10, version 1809 (Build 17763)
  • [ ] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [ ] Windows 10, version 2104 (Build 20348)
  • [ ] Windows 11, version 22H2 (Build 22000)
  • [ ] Other (specify)

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

No response

Device form factor

No response

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item.

Arlodotexe avatar Sep 18 '24 18:09 Arlodotexe

This is because you're using an outdated version of Win2D.

Sergio0694 avatar Sep 18 '24 19:09 Sergio0694