microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

ListView throws ArgumentOutOfRangeException when CollectionChanged is handled with Action = Reset

Open bengavin opened this issue 1 year ago • 3 comments

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:

Screenshot 2024-05-23 at 7 32 34 AM

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

  1. Bind a ListView to an ObservableCollection<>
  2. Perform an operation that results in a NotifyCollectionChangedAction.Reset action
  3. Do this many times, best if you can manage it while the list is in the middle of re-rendering
  4. 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?

bengavin avatar May 23 '24 13:05 bengavin

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:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar May 23 '24 13:05 github-actions[bot]

@bengavin can you please provide a standalone winui3 repro project please ?

ranjeshj avatar Jun 28 '24 17:06 ranjeshj

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

bengavin avatar Jul 01 '24 17:07 bengavin

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.