-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[CollectionView] Fix crash on iOS adding items (ObservableCollection) #7711
Conversation
retarget 4.3 and a UItest pleaaasseeee :) |
@jsuarezruiz needs rebase. also, a uitest would be snazzy |
I'm encountering this error lately when I go from 0 items to adding an item to the items source after CollectionView is rendered. |
@jsuarezruiz please rebase :) |
@samhouts Done!. This is an issue repeated several times, what do you think if I include several tests? |
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7678.cs
Show resolved
Hide resolved
We have a gallery for this case in CollectionView no? maybe we just need to add more UItests to that gallery |
@RhomGit |
@berlamont Thanks for your advice, I have taken a look and it works as you say, excellent. Unfortunately (or fortunately since we didn't roll it out) our workaround for this issue did not work but at least now we have something to test against. |
Failing unit test? |
@jsuarezruiz Also, please retarget to 4.3.0 |
de9d0ae
to
0fd21db
Compare
Description of Change
Both, CollectionView and CarouselView, had a crash when adding items to a binder ObservableCollection (mainly played using asynchronous calls, etc.).
The native error was something like:
"Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (1), plus or minus the number of items inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out)".
NOTE: We could get the same error in other cases (removing items, etc).
Using performBatchUpdates the item count returned by collectionView(_:numberOfItemsInSection:) should be sync with the updates made inside. We had a mismatch sometimes between the number of items in the ObservableCollection and the UICollectionView.
This article describe a similar issue: https://fangpenlin.com/posts/2016/04/29/uicollectionview-invalid-number-of-items-crash-issue/
Issues Resolved
API Changes
None
Platforms Affected
Behavioral/Visual Changes
None
Before/After Screenshots
Before
After
Testing Procedure
Launch Core Gallery and navigate to the Issue 7678. Without a crash, everything is working fine.
PR Checklist