diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index b6ad45215..1431fe65d 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -3468,28 +3468,40 @@ typedef enum : NSUInteger { } }; - if (shouldAnimateUpdates) { - [self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion]; - } else { - // HACK: We use `UIView.animateWithDuration:0` rather than `UIView.performWithAnimation` to work around a UIKit - // Crash like: - // - // *** Assertion failure in -[ConversationViewLayout prepareForCollectionViewUpdates:], - // /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UICollectionViewLayout.m:760 - // *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'While - // preparing update a visible view at {length = 2, path = 0 - 142} wasn't - // found in the current data model and was not in an update animation. This is an internal error.' - // - // I'm unclear if this is a bug in UIKit, or if we're doing something crazy in - // ConversationViewLayout#prepareLayout. To reproduce, rapidily insert and delete items into the conversation. - // See `DebugUIMessages#thrashCellsInThread:` - [UIView animateWithDuration:0.0 + @try { + if (shouldAnimateUpdates) { + [self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion]; + } else { + // HACK: We use `UIView.animateWithDuration:0` rather than `UIView.performWithAnimation` to work around a + // UIKit Crash like: + // + // *** Assertion failure in -[ConversationViewLayout prepareForCollectionViewUpdates:], + // /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UICollectionViewLayout.m:760 + // *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'While + // preparing update a visible view at {length = 2, path = 0 - 142} + // wasn't found in the current data model and was not in an update animation. This is an internal + // error.' + // + // I'm unclear if this is a bug in UIKit, or if we're doing something crazy in + // ConversationViewLayout#prepareLayout. To reproduce, rapidily insert and delete items into the + // conversation. See `DebugUIMessages#thrashCellsInThread:` + [UIView + animateWithDuration:0.0 animations:^{ [self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion]; if (scrollToBottom) { [self scrollToBottomAnimated:shouldAnimateUpdates]; } }]; + } + } @catch (NSException *exception) { + OWSFail(@"%@ exception: %@ of type: %@ with reason: %@, user info: %@.", + self.logTag, + exception.description, + exception.name, + exception.reason, + exception.userInfo); + @throw exception; } self.lastReloadDate = [NSDate new];