JSQMessagesViewController icon indicating copy to clipboard operation
JSQMessagesViewController copied to clipboard

App crashes whenever I scroll to the top

Open jayisidoro opened this issue 11 years ago • 5 comments

After the messages have finished loading and being inserted, I attempt to scroll to the top and the app crashes. I'm getting this error, but i'm not sure why:

*** Assertion failure in -[UICollectionViewData validateLayoutInRect:], /SourceCache/UIKit/UIKit-3347.44/UICollectionViewData.m:435 2015-05-19 10:37:19.630 FestFeed[4261:1044865] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'layout attributes for supplementary item at index path (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}) changed from <JSQMessagesCollectionViewLayoutAttributes: 0x12dd7d980> index path: (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (0 0; 320 32); zIndex = -1; to <JSQMessagesCollectionViewLayoutAttributes: 0x12dd7efd0> index path: (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (0 -70.812; 320 32); zIndex = -1; without invalidating the layout' *** First throw call stack: (0x1821ac2d8 0x1939780e4 0x1821ac198 0x183060ed4 0x186c4b174 0x186c4a86c 0x186c49fa4 0x186be9760 0x186531e1c 0x18652c884 0x18652c728 0x18652bebc 0x18652bc3c 0x186525364 0x1821642a4 0x182161230 0x182161610 0x18208d2d4 0x18b8ab6fc 0x186c52fac 0x1001055bc 0x193ff6a08) libc++abi.dylib: terminating with uncaught exception of type NSException

jayisidoro avatar May 19 '15 17:05 jayisidoro

note: it doesn't happen 100% of the time, but randomly. not sure how to diagnose or solve the problem; any and all help is appreciated!

jayisidoro avatar May 19 '15 17:05 jayisidoro

figured it out: it was the springy cell option being enabled

jayisidoro avatar May 19 '15 22:05 jayisidoro

I'm having the exact same error, springiness is not enabled -- iOS 8.3, JSQ 7.0.2.

jalehman avatar May 26 '15 16:05 jalehman

After some investigation, I found that this code was responsible for some of the crashes -- specifically when quickly scrolling to the top of the screen from the bottom:

if (isOutgoingMessage) {
    cell.messageBubbleTopLabel.textInsets = UIEdgeInsetsMake(0.0, 0.0, 0.0, 60)
} else {
    cell.messageBubbleTopLabel.textInsets = UIEdgeInsetsMake(0.0, 60, 0.0, 0.0)
}

I had introduced this after adding JSQPhotoMediaItems to our conversations, as for some reason the cell.messageBubbleTopLabels had adopted a strange left alignment. Upon removing the above code the issue stopped occurring in conversations that have no media messages (strangely, the messageBubbleTopLabels are now correctly aligned even without the above code). Conversations that have media messages still crash when scrolling to the top of the page...sometimes.

Seems to crash more often in conversations that have fairly large messages in them.

jalehman avatar May 26 '15 17:05 jalehman

@jalehman Did resolve this issue ?

ihorb10 avatar Apr 29 '16 21:04 ihorb10