-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CollectionView crashes/behaves weird when ObservableCollection updated quickly #7237
Comments
repro on IOS with vs main build[32516.290.main] |
There's a very similar issue with CollectionView when adding and clearing items quickly that even existed on XF: xamarin/Xamarin.Forms#13268 In my own app, I have to use a bunch of Task.Delay(50) or else the collection view throws a fatal exception identical to the one linked. |
I just ran into the issue that @emorell96 mentioned. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Workaround for me was to instantiate a new ObservableCollection. Not ideal for memory usage but didn't need hardcoded delays. |
@KieranMaclagan Can You Please Share The Simple Code !!
The error has been fixed, but the new results items are not Binding in the CollectionView !? |
Using ObservableRangeCollection may help, you can use colleciton.AddRange(items) to add items, which is provided by a third-party nuget package (Refractored.MvvmHelpers). |
That works great for me, but I still need some of the tasks.Delay(50) Before Add The Range. |
I appreciate the Delay(50) advice, but with latest .Net MAUI and collection view, that is not reliably working for me, not even at 100ms. Running inserts / removes in main thread seemed to help, but makes app less responsive. I think the iOS handler fix would be simple, but I don't know how to override / replace it, sadly. I finally resorted to using SfListView from Syncfusion -- it took my same templates, so I only had to adjust a few parameters and it worked right away. Not only does it avoid crashing, but also helps work around the default CollectionView's tendency to layout landscape mode on potrait phone screen on iOS. Telerik also has a similar control. I also wrote my own view, but could not get the tap / hold I need on items working reliably with my list contained in a scrollview control. Hopefully this is fixed sometime soon or a free one is out there, but for those as desperate as I was, at least there is a paid option that works. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This was how I managed to solve the issue on my end. I had a similar issue today when I was testing a solution on an iOS emulator. This is done in the MVVM pattern.
|
thanks for your reply @ITPDevAruba I had a workaround for our case too: Not so pretty, but it works ;) |
Any news on this? I don't see any progress or linked PRs/discussions for this? Not even for .Net 8
|
@samhouts, could you triage this bug? For GA .net8 or even better with a backport to 7 would be swell! I was able to reproduce it in both .net8 (latest preview) and .net7 but it seems a lot more stable on .net8. Interestingly the selected item isn't removed once you go back with a swipe gesture but it is if you go back with the toolbar button it will. |
@DDHSchmidt, does this workaround really work for you? if i do a bound DevExpress.Data.XtraReports.ObservableRangeCollection and set it's content to a temporary ObservableRangeCollection it renders an empty collection. Same is true for a normal ObserverableCollection (tested .net7 ios16) |
Yep, I'm going to add this one to NET 8 GA because I'm concerned that workarounds for this problem will exacerbate #16125. It looks like @jfversluis has a PR for Forms that either fixes or reduces the crashes, so maybe that's a place to start! xamarin/Xamarin.Forms#15439 |
Hm yeah I think I didn't merge that PR because it didn't seem to fix the issue, but it also introduced a massive performance hit. So there is still work to do on this one! Also, the Forms PR talks about grouped CollectionViews specifically and looking at this one it isn't grouped, right? Just to make sure we're looking at the right things here. Trying on the latest .NET 8 bits, it seems to work for me on the branch that is posted @michaelstonis. Any chance you might be able to test that? Also on the latest .NET 7 bits I can't reproduce it with the given reproduction in the first post. Is there another reproduction I could try from someone? |
Hi @michaelstonis. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version. You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Verified this issue with Visual Studio Enterprise 17.8.0 Preview 1.0. Not repro on iOS platforms with sample project. |
Will this be fixed in .NET 7 as well? |
Description
If I have a view model with an
ObservableCollection<T>
bound to aCollectionView
. From the view model, I perform aClear
and thenAdd
, it will crash out on iOS and macOS. On macOS, the application will sometimes not crash, but the items for theCollectionView
will not appear.Steps to Reproduce
The crash is being triggered from code in
eShopOnContainers/ViewModels/ObservableCollectionEx.cs
. There are two methods namedReloadData
which clear and reload the items of theObservableCollection
Version with bug
Release Candidate 3 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS, macOS
Affected platform versions
macOS Monterey, iOS 15.4
Did you find any workaround?
Yes, if I handle the list updates and delay notification of changes, it will respond appropriately. Modified versions of the
ReloadData
methods are provided ineShopOnContainers/ViewModels/ObservableCollectionEx.cs
that will avoid this crash.Relevant log output
The text was updated successfully, but these errors were encountered: