Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Fix scrolling crash
Browse files Browse the repository at this point in the history
Don't touch the header zIndex at all, since we're not doing it
consistently, and we don't need it modified anyway.
  • Loading branch information
michaelkirk committed Aug 10, 2017
1 parent 7a7deff commit 146b84f
Showing 1 changed file with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,53 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
[self jsq_configureMessageCellLayoutAttributes:attributesItem];
}
else {
attributesItem.zIndex = -1;
// BEGIN HACK for Signal to fix scrolling crash.
//
// Signature of crash looks like this:
//
// 0 CoreFoundation 0x18cbe2fe0 __exceptionPreprocess + 124 (NSException.m:165)
// 1 libobjc.A.dylib 0x18b644538 objc_exception_throw + 56 (objc-exception.mm:521)
// 2 CoreFoundation 0x18cbe2eb4 +[NSException raise:format:arguments:] + 104 (NSException.m:131)
// 3 Foundation 0x18d67b760 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 112 (NSException.m:157)
// 4 UIKit 0x192d715c8 __45-[UICollectionViewData validateLayoutInRect:]_block_invoke + 1328 (UICollectionViewData.m:445)
// 5 UIKit 0x192d70ad4 -[UICollectionViewData validateLayoutInRect:] + 1496 (UICollectionViewData.m:559)
// 6 UIKit 0x193653184 -[UICollectionViewData layoutAttributesForCellsInRect:validateLayout:] + 148 (UICollectionViewData.m:885)
// 7 UIKit 0x19360f9f4 -[UICollectionView _computePrefetchCandidatesForVisibleBounds:futureVisibleBounds:prefetchVector:notifyDelegateIfNeeded:] + 132 (UICollectionView.m:2366)
// 8 UIKit 0x19360f954 -[UICollectionView _computePrefetchCandidatesForVelocity:notifyDelegateIfNeeded:] + 168 (UICollectionView.m:2361)
// 9 UIKit 0x19360f884 -[UICollectionView _prefetchItemsForVelocity:maxItemsToPrefetch:invalidateCandidatesOnDirectionChanges:] + 768 (UICollectionView.m:2308)
// 10 UIKit 0x192d701ac -[UICollectionView layoutSubviews] + 704 (UICollectionView.m:3586)
//
//
// Digging in a bit I can reliably reproduce the crash after ~10-30s of scrolling wildly while
// receiving messages (1/s). The failed assertion is:
//
// I verified that the problem goes away if we remove the "load earlier messages" supplemental view.
//
// For some reason, since prefetching was introduced in iOS10, this became more common.
//
// Another recent change in Signal wherein we're more aggressively invalidating our layout also made
// the occurrences of this crash jump.
//
// The actual assertion failure is like:
//
// layout attributes for supplementary item at index path (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}) changed from <JSQMessagesCollectionViewLayoutAttributes: 0x10ab8e860> index path: (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (0 0; 375 32); zIndex = 10; to <JSQMessagesCollectionViewLayoutAttributes: 0x10bc398f0> index path: (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (0 0; 375 32); zIndex = -1; without invalidating the layout
//
// Note the zIndex "changed" from 10 -> -1. This is the only place we touch the zIndex.
//
// The following line was introduced:
//
// commit 2c39325220e63535bc1a79b2d471e6c2e9d3d2a4
// Author: Jesse Squires <[email protected]>
// Date: Mon Jul 21 23:08:17 2014 -0700
//
// fix issue where header/footer failed to appear when springiness is enabled. close #409
//
// Since we're not using "springiness" we should be safe in disabling this.

// (Here's the actual code being commented out)
// attributesItem.zIndex = -1;

// END HACK for Signal to fix scrolling crash.
}
}];

Expand Down

0 comments on commit 146b84f

Please sign in to comment.