Commit a913e963 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Work around NSInternalInconsistencyException startup crash.

On small form factor devices (iPhone SE, 5, 5s, iPods), an edge case is
causing an NSInternalInconsistencyException exception and crash immediately
on startup.  The problem only seems to present on devices with VoiceOver
enabled as UIKit functions slightly differently when laying out a
UICollectionView.

By merging the batch updates when adding suggestions, we can work around
the exception.  crbug.com/881647 has a longer discussion about the cause and
resolution.

Bug: 881647
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I0503957ee73edb57a6d978df4338fc76e0370062
Reviewed-on: https://chromium-review.googlesource.com/1234216
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592747}
parent a9abce3b
......@@ -139,14 +139,11 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
- (void)addSuggestions:(NSArray<CSCollectionViewItem*>*)suggestions
toSectionInfo:(ContentSuggestionsSectionInformation*)sectionInfo {
[self.collectionView performBatchUpdates:^{
void (^batchUpdates)(void) = ^{
NSIndexSet* addedSections = [self.collectionUpdater
addSectionsForSectionInfoToModel:@[ sectionInfo ]];
[self.collectionView insertSections:addedSections];
}
completion:nil];
[self.collectionView performBatchUpdates:^{
NSIndexPath* removedItem = [self.collectionUpdater
removeEmptySuggestionsForSectionInfo:sectionInfo];
if (removedItem) {
......@@ -157,8 +154,9 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
[self.collectionUpdater addSuggestionsToModel:suggestions
withSectionInfo:sectionInfo];
[self.collectionView insertItemsAtIndexPaths:addedItems];
}
completion:nil];
};
[self.collectionView performBatchUpdates:batchUpdates completion:nil];
}
- (NSInteger)numberOfSuggestionsAbove:(NSInteger)section {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment