microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.35k stars 678 forks source link

WinAppSDK 1.3 ColorPicker crashing #9903

Open rocksdanister opened 1 year ago

rocksdanister commented 1 year ago

Describe the bug

On upgrading to WindowsAppSDK 1.3 application crashing when opening ColorPicker on SplitButton sometimes.

AppDomain.CurrentDomain.UnhandledException didn't catch any error.

https://github.com/rocksdanister/lively/issues/1724

Steps to reproduce the bug

  1. Get the app https://github.com/rocksdanister/lively
  2. Click on "..." -> Customise one of the wallpaper supporting color (Fluid)
  3. Try opening ColorPicker.

Expected behavior

The program should not crash.

NuGet package version

Windows App SDK 1.3.1: 1.3.230502000

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

I'll try to create a reproducible sample and update here, its not crashing in debug mode so far.

rocksdanister commented 1 year ago

This is the xaml structure:

<StackPanel Name="element1" Orientation="Horizontal">
  <SplitButton>
      <Border
          Width="32"
          Height="32"
          CornerRadius="4" />
      <SplitButton.Flyout>
          <Flyout>
              <ColorPicker
                  ColorSpectrumShape="Box"
                  IsAlphaEnabled="False"
                  IsAlphaSliderVisible="True"
                  IsColorChannelTextInputVisible="True"
                  IsColorSliderVisible="True"
                  IsHexInputVisible="True"
                  IsMoreButtonVisible="False"
                  Tag="element1" />
          </Flyout>
      </SplitButton.Flyout>
  </SplitButton>
  <Button Width="43" Height="43">
      <FontIcon FontSize="17" Glyph="&#xEF3C;" />
  </Button>
</StackPanel>

I could not get it to reproduce on other project, strangely since switching to CommunityToolkit ColorPicker the issue stopped.

rocksdanister commented 5 months ago

Here is a workaround: https://github.com/rocksdanister/lively/blob/cfeefc4953eef8e86baf0ba0b0777b46e39b91ba/src/Lively/Lively.UI.WinUI/UserControls/ColorPickerButton.xaml.cs#L82

https://github.com/rocksdanister/lively/blob/cfeefc4953eef8e86baf0ba0b0777b46e39b91ba/src/Lively/Lively.UI.WinUI/UserControls/ColorPickerButton.xaml#L31

Using x:Load to load the controls inside flyout on dispatcher.

github-actions[bot] commented 2 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

ranjeshj commented 2 months ago

@rocksdanister have you tried this with latest version of WinAppSDK ? 1.6 Preview1 was recently released - can you see if it is addressed there? There have been many fixes since the 1.3 release.

rocksdanister commented 2 months ago

Can be reproduced on 1.6 Preview1.