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

UWP or Xaml Island app crashes on pressing the clear button in the hex Input textbox in ColorPicker #3222

Closed
arjunbalgovind opened this issue Aug 31, 2020 · 7 comments · Fixed by #3224
Labels
area-ColorPicker team-Controls Issue for the Controls team

Comments

@arjunbalgovind
Copy link

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 microsoft/WinUI-Gallery@9e87c2f)
  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: microsoft/PowerToys#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.

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Aug 31, 2020
@arjunbalgovind
Copy link
Author

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.

@arjunbalgovind arjunbalgovind changed the title UWP app crashes on pressing the clear button in the hex Input textbox in ColorPicker UWP/Xaml Island app crashes on pressing the clear button in the hex Input textbox in ColorPicker Aug 31, 2020
@arjunbalgovind arjunbalgovind changed the title UWP/Xaml Island app crashes on pressing the clear button in the hex Input textbox in ColorPicker UWP or Xaml Island app crashes on pressing the clear button in the hex Input textbox in ColorPicker Aug 31, 2020
@Felix-Dev
Copy link
Contributor

I would like to look into this issue.

@Felix-Dev
Copy link
Contributor

Felix-Dev commented Aug 31, 2020

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.)

@ranjeshj
Copy link
Contributor

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::<lambda_116d06a59ca91ebc1c22d588fa239c31>::operator()(const winrt::Windows::Foundation::IInspectable &) Line 13334 C++
Microsoft.UI.Xaml.dll!winrt::impl::delegate<winrt::Windows::UI::Xaml::SizeChangedEventHandler,<lambda_116d06a59ca91ebc1c22d588fa239c31>>::Invoke(void * sender, void * e) Line 893 C++
Windows.UI.Xaml.dll!DirectUI::CEventSourceBase<DirectUI::IUntypedEventSource,Windows::Foundation::ITypedEventHandler<Windows::UI::Xaml::Controls::TextBox *,Windows::UI::Xaml::Controls::TextBoxBeforeTextChangingEventArgs *>,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::ClassMemberEventHandlerDirectUI::TextBox,Windows::UI::Xaml::Controls::ITextBox,Windows::UI::Xaml::ISizeChangedEventHandler,IInspectable,Windows::UI::Xaml::ISizeChangedEventArgs::Invoke(IInspectable * pSender, Windows::UI::Xaml::ISizeChangedEventArgs * pArgs) Line 663 C++
Windows.UI.Xaml.dll!DirectUI::CRoutedEventSourceBaseDirectUI::IUntypedEventSource,Windows::UI::Xaml::IRoutedEventHandler,IInspectable,Windows::UI::Xaml::IRoutedEventArgs::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 ranjeshj added area-ColorPicker team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Aug 31, 2020
@Felix-Dev
Copy link
Contributor

@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.

@arjunbalgovind
Copy link
Author

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

@ranjeshj
Copy link
Contributor

ranjeshj commented Sep 1, 2020

@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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ColorPicker team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants