Improve logging of conversation view exceptions.

pull/1/head
Matthew Chen 7 years ago
parent 84bda352ed
commit b3c19b7905

@ -3468,22 +3468,25 @@ typedef enum : NSUInteger {
} }
}; };
@try {
if (shouldAnimateUpdates) { if (shouldAnimateUpdates) {
[self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion]; [self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion];
} else { } else {
// HACK: We use `UIView.animateWithDuration:0` rather than `UIView.performWithAnimation` to work around a UIKit // HACK: We use `UIView.animateWithDuration:0` rather than `UIView.performWithAnimation` to work around a
// Crash like: // UIKit Crash like:
// //
// *** Assertion failure in -[ConversationViewLayout prepareForCollectionViewUpdates:], // *** Assertion failure in -[ConversationViewLayout prepareForCollectionViewUpdates:],
// /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UICollectionViewLayout.m:760 // /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 // *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'While
// preparing update a visible view at <NSIndexPath: 0xc000000011c00016> {length = 2, path = 0 - 142} wasn't // preparing update a visible view at <NSIndexPath: 0xc000000011c00016> {length = 2, path = 0 - 142}
// found in the current data model and was not in an update animation. This is an internal error.' // 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 // 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. // ConversationViewLayout#prepareLayout. To reproduce, rapidily insert and delete items into the
// See `DebugUIMessages#thrashCellsInThread:` // conversation. See `DebugUIMessages#thrashCellsInThread:`
[UIView animateWithDuration:0.0 [UIView
animateWithDuration:0.0
animations:^{ animations:^{
[self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion]; [self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion];
if (scrollToBottom) { if (scrollToBottom) {
@ -3491,6 +3494,15 @@ typedef enum : NSUInteger {
} }
}]; }];
} }
} @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]; self.lastReloadDate = [NSDate new];
} }

Loading…
Cancel
Save