UICollectionView's cellForItemAtIndexPath returns repeated and out-of-order index paths with quick scrolling
| Originator: | ryan.mcmanus10 | ||
| Number: | rdar://25815761 | Date Originated: | 4/19/2016 |
| Status: | Open | Resolved: | |
| Product: | tvOS SDK | Product Version: | tvOS 9.2 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
There appears to be an issue with quickly scrolling UICollectionViews on tvOS that causes the reported index path in cellForItemAtIndexPath to return randomly. See below for example of index paths coming back when swiping quickly:
<NSIndexPath: 0xc000000001200016> {length = 2, path = 0 - 9}
<NSIndexPath: 0xc000000001000016> {length = 2, path = 0 - 8}
<NSIndexPath: 0xc000000000e00016> {length = 2, path = 0 - 7}
<NSIndexPath: 0xc000000000c00016> {length = 2, path = 0 - 6}
<NSIndexPath: 0xc000000000a00016> {length = 2, path = 0 - 5}
<NSIndexPath: 0xc000000000800016> {length = 2, path = 0 - 4}
<NSIndexPath: 0xc000000001200016> {length = 2, path = 0 - 9}
<NSIndexPath: 0xc000000000600016> {length = 2, path = 0 - 3}
<NSIndexPath: 0xc000000000400016> {length = 2, path = 0 - 2}
<NSIndexPath: 0xc000000000200016> {length = 2, path = 0 - 1}
<NSIndexPath: 0xc000000001000016> {length = 2, path = 0 - 8}
<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}
<NSIndexPath: 0xc000000000e00016> {length = 2, path = 0 - 7}
<NSIndexPath: 0xc000000000c00016> {length = 2, path = 0 - 6}
<NSIndexPath: 0xc000000000a00016> {length = 2, path = 0 - 5}
<NSIndexPath: 0xc000000000800016> {length = 2, path = 0 - 4}
<NSIndexPath: 0xc000000000600016> {length = 2, path = 0 - 3}
<NSIndexPath: 0xc000000000400016> {length = 2, path = 0 - 2}
<NSIndexPath: 0xc000000000200016> {length = 2, path = 0 - 1}
The index paths appear to jump around as reuse occurs. This does not cause problems when the UI is updated synchronously (in this case, setting a label on each cell that merely displays the index path); it does, however, cause problems when attempting to asynchronously fetch images from the network.
This occurs in a single collection view that is either horizontal or vertical, and also occurs in an embedded collection view where the cells contain collection views (where the problem originated from).
This is NOT an issue when collection views are navigated by touch instead of swipe.
Steps to Reproduce:
1. Create UICollectionView in storyboard.
2. Set up appropriate delegate and data source methods.
3. Add NSLog statement in cellForItemAtIndexPath that returns the current index path
4. Tap through collection view, and then swipe through. Notice index paths returned come back in a different order in each case
Expected Results:
Though it's touch to equate this to iOS (the ability to tap and swipe differentiates it from iOS' purely swipe environment), would expect both methods of navigation to return the same index paths for cellForItemAtIndexPath in the same order.
Actual Results:
Index paths from cellForItemAtIndexPath should match which index paths are about to be displayed, instead of jumping around.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!