Invalid absolute dimension: inf. The dimension must be a finite value

Hi I tried to use compositional layout, while using stage manager rare the app getting crashed. Please refer below error message

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid absolute dimension: inf. The dimension must be a finite value.'

            let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(cellWidth),heightDimension: .absolute(cellHeight))
            let item = NSCollectionLayoutItem(layoutSize: itemSize)
            
            let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .absolute(cellHeight))
            let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
            group.interItemSpacing = NSCollectionLayoutSpacing.fixed(cellSpacing)
            
            let section = NSCollectionLayoutSection(group: group)
            section.contentInsets = NSDirectionalEdgeInsets(top: 10,leading: inset, bottom: 0,trailing:inset)
            section.interGroupSpacing = lineSpacing

Why am I getting this error after providing exact height and width?

Where exactly do you get the error ?

Could you add a print:

print("Cell", cellWidth, cellHeight, "absolute": .absolute(cellHeight), .absolute(cellWidth))
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(cellWidth),heightDimension: .absolute(cellHeight))

How do you calculate cellWidth, cellHeight and cellSpacing? The most common source of Inf is by dividing a non-zero value by zero.

@Praveenraj4256 Did you add the print, as I told ? What do you get ?

If it crashes, just print this:

print("Cell", cellWidth, cellHeight)
Invalid absolute dimension: inf. The dimension must be a finite value
 
 
Q