UICollectionView error on Xcode(14.3.1, 15.0) with ios over 16.5

Details on below

stacktrace on bottom

xcode / ios16.517.015.4
14.2okokok
14.3.1errorerrorok
15.0(beta)errorerrorok

==================

this bug happened when (left-right)swipe collectionView

I use reloadSection() for different cell count or size in some section.

  • this error happens below code

 UIView.performWithoutAnimation {

       collectionView.reloadSections(IndexSet.init(integer: section.rawValue))

 }

I couldn't find any way to fix this problem. In my mind, it is right logic related collectionView but not exactly sure.

Question

  1. If the problem is on my code, what can I try?.

    • I searched on google, asked ai-propt(openai, bing,bard) but these not helped
  2. If the bug source is from Xcode or swift (or UIKit?)?

    • just wait?
  3. Now, Xcode 14.2 is fine on any situation. is it safe to code on this version and upload appstroe? and even this ok, should I fix this bug from my code?

  • stacktrace
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid batch updates detected: the number of sections and/or items returned by the data source before and/or after performing the batch updates are inconsistent with the updates.Data source before updates = { 9 sections with item counts: [1, 1, 1, 0, 1, 0, 1, 1, 0] }Data source after updates = { 9 sections with item counts: [1, 0, 1, 0, 1, 0, 1, 1, 0] }Updates = [ Delete section 4, Insert section 4]Collection view: <UICollectionView: 0x105130000; frame = (0 74; 375 634); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x282dd60a0>; backgroundColor = <UIDynamicSystemColor: 0x283788b80; name = systemBackgroundColor>; layer = <CALayer: 0x2823724a0>; contentOffset: {0, -8}; contentSize: {375, 951.32993055555562}; adjustedContentInset: {8, 0, 60, 0}; layout: <UICollectionViewFlowLayout: 0x103ff0020>; dataSource: <Formation.MarketViewCell: 0x105047a00; baseClass = UICollectionViewCell; frame = (1125 -17; 375 768); clipsToBounds = YES; hidden = YES; backgroundColor = UIExtendedSRGBColorSpace 0.941176 0.956863 0.972549 1; layer = <CALayer: 0x282395ec0>>>'***

(openai, bing,bard) but these not helped

Did you seriously hoped to get answer there ?

You have a lot of information in le crashlog.

When do you you reloadSections ? After adding or deleting item I guess.

You must check that you have updated the dataSource before. The difference between OS versions may come form an async issue: you assumed operations would occur in a certain order (but without a system commitment to do so), and the exact timing has changed. So the update that occured in time now occurs too late.

But we would need to see much more code to give more precise help.

Thanks reply.

I am trying to fix async issue on my code. I also think it is related fetch from backend or image(relate async)

In Debug Navigator, alamofire or kingfisher is shown first many times at the same bug. but in 9 sections, sometimes happend other place(section), but meet "reloadSection".

I use reloadSection when just items (of section) changed(added or removed whatever)

I think it's better to fix this, not just using Xcode 14.2 for future.

Thanks.

Did you seriously hoped to get answer there ?

Sometimes it gives some good hints.

Hi All, I am facing a similar issue,Can you suggest how you fixed this ?

UICollectionView error on Xcode(14.3.1, 15.0) with ios over 16.5
 
 
Q