diff --git a/Signal/src/ViewControllers/ConversationView/MessagesViewController.m b/Signal/src/ViewControllers/ConversationView/MessagesViewController.m index 672cfc3ba..e4327ae67 100644 --- a/Signal/src/ViewControllers/ConversationView/MessagesViewController.m +++ b/Signal/src/ViewControllers/ConversationView/MessagesViewController.m @@ -1645,7 +1645,7 @@ typedef enum : NSUInteger { break; } default: { - DDLogWarn(@"using default cell constructor for message: %@", message); + OWSFail(@"using default cell constructor for message: %@", message); cell = (JSQMessagesCollectionViewCell *)[super collectionView:collectionView cellForItemAtIndexPath:indexPath]; break; @@ -1751,7 +1751,6 @@ typedef enum : NSUInteger { #pragma mark - Adjusting cell label heights - /** Due to the usage of JSQMessagesViewController, and it non-conformity to Dynamyc Type we're left to our own devices to make this as usable as possible. @@ -3260,6 +3259,18 @@ typedef enum : NSUInteger { return; } + // HACK to work around radar #28167779 + // "UICollectionView performBatchUpdates can trigger a crash if the collection view is flagged for layout" + // more: https://github.com/PSPDFKit-labs/radar.apple.com/tree/master/28167779%20-%20CollectionViewBatchingIssue + // This was our #2 crash, and much exacerbated by the refactoring somewhere between 2.6.2.0-2.6.3.8 + // + // NOTE: It's critical we do this before beginLongLivedReadTransaction. + // layoutIfNeeded triggers layout (obviously) which will update our cells using the current mappings + // but loading cells using interactionAtIndexPath: and messageAtIndexPath:, which will return the + // wrong results if the db connection has been updated but the mappings haven't. + [self.collectionView layoutIfNeeded]; + // ENDHACK to work around radar #28167779 + // We need to `beginLongLivedReadTransaction` before we update our // models in order to jump to the most recent commit. NSArray *notifications = [self.uiDatabaseConnection beginLongLivedReadTransaction]; @@ -3286,13 +3297,6 @@ typedef enum : NSUInteger { return; } - // HACK to work around radar #28167779 - // "UICollectionView performBatchUpdates can trigger a crash if the collection view is flagged for layout" - // more: https://github.com/PSPDFKit-labs/radar.apple.com/tree/master/28167779%20-%20CollectionViewBatchingIssue - // This was our #2 crash, and much exacerbated by the refactoring somewhere between 2.6.2.0-2.6.3.8 - [self.collectionView layoutIfNeeded]; - // ENDHACK to work around radar #28167779 - NSArray *messageRowChanges = nil; NSArray *sectionChanges = nil; [[self.uiDatabaseConnection ext:TSMessageDatabaseViewExtensionName]