Description
Describe the bug
Tested on both latest 1.1.0-preview3 (not an option in dropdown below) and 1.0.1,
I'm hitting a 0xC0000005: Access violation reading location 0x0000000000000000.
error when trying to set the ProtectedCursor
on my derived control. I'm trying to update our new refactor of GridSplitter
and related controls in the Toolkit to work with WinUI 3 from this PR here CommunityToolkit/WindowsCommunityToolkit#4083 (related to issue #4509 here as well).
We'd like to showcase this component in our new Labs setup. Seems more severe of an issue than previously reported #6058.
Interesting to note is that if I change this value within OnApplyTemplate
it seems to work fine. However, when being called as a result of the XAML DependencyProperty PropertyChangedCallback - updating it fails with this error.
I tried to use a DispatcherQueue
within the callback, but that resulted in the same error. (Even though this should already be still on the UI thread, so I wouldn't expect to have to do this here.)
Steps to reproduce the bug
Derive a control and try and set the ProtectedCursor property:
ProtectedCursor = InputSystemCursor.Create(InputSystemCursorShape.SizeNorthSouth);
Move this to a DependencyPropertyChanged callback, see error.
Happy to add someone to our repo and point them to the commit where we can reproduce this in Labs.
Expected behavior
Should not crash and set the cursor to the specified value.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.1 Preview 2: 1.1.0-preview3
Windows app type
- UWP
- Win32
Device form factor
Desktop
Windows version
Windows 10 (21H2): Build 19044
Additional context
Exception thrown at 0x00007FFDB995F223 (Microsoft.ui.xaml.dll) in SizerBase.WinAppSdk.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
Microsoft.ui.xaml.dll!CInputServices::SetCursor() Unknown
Microsoft.ui.xaml.dll!CInputServices::UpdateCursor() Unknown
Microsoft.ui.xaml.dll!CUIElement::SetValue() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::SetValue() Unknown
Microsoft.ui.xaml.dll!CControl::SetValue() Unknown
Microsoft.ui.xaml.dll!DirectUI::DependencyObject::SetValueCore() Unknown
Microsoft.ui.xaml.dll!DirectUI::DependencyObject::SetValueByKnownIndex() Unknown
[Managed to Native Transition]
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IUIElementProtectedMethods.set_ProtectedCursor(WinRT.IObjectReference _obj, Microsoft.UI.Input.InputCursor value) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.UIElement.ProtectedCursor.set(Microsoft.UI.Input.InputCursor value) Unknown
> CommunityToolkit.Labs.WinUI.SizerBase.dll!CommunityToolkit.Labs.WinUI.SizerBase.OnOrientationPropertyChanged(Microsoft.UI.Xaml.DependencyObject d, Microsoft.UI.Xaml.DependencyPropertyChangedEventArgs e) Line 111 C#
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.PropertyChangedCallback.Do_Abi_Invoke(System.IntPtr thisPtr, System.IntPtr d, System.IntPtr e) Unknown
[Native to Managed Transition]
Microsoft.ui.xaml.dll!DirectUI::DependencyObject::NotifyPropertyChanged() Unknown
Microsoft.ui.xaml.dll!CDependencyObject::NotifyPropertyChanged() Unknown
Microsoft.ui.xaml.dll!CDependencyObject::SetEffectiveValue() Unknown
Microsoft.ui.xaml.dll!CDependencyObject::UpdateEffectiveValue() Unknown
Microsoft.ui.xaml.dll!CDependencyObject::SetValue() Unknown
Microsoft.ui.xaml.dll!CUIElement::SetValue() Unknown
...
Working stack:
> CommunityToolkit.Labs.WinUI.SizerBase.dll!CommunityToolkit.Labs.WinUI.SizerBase.OnOrientationPropertyChanged(Microsoft.UI.Xaml.DependencyObject d, Microsoft.UI.Xaml.DependencyPropertyChangedEventArgs e) Line 111 C#
CommunityToolkit.Labs.WinUI.SizerBase.dll!CommunityToolkit.Labs.WinUI.SizerBase.OnApplyTemplate() Line 124 C#
Microsoft.WinUI.dll!Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.OnApplyTemplate() Unknown
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_OnApplyTemplate_2(System.IntPtr thisPtr) Unknown
[Native to Managed Transition]
Microsoft.ui.xaml.dll!DirectUI::FrameworkElementGenerated::OnApplyTemplateProtected() Unknown
Microsoft.ui.xaml.dll!DirectUI::FrameworkElement::OnApplyTemplateFromCore() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::InvokeApplyTemplate() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::MeasureCore() Unknown
Microsoft.ui.xaml.dll!CUIElement::MeasureInternal() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CGrid::MeasureCell() Unknown
Microsoft.ui.xaml.dll!CGrid::MeasureCellsGroup() Unknown
Microsoft.ui.xaml.dll!CGrid::MeasureOverride() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::MeasureCore() Unknown
Microsoft.ui.xaml.dll!CUIElement::MeasureInternal() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!DirectUI::UIElementGenerated::Measure() Unknown
Microsoft.ui.xaml.dll!DirectUI::Page::MeasureOverride() Unknown
...
Related microsoft/WindowsAppSDK#1816