CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.89k stars 1.38k forks source link

TokenizingTextBox crashes the app in CommunityToolkit.WinUI #4772

Open lunelake opened 2 years ago

lunelake commented 2 years ago

Describe the bug

Having an TokenizingTextBox in WinUI crashes the app. The same code works well in UWP.

<Grid>
    <controls:TokenizingTextBox />
</StackPanel>

designme_cKfgF05iK0yAw-5qW7Uzmg

Regression

No response

Reproducible in sample app?

Steps to reproduce

1. Create a WinUI3 project
2. Add the snippet from the bug description
3. Run the app

Expected behavior

The app will continue running and show the items from TokenizingTextBox as with a normal one would.

Screenshots

No response

Windows Build Number

Other Windows Build number

No response

App minimum and target SDK version

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

17.3.3

Device form factor

Desktop

Nuget packages

Additional context

App4.zip

Help us help you

Yes, but only if others can assist.

ghost commented 2 years ago

Hello lunelake, 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 🙌

niels9001 commented 2 years ago

Able to reproduce. Stacktrace:

at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr) 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)

What's strange is that this only seems to happen when the Orientation of the parent StackPanel is explicitly set to Horizontal.

This causes a crash:

<StackPanel Orientation="Horizontal">
        <controls:TokenizingTextBox />
   </StackPanel>

But when left out, or set to Vertical, it does not crash:

<StackPanel Orientation="Vertical">
        <controls:TokenizingTextBox />
   </StackPanel>
niels9001 commented 2 years ago

Able to reproduce this in UWP as well, seems to be an issue with the WrapPanel:

<StackPanel Orientation="Horizontal">
      <local:WrapPanel StretchChild="Last">
            <TextBox />
      </local:WrapPanel>
</StackPanel>

The app crashes when the Size gets returned in the MeasureOverride function - is it because the width is considered Infinity?

image
michael-hawker commented 2 years ago

Going to move to 8.0 when we can better test this component in our new infrastructure.

Tiktack commented 3 months ago

Any progress on that? 2 years and it still crashes with 8.X.X Would appreciate if anyone can take a look.