Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Conversation

@3lvis
Copy link
Owner

@3lvis 3lvis commented Dec 4, 2016

This resolves the crash presented in issue #559. I think is likely because the layout is computing different states at the same time, first the scrolling, then the enabling and then processing the targets, adding some delay fixes the issue. Also, it seems like UIView performWithoutAnimation wasn't working as it should, so I had to update that as well.

This crash only occurs on iOS 10.

@jeffleeismyhero
Copy link
Collaborator

@3lvis this issue is still present with this branch. See below.

form-nsrangeexception-3lvis

2016-12-06 15:26:30.380 Basic-ObjC[62802:16560723] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 7 beyond bounds [0 .. 6]'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000107d1234b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010777321e objc_exception_throw + 48
	2   CoreFoundation                      0x0000000107c43f1b -[__NSArrayM objectAtIndex:] + 203
	3   UIKit                               0x000000010923637d -[_UIFlowLayoutSection frameForItemAtIndexPath:] + 155
	4   UIKit                               0x00000001091d1eb5 -[UICollectionViewFlowLayout _frameForItem:inSection:usingData:] + 159
	5   UIKit                               0x00000001091cba72 -[UICollectionViewFlowLayout layoutAttributesForItemAtIndexPath:usingData:] + 561
	6   UIKit                               0x00000001091cbd23 -[UICollectionViewFlowLayout layoutAttributesForItemAtIndexPath:] + 406
	7   Form                                0x0000000107056c8c -[FORMLayout layoutAttributesForDecorationViewOfKind:atIndexPath:] + 796
	8   Form                                0x0000000107057ae6 -[FORMLayout layoutAttributesForElementsInRect:] + 1526
	9   UIKit                               0x00000001091ecbe0 __45-[UICollectionViewData validateLayoutInRect:]_block_invoke + 241
	10  UIKit                               0x00000001091ec4e3 -[UICollectionViewData validateLayoutInRect:] + 2984
	11  UIKit                               0x00000001091ef7ae -[UICollectionViewData layoutAttributesForCellsInRect:validateLayout:] + 170
	12  UIKit                               0x0000000109189d59 -[UICollectionView _computePrefetchCandidatesForVisibleBounds:futureVisibleBounds:prefetchVector:notifyDelegateIfNeeded:] + 134
	13  UIKit                               0x0000000109189cc7 -[UICollectionView _computePrefetchCandidatesForVelocity:notifyDelegateIfNeeded:] + 214
	14  UIKit                               0x0000000109189bdd -[UICollectionView _prefetchItemsForVelocity:maxItemsToPrefetch:invalidateCandidatesOnDirectionChanges:] + 934
	15  UIKit                               0x0000000109192ef7 -[UICollectionView layoutSubviews] + 717
	16  UIKit                               0x000000010890a344 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
	17  QuartzCore                          0x000000010d0cfcdc -[CALayer layoutSublayers] + 146
	18  QuartzCore                          0x000000010d0c37a0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
	19  UIKit                               0x00000001088f83e4 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1507
	20  UIKit                               0x00000001091ab498 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] + 252
	21  UIKit                               0x00000001091ab379 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 91
	22  UIKit                               0x00000001091ab2fb -[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 74
	23  UIKit                               0x00000001091ab250 -[UICollectionView performBatchUpdates:completion:] + 53
	24  Form                                0x0000000107035efa -[FORMDataSource insertItemsAtIndexPaths:] + 378
	25  Form                                0x000000010703cea9 __38-[FORMDataSource startProcessTargets:]_block_invoke + 649
	26  Form                                0x000000010706430f +[FORMTarget filteredTargets:filtered:] + 1199
	27  Form                                0x000000010703cbf0 -[FORMDataSource startProcessTargets:] + 160
	28  Foundation                          0x00000001072b8f48 __NSFireDelayedPerform + 417
	29  CoreFoundation                      0x0000000107ca4964 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
	30  CoreFoundation                      0x0000000107ca45f3 __CFRunLoopDoTimer + 1075
	31  CoreFoundation                      0x0000000107ca417a __CFRunLoopDoTimers + 250
	32  CoreFoundation                      0x0000000107c9bf01 __CFRunLoopRun + 2065
	33  CoreFoundation                      0x0000000107c9b494 CFRunLoopRunSpecific + 420
	34  GraphicsServices                    0x000000010c8dfa6f GSEventRunModal + 161
	35  UIKit                               0x0000000108845f34 UIApplicationMain + 159
	36  Basic-ObjC                          0x0000000106f7fd4f main + 111
	37  libdyld.dylib                       0x000000010b1fd68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

@3lvis 3lvis closed this Feb 11, 2017
@3lvis 3lvis deleted the fix/exception-when-enabling-and-running-targets-at-the-same-time branch February 11, 2017 07:42
@3lvis
Copy link
Owner Author

3lvis commented Feb 11, 2017

Damn, @jeffleeismyhero. 🤷‍♂️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants