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

ColorPicker sample in gallery crashing under Windows App SDK #509

Open
1 of 24 tasks
Arlodotexe opened this issue Sep 18, 2024 · 6 comments
Open
1 of 24 tasks

ColorPicker sample in gallery crashing under Windows App SDK #509

Arlodotexe opened this issue Sep 18, 2024 · 6 comments
Assignees
Labels
bug Something isn't working regression What was working is now broke sample app 🖼️

Comments

@Arlodotexe
Copy link
Member

Arlodotexe commented Sep 18, 2024

Describe the bug

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

image

   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.MeasureOverride(IObjectReference _obj, Size availableSize)
   at Microsoft.UI.Xaml.FrameworkElement.MeasureOverride(Size availableSize)
   at Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Size availableSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(IntPtr thisPtr, Size availableSize, Size* result)

This crash does not occur under UWP.

Steps to reproduce

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

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 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
Copy link
Member Author

Has the same error message as #517

@Arlodotexe
Copy link
Member Author

Arlodotexe commented Sep 18, 2024

Additional info uncovered thanks to a tip from @Sergio0694

image

(Possibly related to #516? Though, not the same error message.)

@michael-hawker Anything you could add? SwitchPresenter may be having more than one AoT issue here.

@michael-hawker
Copy link
Member

@Arlodotexe Switch Presenter uses all the general types and such from XAML like DependencyObjectCollection and DependencyObject - It also just does a lot of general comparison/reflection-y type stuff when trying to compare values here: https://github.com/CommunityToolkit/Windows/blob/main/components/Primitives/src/SwitchPresenter/SwitchPresenter.cs#L116

So, there's probably something there to figure out how to better guard against?

I also saw a new issue on the WinUI repo about controls and resource dictionaries + trimming, so something we may want to keep an eye on incase there's other underlying issues still we need to be concerned about or bubble up with the platform team. RE: microsoft/microsoft-ui-xaml#10020

@Arlodotexe
Copy link
Member Author

Arlodotexe commented Oct 17, 2024

Since #516 turned out to be an issue with the EnumValuesExtension, I suspect this may be a binding issue given the data in the exception. Could also be erroring internally in the setter, but the Value property is a good place to start looking.

@Arlodotexe
Copy link
Member Author

It looks like the problem is here:

<controls:SwitchPresenter x:Name="ContentContainer"
Grid.Row="2"
Value="{Binding ElementName=ColorPanelSelector, Path=SelectedItem.Name}">

Unfortunately, this isn't a backed resource dictionary, so we can't use x:Bind here. If we try, we get the error:

1>V:\Windows\components\ColorPicker\src\ColorPicker.xaml(240,55): XamlCompiler error WMC1119: This Xaml file must have a code-behind class to use {x:Bind}. See http://go.microsoft.com/fwlink/?LinkID=532920&clcid=0x409 for more information
1>Done building project "CommunityToolkit.WinUI.Controls.ColorPicker.csproj" -- FAILED.

To fix the problem, we'll need to locate any .xaml files that use a non-TemplatedParent variant of {Binding}, update the resource dictionary to be backed by a cs file, and update bindings to use x:Bind.

@michael-hawker
Copy link
Member

This issue got opened on the WinUI repo which is related microsoft/microsoft-ui-xaml#10214 - not too sure what we can do here atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression What was working is now broke sample app 🖼️
Projects
Status: 🏗 In progress
Development

No branches or pull requests

2 participants