-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Allow observable source update while CollectionView is not visible #13678
Conversation
CollectionView updates while CollectionView is hidden; fixes #13126
Fantastic @hartez! Is there a package with this fix I could test? |
Only force layout on transition from invisible to visible Move cell size cache to layout and clear cache on size change (e.g., rotation) Use ItemsView size for constraints when possible;
@Tommigun1980 you can try the packages inside the artifacts folder / Nuget |
UWP and Android test failures are utterly unrelated. iOS 14 failures are the known ListView issues. |
Thank you. Tested with this package and the issue was unfortunately not fixed in my app. I still have to do the following after populating the CollectionView in order for its items to become visible: var items = this.myCollectionView.ItemsSource;
this.myCollectionView.ItemsSource = null;
this.myCollectionView.ItemsSource = items; If I don't do the above, it will display the EmptyView. A hot reload also makes the contents draw properly. |
We are experiencing the same (or similar) issue, with the same exception. We are using a view with two tabs, where each tabs has a separate view model with separate ObservableCollection. Collection view has grouped items, with sticky list header behaviour disabled. Downloaded the above NuGet packages and updated locally to verify this issue has been resolved.
Tried workarounds:
Maybe the above information is useful for further troubleshooting. |
@Tommigun1980 I thought it was odd that it didn't work, because I basically just copied your repro project from 13126 as my test case for this. But you're right - applying this nuget package to the repro project does not work. However, if I apply the nuget package to your repro project and then comment out the So now I need to figure out what the XamarinUniversity.Infrastructure package's "OptimizedObservableCollection" is doing that's thwarting the ObservableItemsSource. |
@timvandenhof Your issue sounds like a different problem; your situation is crashing (not just remaining blank) and you're using a grouped collection. Can you open an issue? And if you can provide a small repro project, that would help a lot. It sounds like your problem might be a grouped version of issue #7700. |
@Tommigun1980 Okay, looking at OptimizedObservableCollection, it looks like when the mass update object is Disposed the collection raises a Reset event. Which should just trigger a full UICollectionView.ReloadData(), but I'm guessing there's a timing/race condition we're not accounting for. I'll add another test case for a reset and see what I can find. |
Thank you @hartez. Yeah the OptimizedObservableCollection suspends the updates when it is populated, and only sends out one Reset when done. Thank you so much for fixing these!! |
Description of Change
Fix timing issue where CollectionView items are added to ObservableSource before CollectionView is visible, and CollectionView is later made visible via Binding.
Issues Resolved
API Changes
None
Platforms Affected
Behavioral/Visual Changes
None
Before/After Screenshots
Not applicable
Testing Procedure
Automated UI test.
PR Checklist