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

GeneratedSampleOptionRenderer dependency property fails to bind under AoT, crashes sample gallery #213

Closed
1 of 20 tasks
Arlodotexe opened this issue Sep 16, 2024 · 4 comments · Fixed by #214
Closed
1 of 20 tasks
Assignees
Labels
bug 🐛 Something isn't working sample app 🖼

Comments

@Arlodotexe
Copy link
Member

Arlodotexe commented Sep 16, 2024

Describe the bug

With the latest updates to WinAppSDK 1.6 with AoT, we're seeing an exception coming from the WASDK build of our gallery for components using a generated options pane.

   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
   at ABI.Microsoft.UI.Xaml.Controls.IItemsControlMethods.set_ItemsSource(IObjectReference _obj, Object value)
   at Microsoft.UI.Xaml.Controls.ItemsControl.set_ItemsSource(Object value)
   at CommunityToolkit.App.Shared.Renderers.GeneratedSampleOptionsRenderer.XamlBindingSetters.Set_Microsoft_UI_Xaml_Controls_ItemsControl_ItemsSource(ItemsControl obj, Object value, String targetNullValue) in /_/ProjectHeads/AllComponents/Wasdk/obj/x64/Debug/net8.0-windows10.0.22621.0/win-x64/Renderers/GeneratedSampleOptionsRenderer.g.cs:line 27
   at CommunityToolkit.App.Shared.Renderers.GeneratedSampleOptionsRenderer.GeneratedSampleOptionsRenderer_obj1_Bindings.Update_SampleOptions(IEnumerable`1 obj, Int32 phase) in /_/ProjectHeads/AllComponents/Wasdk/obj/x64/Debug/net8.0-windows10.0.22621.0/win-x64/Renderers/GeneratedSampleOptionsRenderer.g.cs:line 2011
   at CommunityToolkit.App.Shared.Renderers.GeneratedSampleOptionsRenderer.GeneratedSampleOptionsRenderer_obj1_Bindings.Update_(GeneratedSampleOptionsRenderer obj, Int32 phase) in /_/ProjectHeads/AllComponents/Wasdk/obj/x64/Debug/net8.0-windows10.0.22621.0/win-x64/Renderers/GeneratedSampleOptionsRenderer.g.cs:line 2000
   at CommunityToolkit.App.Shared.Renderers.GeneratedSampleOptionsRenderer.GeneratedSampleOptionsRenderer_obj1_Bindings.Update() in /_/ProjectHeads/AllComponents/Wasdk/obj/x64/Debug/net8.0-windows10.0.22621.0/win-x64/Renderers/GeneratedSampleOptionsRenderer.g.cs:line 1956
   at CommunityToolkit.App.Shared.Renderers.GeneratedSampleOptionsRenderer.GeneratedSampleOptionsRenderer_obj1_Bindings.Initialize() in /_/ProjectHeads/AllComponents/Wasdk/obj/x64/Debug/net8.0-windows10.0.22621.0/win-x64/Renderers/GeneratedSampleOptionsRenderer.g.cs:line 1950
   at CommunityToolkit.App.Shared.Renderers.GeneratedSampleOptionsRenderer.GeneratedSampleOptionsRenderer_obj1_Bindings.Loading(FrameworkElement src, Object data) in /_/ProjectHeads/AllComponents/Wasdk/obj/x64/Debug/net8.0-windows10.0.22621.0/win-x64/Renderers/GeneratedSampleOptionsRenderer.g.cs:line 1989
   at WinRT._EventSource_global__Windows_Foundation_TypedEventHandler_global__Microsoft_UI_Xaml_FrameworkElement__object_.EventState.<GetEventInvoke>b__1_0(FrameworkElement sender, Object args)
   at WinRT.GenericTypeInstantiations.Windows_Foundation_TypedEventHandler_2_Microsoft_UI_Xaml_FrameworkElement__object.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr args)

Steps to reproduce

1. Clone the toolkit repo
2. Generate and open the wasdk solution: `./tooling/GenerateAllSolution.ps1 -winui 3 -heads wasdk -multitargets wasdk`
3. Build and deploy the gallery CommunityToolkit.App.Wasdk
4. Navigate to a component that uses generated sample options, such as SettingsControl.

Expected behavior

No crash.

Screenshots

No response

Code Platform

  • UWP
  • 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 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)
  • 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 Arlodotexe added bug 🐛 Something isn't working sample app 🖼 labels Sep 16, 2024
@Arlodotexe Arlodotexe self-assigned this Sep 16, 2024
@Arlodotexe Arlodotexe moved this to 🏗 In progress in Toolkit 8.x Sep 16, 2024
@Arlodotexe
Copy link
Member Author

Arlodotexe commented Sep 16, 2024

The options pane metadata is generating fine, seems the dependency property binding for the display is just failing:
image

@Arlodotexe
Copy link
Member Author

Arlodotexe commented Sep 16, 2024

The dependency property in GeneratedSampleOptionsRenderer.xaml.cs#L38 seems to be the root of the trouble, though it's not clear what is doing this.

Updating the property to use an empty list by default (instead of null), there's no change in behavior. Not sure. 🤔

@Arlodotexe
Copy link
Member Author

I was able to fix the issue by changing the dependency property to a List<T> instead of IEnumerable<T>. Will get a PR in.

image

@michael-hawker
Copy link
Member

Huh, odd that IEnumerable is a problem over List, I wonder why that would be...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working sample app 🖼
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants