Microsoft-ui-xaml: UWP or Xaml Island app crashes on pressing the clear button in the hex Input textbox in ColorPicker

Created on 1 Sep 2020  路  7Comments  路  Source: microsoft/microsoft-ui-xaml

Describe the bug


If a ColorPicker element is declared with the muxc namespace as in the following snippet, then the entire app crashes without any exception trace on clicking the clear button on the hex input box. This can also be reproduced on the Xaml Controls Gallery repository.

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Run Xaml Controls Gallery and open the Color Picker page (https://github.com/microsoft/Xaml-Controls-Gallery/blob/master/XamlControlsGallery/ControlPages/ColorPickerPage.xaml, reproduced on commit https://github.com/microsoft/Xaml-Controls-Gallery/commit/9e87c2feace4da6a2eef66aa07181a0c0cf1ce0b)
  2. Click on the X button on the hex input textbox

Expected behavior

String gets cleared.

Screenshots

GIF that shows the crash on Xaml Controls Gallery.
winUICrash

Version Info

NuGet package version:

Microsoft.UI.Xaml 2.5.0-prerelease.200812001


Windows app type:
| UWP | Win32 |
| :--------------- | :--------------- |
| | |


| Windows 10 version | Saw the problem? |
| :--------------------------------- | :-------------------- |
| Insider Build (xxxxx) | |
| May 2020 Update (19041) | Yes |
| November 2019 Update (18363) | Yes |
| May 2019 Update (18362) | |
| October 2018 Update (17763) | |
| April 2018 Update (17134) | |
| Fall Creators Update (16299) | |
| Creators Update (15063) | |


| Device form factor | Saw the problem? |
| :----------------- | :--------------- |
| Desktop | Yes |
| Xbox | |
| Surface Hub | |
| IoT | |

Additional context

Link to issue on PowerToys repository: https://github.com/microsoft/PowerToys/issues/6022. We are using WinUI in a Xaml Island, and hence require the pre-release version with the latest changes.

After a lot of trial and error, I found that this seems to happen only if the ColorPicker is referenced with the muxc prefix. If I removed muxc: and used <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/> in the App.xaml ResourceDictionary, I could no longer reproduce the crash.
When the crash occurs, the application exits with error code 0xc000041d.

area-ColorPicker team-Controls

Most helpful comment

@ranjeshj Yes, already added one. Will also look into creating test coverage for this. If it's fine with you I'd create a PR tomorrow.

All 7 comments

On a related note, I wanted to clarify should all the xaml controls be accessible without the muxc: reference if <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/> is added in the ResourceDictionary ? I observed that if I don't add muxc: before a NumberBox element it can't be found. If this is unexpected behavior or not a known issue I can create a separate issue for this.

I would like to look into this issue.

On a related note, I wanted to clarify should all the xaml controls be accessible without the muxc: reference if is added in the ResourceDictionary ? I observed that if I don't add muxc: before a NumberBox element it can't be found. If this is unexpected behavior or not a known issue I can create a separate issue for this.

@arjunbalgovind To my understanding, this is expected because the documentation states that you should add

xmlns:muxc="using:Microsoft.UI.Xaml.Controls"

to your XAML files where you want to use WinUI controls (and thus preface them with "muxc:"). Not prefacing controls with "muxc:" (or however else you named that XAML namespace) will mean that the OS XAML will be checked for the type. However, there is no NumberBox in the OS XAML so you will see that error. There are, however, TextBox, TextBlock, ComboBox,... classes and those will be found in the OS if you don't preface them with "muxc:". WinUI 2 is just being added as a library on top of OS XAML and we use a XAML namespace here to let the systen know that we want to reference controls exposed by that library and not the OS.

(With WinUI 3, the "muxc:" preface won't be needed any longer.)

Looks like the crash is at this point. I think we need a null check.

image

Microsoft.UI.Xaml.dll!ColorPicker::OnHexTextChanging(const winrt::Windows::UI::Xaml::Controls::TextBox & __formal, const winrt::Windows::UI::Xaml::Controls::TextBoxTextChangingEventArgs & __formal) Line 964 C++
[Inline Frame] Microsoft.UI.Xaml.dll!winrt::Windows::UI::Xaml::SizeChangedEventHandler::::operator()(const winrt::Windows::Foundation::IInspectable &) Line 13334 C++
Microsoft.UI.Xaml.dll!winrt::impl::delegate>::Invoke(void * sender, void * e) Line 893 C++
Windows.UI.Xaml.dll!DirectUI::CEventSourceBase,Windows::UI::Xaml::Controls::ITextBox,Windows::UI::Xaml::Controls::ITextBoxBeforeTextChangingEventArgs>::Raise(Windows::UI::Xaml::Controls::ITextBox * pSource, Windows::UI::Xaml::Controls::ITextBoxBeforeTextChangingEventArgs * pArgs) Line 275 C++
Windows.UI.Xaml.dll!DirectUI::TextBox::OnTextChangingHandler(CTextBox * const pNativeTextBox, bool fTextChanged) Line 953 C++
[Inline Frame] Windows.UI.Xaml.dll!CFxCallbacks::TextBox_OnTextChangingHandler(CTextBox * const) Line 907 C++
Windows.UI.Xaml.dll!CTextBox::UpdateTextProperty(const bool notifyPropertyChangeOnly, const bool fTextChanged) Line 443 C++
Windows.UI.Xaml.dll!CTextBox::OnContentChanged(const bool fTextChanged) Line 367 C++
Windows.UI.Xaml.dll!CTextBoxBase::TxNotify(unsigned int notification, void * pData) Line 674 C++
Windows.UI.Xaml.dll!TextServicesHost::TxNotify(unsigned long iNotify, void * pv) Line 779 C++
msftedit.dll!124699fe() Unknown
msftedit.dll![Frames below may be incorrect and/or missing, no symbols loaded for msftedit.dll] Unknown
msftedit.dll!124ad7da() Unknown
msftedit.dll!12473971() Unknown
msftedit.dll!1247345b() Unknown
Windows.UI.Xaml.dll!CTextBoxBase::SetTextServicesBuffer(const xstring_ptr & strText) Line 4021 C++
Windows.UI.Xaml.dll!CTextBox::SetTextServicesBuffer(const xstring_ptr & strText) Line 934 C++
Windows.UI.Xaml.dll!CTextBox::OnDeleteButtonClick() Line 335 C++
[Inline Frame] Windows.UI.Xaml.dll!TextBox_OnDeleteButtonClick(CTextBox *) Line 169 C++
Windows.UI.Xaml.dll!DirectUI::TextBox::OnDeleteButtonClick(IInspectable * pSender, Windows::UI::Xaml::IRoutedEventArgs * pArgs) Line 1120 C++
Windows.UI.Xaml.dll!DirectUI::ClassMemberEventHandler::Invoke(IInspectable * pSender, Windows::UI::Xaml::ISizeChangedEventArgs * pArgs) Line 663 C++
Windows.UI.Xaml.dll!DirectUI::CRoutedEventSourceBase::Raise(IInspectable * pSource, Windows::UI::Xaml::IRoutedEventArgs * pArgs) Line 1041 C++
Windows.UI.Xaml.dll!DirectUI::ButtonBase::OnClick() Line 909 C++
Windows.UI.Xaml.dll!DirectUI::Button::OnClick() Line 91 C++
Windows.UI.Xaml.dll!DirectUI::ButtonBase::PerformPointerUpAction() Line 810 C++
Windows.UI.Xaml.dll!DirectUI::ButtonBase::OnPointerReleased(Windows::UI::Xaml::Input::IPointerRoutedEventArgs * pArgs) Line 784 C++

Windows.UI.Xaml.dll!DirectUI::ControlGenerated::OnPointerReleasedProtected(Windows::UI::Xaml::Input::IPointerRoutedEventArgs * pE) Line 1518 C++
Windows.UI.Xaml.dll!DirectUI::Control::FireEvent(KnownEventIndex nDelegate, DirectUI::DependencyObject * pSender, IInspectable * pArgs) Line 259 C++

@ranjeshj Yes, already added one. Will also look into creating test coverage for this. If it's fine with you I'd create a PR tomorrow.

@ranjeshj when can we expect a pre-release with this fix?

@ranjeshj when can we expect a pre-release with this fix?

@arjunbalgovind assuming the fix goes in before the next pre-release, it should be available in the next pre-release (couple of weeks time).

Was this page helpful?
0 / 5 - 0 ratings