Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Crash in CollectionView on iOS on CollectionChanged: SIGABRT: Index was out of range. #12256

Closed
lafritay opened this issue Sep 25, 2020 · 7 comments
Labels
a/collectionview p/iOS 🍎 s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. s/unverified New report that has yet to be verified t/bug 🐛

Comments

@lafritay
Copy link

lafritay commented Sep 25, 2020

Description

I've observed this crash in production and so far on iOS only. I have not been able to get a repro locally, though I will continue to try. Here is the stack trace:

SIGABRT: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

List`1[T].get_Item (System.Int32 index)
IList.get_Item (System.Int32 index)
ObservableItemsSource.ElementAt (System.Int32 index)
ObservableItemsSource.get_Item (System.Int32 index)
ObservableItemsSource.get_Item (Foundation.NSIndexPath indexPath)
ItemsViewController`1[TItemsView].UpdateTemplatedCell (Xamarin.Forms.Platform.iOS.TemplatedCell cell, Foundation.NSIndexPath indexPath)
ItemsViewController`1[TItemsView].GetCell (UIKit.UICollectionView collectionView, Foundation.NSIndexPath indexPath)
ItemsViewController`1[TItemsView].GetPrototype ()
ItemsViewLayout.DetermineCellSize ()
ListViewLayout.ConstrainTo (CoreGraphics.CGSize size)
ItemsViewLayout.UpdateConstraints (CoreGraphics.CGSize size)
ItemsViewLayout.InvalidateLayout ()
(wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr)
UICollectionView.ReloadData ()
ObservableItemsSource.Reload ()
ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args)
ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args)
AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state)
NSAsyncSynchronizationContextDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)

Steps to Reproduce

Unknown at this point. From my telemetry, I think the following is happening:

  1. Show page1 with CollectionView that is completely loaded.
  2. Push page2 onto Navigation stack.
  3. Click action on page2 that causes a modal to show and pops page2 so that page1 is showing under the modal.
  4. Dismiss the modal.
  5. When the modal is dismissed, page1 and the CollectionView on it will update itself, repopulating the ObservableCollection in it's view. The crash happens on this update.

Expected Behavior

No Crash

Actual Behavior

Crash

Basic Information

  • Version with issue: 4.7.0.1351
  • Last known good version: unknown
  • IDE: VS
  • Platform Target Frameworks:
    • iOS: 13.7
  • Affected Devices: Have seen this on iPhone7, XS and iPhone 11 Pro Max so I think it's safe to say it's not device related.

Workaround

None at this point.

@lafritay lafritay added s/unverified New report that has yet to be verified t/bug 🐛 labels Sep 25, 2020
@rmarinho
Copy link
Member

Hi @lafritay I tried to reproduce your sample but wasn't able too. I did my best following the steps you gave us but everything works.

Can you please change the sample in attach to make it reproduce the issue?!

Thanks!

Issue12256.zip

@rmarinho rmarinho added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Sep 25, 2020
@lafritay
Copy link
Author

@rmarinho What OS / Platform / Device did you test on?

@lafritay
Copy link
Author

lafritay commented Sep 25, 2020

@rmarinho Sorry, I thought this was a different bug. No, the repro won't happen everytime. It's likely a timing issue in ItemsViewController and it only happens rarely.

@ClaytonIndustries
Copy link

I've seen this as well in 4.7 / 4.8 when changing the item source on the CollectionView. Doesn't happen every time as well

@lafritay
Copy link
Author

@samhouts @rmarinho I've updated the original post to contain information about different devices we're seeing this on. Just wanted to let you know that it isn't limited to iPhone 7. We're starting to get more reports of this crash every day. What else can we provide to help get traction on diagnosing this or coming up with a workaround?

@rmarinho
Copy link
Member

What would help us a lot would be a reproduction, can you try to change the sample I uploaded to mimic what you have? the item template, the way you refresh data etc?!

Thanks

@lafritay
Copy link
Author

@rmarinho @samhouts After adding some instrumentation, I was able to determine that we're actually hitting this bug:

#12080

Please dupe this on that one. I'll follow up with more information there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/collectionview p/iOS 🍎 s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
Development

No branches or pull requests

3 participants