microsoft / microsoft/microsoft-ui-xaml
Rapid Scrolling in TreeView Causes Application Crash in WinUI 3
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
When scrolling **quickly** through the `TreeView` items in an "up-down-up-down" sequence, the application consistently crashes. This issue occurs with the item count enough to perform long scrolls and seems to be triggered **only** by rapid scrolling. The amount of scrolls required to trigger the issue varies, sometimes it crashes only after 3-4 such iterations.

- Slow scrolling as well as scrolling with a mouse wheel **does not** seem to cause any issues.
- Similar controls such as `ListView` **do not** seem to cause such issues under the same conditions.
**Exception Message**
`Source object type is not a projected type and does not inherit from a projected type. (Parameter 'value')`
**Stack Trace**
```
at WinRT.CastExtensions.GetRefForObject(Object value)
at WinRT.CastExtensions.As[TInterface](Object value)
at TreeViewScrollingIssue.MainWindow.MainWindow_obj3_Bindings.SetDataRoot(Object newDataRoot) in \\TreeViewScrollingIssue\obj\x64\Debug\net8.0-windows10.0.19041.0\win-x64\MainWindow.g.cs:line 190
at TreeViewScrollingIssue.MainWindow.MainWindow_obj3_Bindings.ProcessBindings(Object item, Int32 itemIndex, Int32 phase, Int32& nextPhase) in \\TreeViewScrollingIssue\obj\x64\Debug\net8.0-windows10.0.19041.0\win-x64\MainWindow.g.cs:line 141
at ABI.Microsoft.UI.Xaml.Markup.IDataTemplateComponent.Do_Abi_ProcessBindings_1(IntPtr thisPtr, IntPtr item, Int32 itemIndex, Int32 phase, Int32* nextPhase)
```
### Steps to reproduce the bug
1. Run the project: https://github.com/datskiy/TreeViewScrollingIssue
2. Start scrolling the `TreeView` quickly all the way up and down sequentially.
3. Observe the unhandled exception and the application crash.
### Expected behavior
The `TreeView` should handle rapid scrolling without crashing the application, like other similar controls.
### Screenshots
**Unhandled exception in VS**

### NuGet package version
WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003
### Windows version
Windows 11 (24H2): Build 26100
### Additional context
Source code: https://github.com/datskiy/TreeViewScrollingIssue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked TreeViewScrollingIssue reproduction and rapidly scrolling the TreeView up and down. Use the reported exception and stack trace to inspect MainWindow.g.cs, especially MainWindow_obj3_Bindings.SetDataRoot and ProcessBindings. Done means reproducing the scenario without an unhandled crash and validating the behavior against the supplied repro.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100