IGListKit icon indicating copy to clipboard operation
IGListKit copied to clipboard

crash with ios 16.4 when build with xcode 14.3

Open DrWaleedNour opened this issue 1 year ago • 10 comments

occur crash with in devices have ios version: 16.4, when i build the app with xcode 14.3 , but when i build app with xcode 14.2 the crash disappear the crash: __67-[IGListAdapterUpdater performBatchUpdatesWithCollectionViewBlock:]_block_invoke.9

iglistkit version = 4.0.0

DrWaleedNour avatar Apr 19 '23 08:04 DrWaleedNour

Hi @DrWaleedNour! Sorry to hear you're experiencing a crash with IGListKit. Is there an error message that was visible in that crash?

We're working hard towards getting version 5.0 ready. Once I've merged my latest PRs to the codebase, I'll ask you to try the latest copy of IGListKit from the main branch and see if you're still having that issue.

TimOliver avatar Apr 20 '23 15:04 TimOliver

Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x119180 __exceptionPreprocess 1 libobjc.A.dylib 0x59f8 objc_exception_throw 2 CoreFoundation 0x3288c +[_CFXNotificationTokenRegistration keyCallbacks] 3 Foundation 0x8ab38 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] 4 UIKitCore 0x1c6324 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] 5 UIKitCore 0x1cd1b8 -[UICollectionView _endUpdatesWithInvalidationContext:tentativelyForReordering:animator:] 6 UIKitCore 0x1cd4ec -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] 7 UIKitCore 0x1cd34c -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] 8 UIKitCore 0x1cd2d0 -[UICollectionView _performBatchUpdates:completion:invalidationContext:] 9 UIKitCore 0x1cd20c -[UICollectionView performBatchUpdates:completion:] 10 liaqa 0x218c8a0 __67-[IGListAdapterUpdater performBatchUpdatesWithCollectionViewBlock:]_block_invoke.9 + 250 (IGListAdapterUpdater.m:250) 11 liaqa 0x218c0e4 -[IGListAdapterUpdater performBatchUpdatesWithCollectionViewBlock:] + 272 (IGListAdapterUpdater.m:272) 12 liaqa 0x218d7c4 __60-[IGListAdapterUpdater _queueUpdateWithCollectionViewBlock:]_block_invoke + 434 (IGListAdapterUpdater.m:434) 13 libdispatch.dylib 0x5fa38 _dispatch_call_block_and_release 14 libdispatch.dylib 0x607d4 _dispatch_client_callout 15 libdispatch.dylib 0xe008 _dispatch_main_queue_callback_4CF$VARIANT$mp 16 CoreFoundation 0xaab20 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE 17 CoreFoundation 0xa5a58 __CFRunLoopRun 18 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific 19 GraphicsServices 0xa79c GSEventRunModal 20 UIKitCore 0x8bcc38 UIApplicationMain 21 liaqa 0x229d0 main + 245 (AppDelegate.swift:245) 22 libdyld.dylib 0x18e0 start

waleednour avatar Apr 25 '23 13:04 waleednour

When 5.0?

baveku avatar Apr 25 '23 15:04 baveku

Hi @DrWaleedNour! Sorry to hear you're experiencing a crash with IGListKit. Is there an error message that was visible in that crash?

We're working hard towards getting version 5.0 ready. Once I've merged my latest PRs to the codebase, I'll ask you to try the latest copy of IGListKit from the main branch and see if you're still having that issue.

any update or solution?

DrWaleedNour avatar May 01 '23 12:05 DrWaleedNour

@baveku Soon. :)

@DrWaleedNour Did you try with the latest version from the main branch yet?

TimOliver avatar May 02 '23 05:05 TimOliver

@DrWaleedNour hello! I have a question about your usage of IGListKit. Can you take a look at your usage of performBatchAnimated and similar methods (if perhaps you're calling the equivalent method directly on your collection view), and see if you ever make a model update outside of the update block? I believe you'll need to move any model mutations you might be making into the beginning of the update block and that may fix your issue.

DimaVartanian avatar May 18 '23 18:05 DimaVartanian

I believe it was "fixed" in https://github.com/Instagram/IGListKit/commit/eb9b18ada40800941e9ec96450de67481974f07c

akuzminskyi avatar Jun 02 '23 09:06 akuzminskyi

I am experiencing the same crashes with sdk version 4.0.0 since building Xcode 14.3.1. I am happy to see that there is already a fix to catch the crashing exception.

@TimOliver @DimaVartanian Since your are not releasing minor updates anymore and the next version 5.0.0 update is marked as upcoming for quite some time now, can you please elaborate on what's the best way to integrate this fix?

  • Can you give an ETA on when version 5.0.0 will be released? E.g. more like weeks or months?
  • Do you you consider the main branch stable and ready for production? Do you at Instagram also use the main branch directly to utilize the developments since version 4.0.0?

chwo avatar Jul 04 '23 15:07 chwo

I believe it was "fixed" in eb9b18a

This doesn't seem to fix the actual issue. The app no longer crashes but the invalid updates end up leaving the collection view in a weird state of blank spaces and non-updating cells forever until the app is killed.

tahirmt avatar Jul 08 '23 21:07 tahirmt

https://instagram.com/dezan_berhijrah?igshid=MzRlODBiNWFlZA==

ronaya2001 avatar Aug 09 '23 15:08 ronaya2001

Does this issue have any resolution? I have the same exception thrown in my Xcode 15.3 build and I see that the source code has an experiment to avoid the exception, but the experiment was disabled. Referring to in eb9b18a mentioned above on July 8th 2023

julianhulme-gocanvas avatar Jul 10 '24 10:07 julianhulme-gocanvas

Hey folks! Sorry for the delay! Version 5.0 is officially out now, so I think we can put this issue to bed. 🎉

The official final resolution for this issue is that it wasn't due to an issue in IGListKit, but it was due to an underlying change to UICollectionView by Apple. 🤯

Apple explained on the Apple Developer forums that this came about as a deliberate change in iOS 16.4. They explained that in previous versions of iOS, when an update operation was found to be inconsistent, it didn't crash, but it implicitly performed a costly reloadData call on the collection view instead. They said even in those previous cases, this was still using the collection view incorrectly and should have still been avoided. 😅

In light of this, if this error occurs via IGListKit, this means something is genuinely incorrect in the user's model logic, and it should be appropriately addressed.

The experiment in IGListKit is there to 'skip' the exception and allow the app to continue running in order to discover and capture instances of this exception occurring. This allows the app to continue executing (which may be preferable to it crashing if it was on lower priority screen), however it absolutely shouldn't be relied upon if it can be helped. If a collection view encounters this exception and the app doesn't crash, the collection view remains in an invalid state, and will start showing inconsistent UI if the user continues to interact with it.

I hope that clears everything up. Thanks again for reporting this issue! It ended up being an early warning to us at Instagram that this API change by Apple was on the horizon and was extremely valuable in our own efforts! 🙏

tl;dr: This issue started due to a deliberate choice by Apple and isn't an underlying issue in IGListKit. If you're encountering it, you need to re-examine your app's logic to ensure your model state logic is updating correctly. If you need to bypass the exception for now, you can optionally choose to disable IGListExperimentThrowOnInconsistencyException, but this isn't recommended.

TimOliver avatar Jul 23 '24 06:07 TimOliver