microsoft-ui-xaml
microsoft-ui-xaml copied to clipboard
ListView throws ArgumentOutOfRangeException when CollectionChanged is handled with Action = Reset
Describe the bug
Our team has run into a variant of this bug a number of times, where our MAUI ListView crashes on Windows when Reset(ing) the collection. An example error:
In this sample, the bound collection contains 2 items, but we've seen the error across collections of various sizes, and none of the collections contain more than 100 items. We have implemented workarounds to avoid removing the last item in a bound collection, which has lessened the frequency of the error, and the most recent 1.5 SDK -seems- to have improved things, but we're still seeing this error pop up. It feels a whole lot like a race condition of some sort, because certain machines are able to reproduce it more easily than others.
Steps to reproduce the bug
- Bind a ListView to an ObservableCollection<>
- Perform an operation that results in a NotifyCollectionChangedAction.Reset action
- Do this many times, best if you can manage it while the list is in the middle of re-rendering
- Observe this nonsense exception, since the underlying collection matches the constraints of the error
Expected behavior
The application does not crash and the ListView is re-bound to the specified list of items.
Screenshots
No response
NuGet package version
None
Windows version
Windows 11 (22H2): Build 22621
Additional context
A number of other bugs exist out here for similar behavior, which I'm sure the AI will helpfully link when I add this issue :). Many of them have been marked as 'Closed' without any sort of reference to a PR or official commentary to verify they are actually fixed and additional comments to the effect that the bug is still occurring. How else can we help to find the root cause so we can stabilize this aspect of the WinUI platform that we rely on for our MAUI Windows apps?
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!
Closed similar issues:
- clearing observable collection bound to ListView crashes with ArgumentOutOfRangeException (#8684), similarity score: 0.77
- Updating an ObservableCollection bound to a MenuItemsSource crashes with ArgumentOutOfRangeException (#8770), similarity score: 0.76
- Binding can cause Catastrophic Failures (#6612), similarity score: 0.74
- ListView/GridView crashes with incremental loading (#6921), similarity score: 0.73
- UWP ListView Touch Unhandled Win32 Exception (#8434), similarity score: 0.73
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
@bengavin can you please provide a standalone winui3 repro project please ?
@ranjeshj - I'm in the process of putting a repro project together, but thus far, I've been unable to make this happen. I'm digging through the MAUI infrastructure to see if I can pull out enough of the relevant pieces to get a repro put together, but it's proving more difficult than I had initially suspected. I've not yet given up as of yet, as we're still seeing the error occur, and it is definitely flowing out of the ABI layer, which feels 'too low' for this to be a MAUI issue specifically.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.