IGListKit icon indicating copy to clipboard operation
IGListKit copied to clipboard

Help identifying cause of crash

Open attheodo opened this issue 5 years ago • 1 comments

I have plenty crash occurrences, rooting from IGListAdapterUpdater that unfortunately due to the stack trace I cannot exactly pin point. Here's the stack trace:

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x1e5baf530 objc_msgSend + 16
1  UIKitCore                      0x212be2c58 -[UICollectionReusableView preferredLayoutAttributesFittingAttributes:] + 72
2  UIKitCore                      0x212be2bf8 -[UICollectionReusableView _preferredLayoutAttributesFittingAttributes:] + 48
3  UIKitCore                      0x212bb55c4 -[UICollectionView _checkForPreferredAttributesInView:originalAttributes:] + 468
4  UIKitCore                      0x212bb62b8 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 1512
5  UIKitCore                      0x212bb9f34 -[UICollectionView _updateVisibleCellsNow:] + 4068
6  UIKitCore                      0x212bbe8f4 -[UICollectionView layoutSubviews] + 324
7  UIKitCore                      0x21375aed0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1292
8  QuartzCore                     0x1eae71a20 -[CALayer layoutSublayers] + 184
9  QuartzCore                     0x1eae769c8 CA::Layer::layout_if_needed(CA::Transaction*) + 332
10 UIKitCore                      0x213746f04 -[UIView(Hierarchy) layoutBelowIfNeeded] + 544
11 IGListKit                      0x1015e0a8c __62-[IGListAdapterUpdater performBatchUpdatesWithCollectionView:]_block_invoke.58 + 168 (IGListAdapterUpdater.m:168)
12 IGListKit                      0x1015e02e0 -[IGListAdapterUpdater performBatchUpdatesWithCollectionView:] + 176 (IGListAdapterUpdater.m:176)
13 IGListKit                      0x1015e1f94 __55-[IGListAdapterUpdater _queueUpdateWithCollectionView:]_block_invoke + 393 (IGListAdapterUpdater.m:393)
14 libdispatch.dylib              0x1e63fca38 _dispatch_call_block_and_release + 24
15 libdispatch.dylib              0x1e63fd7d4 _dispatch_client_callout + 16
16 libdispatch.dylib              0x1e63dd9e4 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 1008
17 CoreFoundation                 0x1e694ec1c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
18 CoreFoundation                 0x1e6949b54 __CFRunLoopRun + 1924
19 CoreFoundation                 0x1e69490b0 CFRunLoopRunSpecific + 436
20 GraphicsServices               0x1e8b4979c GSEventRunModal + 104
21 UIKitCore                      0x2132c3978 UIApplicationMain + 212
22 Waldo                          0x1009d1af0 main + 18 (AppDelegate.swift:18)
23 libdyld.dylib                  0x1e640e8e0 start + 4

Looks like it's happening to one of my rather many collection views that utilize a specific UICollectionViewCell subclass as a re-usable view. I believe the offending code lies somewhere in here:

 override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
        
        setNeedsLayout()
        layoutIfNeeded()
        
        let size = contentView.systemLayoutSizeFitting(CGSize(width:  layoutAttributes.frame.width,
                                                              height: SectionSupplementaryView.cellHeight),
                                                       withHorizontalFittingPriority: UILayoutPriority.required,
                                                       verticalFittingPriority: UILayoutPriority.fittingSizeLevel)
        layoutAttributes.frame.size = size
        return layoutAttributes
        
    }

This subclass is interchangeably used inside a ListSingleSectionController as a cell and as a supplementary view but the problem seems to appear only when utilized as the latter.

For the shake of completeness, when utilized as a supplementary view, size is being dictated like this in the ListSupplementaryViewSource

func sizeForSupplementaryView(ofKind elementKind: String, at index: Int) -> CGSize {
        return CGSize(width: collectionContext!.containerSize.width, height: SectionSupplementaryView.cellHeight)
    }

If anyone has at least a mild idea or guesstimate on why this might be happening so I can start untangling it, I'd highly appreciate it! 🙏

attheodo avatar Aug 06 '19 11:08 attheodo