WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

TokenizingTextBox crashes the app in CommunityToolkit.WinUI

Open lunelake opened this issue 1 year ago • 1 comments

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?

  • [ ] This bug can be reproduced in the 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

  • [ ] 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)
  • [X] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • [X] 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

2022

Visual Studio Build Number

17.3.3

Device form factor

Desktop

Nuget packages

  • CommunityToolkit.WinUI.UI : 7.1.2
  • CommunityToolkit.WinUI.UI.Controls : 7.1.2
  • CommunityToolkit.WinUI.UI.Controls.Input : 7.1.2
  • Microsoft.WindowsAppSDK : 1.1.3
  • Microsoft.Windows.SDK.BuildTools : 10.0.22000.194

Additional context

App4.zip

Help us help you

Yes, but only if others can assist.

lunelake avatar Sep 21 '22 04:09 lunelake

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 🙌

msftbot[bot] avatar Sep 21 '22 04:09 msftbot[bot]

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 avatar Sep 27 '22 07:09 niels9001

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

niels9001 avatar Oct 06 '22 15:10 niels9001

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

michael-hawker avatar Oct 11 '22 16:10 michael-hawker