-
Notifications
You must be signed in to change notification settings - Fork 596
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
Crash in performBatchUpdates #71
Comments
Seems crash occurs if you leave the ChatViewController while row add animation is in progress. Actually it only appears if you add random text messages to .Top and to .Bottom. I've reproduced it here https://github.com/weyg/Chatto. (have a look at diff). |
@weyg That's awesome, thank you very much!. Fix is on the way :) |
Reproduced under iOS 8.1 and 9.2. |
I couldn't reproduce the crash with your code in dev branch. Assuming it's just trickier to get across. #72 should fix it |
Can't reproduce either. Seems that #72 really fixes the issue. But now its much more slower than before. Main thread is used massively. (it happens after entering/leaving several chats). But it really may be caused by some bad approach I'm using for appending/prepending messages. |
Yes, your NSTimer is retaining the ViewController so it keeps inserting items forever. |
Ignorant mistake:( Fixed it out and all works like a charm. Can't reproduce the crash with the same steps anymore. @diegosanchezr any guesses about the reason of the crash? |
Looks like performBatchUpdates may trigger a layout of the UICollectionView before handling any changes. In that case, the UICollectionViewLayout can be also invalidated; but because we had updated the model it would return attributes for new items. Apple example also modifies the datasource inside the batch block (https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/CreatingCellsandViews/CreatingCellsandViews.html#//apple_ref/doc/uid/TP40012334-CH7-SW7) |
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0x1cc284a0> {length = 2, path = 0 - 114}'
Seen on iOS 8. No steps to reproduce known.
The text was updated successfully, but these errors were encountered: