Skip to content
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 when scrolling quickly through chat history #817

Closed
chrisballinger opened this issue Jul 27, 2017 · 15 comments
Closed

Crash when scrolling quickly through chat history #817

chrisballinger opened this issue Jul 27, 2017 · 15 comments

Comments

@chrisballinger
Copy link
Member

Regression caused by #812

cc @stigger

Application Specific Information:
*** 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: 0x13398d420> index path: (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (0 0; 414 32); zIndex = 10;  to <JSQMessagesCollectionViewLayoutAttributes: 0x131ef8640> index path: (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (0 0; 414 32); zIndex = -1;  without invalidating the layout'

Thread 0 Crashed:
0   CoreFoundation                  0x000000018878afe0 __exceptionPreprocess + 124
1   libobjc.A.dylib                 0x00000001871ec538 objc_exception_throw + 52
2   CoreFoundation                  0x000000018878aeb4 +[NSException raise:format:arguments:] + 100
3   Foundation                      0x0000000189223760 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 108
4   UIKit                           0x000000018e9195c8 __45-[UICollectionViewData validateLayoutInRect:]_block_invoke + 1324
5   UIKit                           0x000000018e918ad4 -[UICollectionViewData validateLayoutInRect:] + 1492
6   UIKit                           0x000000018f1fb184 -[UICollectionViewData layoutAttributesForCellsInRect:validateLayout:] + 144
7   UIKit                           0x000000018f1b79f4 -[UICollectionView _computePrefetchCandidatesForVisibleBounds:futureVisibleBounds:prefetchVector:notifyDelegateIfNeeded:] + 128
8   UIKit                           0x000000018f1b7954 -[UICollectionView _computePrefetchCandidatesForVelocity:notifyDelegateIfNeeded:] + 164
9   UIKit                           0x000000018f1b7884 -[UICollectionView _prefetchItemsForVelocity:maxItemsToPrefetch:invalidateCandidatesOnDirectionChanges:] + 764
10  UIKit                           0x000000018e9181ac -[UICollectionView layoutSubviews] + 700
11  UIKit                           0x000000018e8b9cc0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1196
12  QuartzCore                      0x000000018baaa274 -[CALayer layoutSublayers] + 144
13  QuartzCore                      0x000000018ba9ede8 CA::Layer::layout_if_needed(CA::Transaction*) + 288
14  QuartzCore                      0x000000018ba9eca8 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 28
15  QuartzCore                      0x000000018ba1a34c CA::Context::commit_transaction(CA::Transaction*) + 248
16  QuartzCore                      0x000000018ba413ac CA::Transaction::commit() + 500
17  QuartzCore                      0x000000018b99d530 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 596
18  IOKit                           0x00000001889f7b9c IODispatchCalloutFromCFMessage + 368
19  CoreFoundation                  0x0000000188721960 __CFMachPortPerform + 176
20  CoreFoundation                  0x0000000188739ae4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
21  CoreFoundation                  0x0000000188739284 __CFRunLoopDoSource1 + 432
22  CoreFoundation                  0x0000000188736d98 __CFRunLoopRun + 1748
23  CoreFoundation                  0x0000000188666da4 CFRunLoopRunSpecific + 420
24  GraphicsServices                0x000000018a0d1074 GSEventRunModal + 96
25  UIKit                           0x000000018e921c9c UIApplicationMain + 204
26  ChatSecure                      0x00000001000b5d78 main (main.m:14)
27  libdyld.dylib                   0x000000018767559c start + 0
@stigger
Copy link
Contributor

stigger commented Jul 27, 2017

I've tested extensively, but never seen this. What iOS version is that? Is it reproducible?

@chrisballinger
Copy link
Member Author

iOS 10.3.3 on the TestFlight build v4.1.1 (96) I put out last night. It's 100% reproducible but... it only happens on one of my conversations (the one with the longest history), while I try to scroll up faster than it can load the previous page.

@stigger
Copy link
Contributor

stigger commented Jul 27, 2017

Is that new build already published via TestFlight? I don't see it.

@chrisballinger
Copy link
Member Author

iTunes Connect is being very buggy, but I think I fixed the TestFlight invites.

@cringeops
Copy link

Confirm. iOS 10.3.3. If I scroll through the conversation fast enough, the app crashes.

@stigger
Copy link
Contributor

stigger commented Jul 28, 2017

Reproduced, will fix in the next couple of days.

@chrisballinger
Copy link
Member Author

@stigger Thanks! I think there are some related bugs as well:

  1. Incoming messages sometimes do not appear until you send another outgoing message (missing a call to JSQ's finishReceivingMessage somewhere). Someone else reported this issue and I was able to confirm it.
  2. JSQ's message bubbles are the wrong size and have the wrong contents. [noticed on iOS 11]

stigger added a commit to stigger/ChatSecure-iOS that referenced this issue Jul 29, 2017
chrisballinger added a commit that referenced this issue Aug 1, 2017
Fixing a crash and a couple of other issues introduced in a recent OTRMessagesViewController rework (#817)
@chrisballinger
Copy link
Member Author

Marking as fixed for now

@chrisballinger
Copy link
Member Author

Ok, still not fixed. Same exact crash still happening in v4.1.1 (98). :(

Also the screen flashes white when sending a message, or scrolls to the wrong place, which is new as of merging this PR. If we can't get these issues fixed in the next week or two I'll have to revert the merge and push it back.

@chrisballinger chrisballinger reopened this Aug 3, 2017
@stigger
Copy link
Contributor

stigger commented Aug 3, 2017

I'll have to revert the merge

Please don't, it will be fixed.

@stigger
Copy link
Contributor

stigger commented Aug 4, 2017

I looked into the crash more closely, and apparently this is a bug in JSQMessagesViewController: jessesquires/JSQMessagesViewController#1424 (PR jessesquires/JSQMessagesViewController#1868 does not fix it).

The workaround is to comment out lines 312-314 in JSQMessagesCollectionViewFlowLayout.m. It seems that these lines are related to springiness, which is not used in ChatSecure, so this should be a safe change.

After that the layout invalidation, which I introduced in #823, can be removed.

@chrisballinger
Copy link
Member Author

@stigger Thanks for looking into that! I happen to have commit access to upstream JSQMessagesViewController now, but will probably continue maintaining our own fork for the most part.

@stigger
Copy link
Contributor

stigger commented Aug 6, 2017

Regarding the flashes and scrolling to the wrong place. I could not reproduce them (and never seen them while using the app normally), so I need some additional details.

@michaelkirk
Copy link

We recently fixed some similar looking crash in Signal.

This may or may not be useful for you:
https://github.com/WhisperSystems/JSQMessagesViewController/pull/14/files

@chrisballinger
Copy link
Member Author

Should be fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants