apptekstudios / ASCollectionView

A SwiftUI collection view with support for custom layouts, preloading, and more.
MIT License
1.35k stars 160 forks source link

IOS16: NSInternalInconsistencyException: UICollectionViewLayoutAttributes: -setSize: requires finite dimensions #243

Open dreampowder opened 1 year ago

dreampowder commented 1 year ago

Hello, first of all, thanks a lot for this wonderful library.

From time to time, i see a random crash log in crashlytics, which i couldn't reproduce on my side whatever i do.

Fatal Exception: NSInternalInconsistencyException
UICollectionViewLayoutAttributes: -setSize: requires finite dimensions <UICollectionViewLayoutAttributes: 0x14b2c0140> index path: (1-0); element kind: (groupBackground); frame = (0 377.667; 390 294.333); alpha = 0; - {inf, inf}

the groupBackground is registered like this:

    var collectionViewLayouts:ASCollectionLayout<SeasonScreenSections>{
        let layout =  ASCollectionLayout<SeasonScreenSections>(scrollDirection: .vertical, interSectionSpacing: 0.0,layoutPerSection: {sectionId in
            switch(sectionId){
            case .beatpacks:
                return SeasonLayoutGenerator.beatpackLayout(columnCount: 2)
            case .spotlight:
                return SeasonLayoutGenerator.beatpackLayout(columnCount: 1)
            case .creators:
                return SeasonLayoutGenerator.creatorLayout()
            case .season_header:
                return SeasonLayoutGenerator.seasonHeaderLayout(height: seasonImgHeight ?? 0)
            }
        }).decorationView(GroupBackground.self, forDecorationViewOfKind: "groupBackground")
        return layout
    }

and GroupBackground is like this:

struct GroupBackground: View, Decoration
{
    var body: some View
    {
        Color.gray
    }
}

Thanks a lot for your time.

dreampowder commented 1 year ago

looks like this is an ios16 bug, similar to the tableview bug mentioned in another issue

Screen Shot 2022-07-19 at 16 52 02 Screen Shot 2022-07-19 at 16 51 50