Skip to content

DataGrid Scrollbar VisualState invoked outside UI thread #4443

Open
@nickprotop

Description

@nickprotop

Describe the bug

I receiving unhandled exceptions about Datagrid control by telemetry. The exceptions seems random to me, and I can't find a pattern reproducing the bug. I am using latest Community Toolkit and Windows App SDK version 1.0.

This is the stack trace reported back to app center:

Exception Stack:

System.Runtime.InteropServices.COMException: Η εφαρμογή κάλεσε μια διασύνδεση που είχε παραταχθεί για διαφορετικό νήμα. (0x8001010E (RPC_E_WRONG_THREAD))
  at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
  at ABI.Microsoft.UI.Xaml.IVisualStateManagerStatics.global::Microsoft.UI.Xaml.IVisualStateManagerStatics.GoToState(Control control, String stateName, Boolean useTransitions)
  at CommunityToolkit.WinUI.UI.Controls.Utilities.VisualStates.GoToState(Control control, Boolean useTransitions, String[] stateNames)
  at CommunityToolkit.WinUI.UI.Controls.DataGrid.SwitchScrollBarsVisualStates(ScrollBarVisualState scrollBarsState, ScrollBarsSeparatorVisualState separatorState, Boolean useTransitions)
  at ABI.Windows.Foundation.TypedEventHandler`2.Do_Abi_Invoke[TSenderAbi,TResultAbi](Void* thisPtr, TSenderAbi sender, TResultAbi args)
  at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
  at ABI.Windows.ApplicationModel.Core.IUnhandledErrorMethods.Propagate(IObjectReference _obj)
  at Windows.ApplicationModel.Core.UnhandledError.Propagate()
  at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.<.ctor>b__16_0(Object sender, UnhandledErrorDetectedEventArgs eventArgs)
  at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.<.ctor>b__16_0(Object sender, UnhandledErrorDetectedEventArgs eventArgs)
  at WinRT.EventSource__EventHandler`1.EventState.<GetEventInvoke>b__1_0(Object obj, T e)
  at ABI.System.EventHandler`1.Do_Abi_Invoke[TAbi](Void* thisPtr, IntPtr sender, TAbi args)
  at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
  at ABI.Microsoft.UI.Xaml.IVisualStateManagerStatics.global::Microsoft.UI.Xaml.IVisualStateManagerStatics.GoToState(Control control, String stateName, Boolean useTransitions)
  at CommunityToolkit.WinUI.UI.Controls.Utilities.VisualStates.GoToState(Control control, Boolean useTransitions, String[] stateNames)
  at CommunityToolkit.WinUI.UI.Controls.DataGrid.SwitchScrollBarsVisualStates(ScrollBarVisualState scrollBarsState, ScrollBarsSeparatorVisualState separatorState, Boolean useTransitions)
  at ABI.Windows.Foundation.TypedEventHandler`2.Do_Abi_Invoke[TSenderAbi,TResultAbi](Void* thisPtr, TSenderAbi sender, TResultAbi args)
  at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
  at ABI.Windows.ApplicationModel.Core.IUnhandledErrorMethods.Propagate(IObjectReference _obj)
  at Windows.ApplicationModel.Core.UnhandledError.Propagate()
  at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.<.ctor>b__16_0(Object sender, UnhandledErrorDetectedEventArgs eventArgs)
  at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.<.ctor>b__16_0(Object sender, UnhandledErrorDetectedEventArgs eventArgs)
  at WinRT.EventSource__EventHandler`1.EventState.<GetEventInvoke>b__1_0(Object obj, T e)
  at ABI.System.EventHandler`1.Do_Abi_Invoke[TAbi](Void* thisPtr, IntPtr sender, TAbi args)
  at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
  at ABI.Microsoft.UI.Xaml.IVisualStateManagerStatics.global::Microsoft.UI.Xaml.IVisualStateManagerStatics.GoToState(Control control, String stateName, Boolean useTransitions)
  at CommunityToolkit.WinUI.UI.Controls.Utilities.VisualStates.GoToState(Control control, Boolean useTransitions, String[] stateNames)
  at CommunityToolkit.WinUI.UI.Controls.DataGrid.SwitchScrollBarsVisualStates(ScrollBarVisualState scrollBarsState, ScrollBarsSeparatorVisualState separatorState, Boolean useTransitions)
  at ABI.Windows.Foundation.TypedEventHandler`2.Do_Abi_Invoke[TSenderAbi,TResultAbi](Void* thisPtr, TSenderAbi sender, TResultAbi args)
  at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
  at ABI.Windows.ApplicationModel.Core.IUnhandledErrorMethods.Propagate(IObjectReference _obj)
  at Windows.ApplicationModel.Core.UnhandledError.Propagate()
  at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.<.ctor>b__16_0(Object sender, UnhandledErrorDetectedEventArgs eventArgs)

Regression

No response

Reproducible in sample app?

  • This bug can be reproduced in the sample app.

Steps to reproduce

The exception is random. No pattern can be identified for reproducing.

Expected behavior

No exception at all

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

Other Windows Build number

No response

App minimum and target SDK version

  • 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

No response

Device form factor

Desktop

Nuget packages

No response

Additional context

No response

Help us help you

No.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DataGrid 🔠Issues on DataGrid controlWinUI 💠Related to WinUI 3 Version or when paired with External can mean requires fix in WinUI 2/3.bug 🐛An unexpected issue that highlights incorrect behaviorneed more info 📌

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions