iOS App/Designed for iPad crashing in Ventura - suspect LazyVGrid.

I do have a SwiftUI view with a model and lately when I run the iOS App on Mac as "designed for iPAD" it crashes.

The view uses a LazyVGrid - I suspect that is the issue?

My code works on iPad and iPhone but crashes on Mac when elements from the LazyVGrid are being removed from the ObservableObject driving the view.

Any recommendations what I could do about this? I currently have no idea about where to start as I cannot dig further and the stack trace does not contain any of my code...

Cheers, Michael

here is what I get in the output:

*** First throw call stack:
(
	0   CoreFoundation                      0x000000019b28c418 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000019add6ea8 objc_exception_throw + 60
	2   Foundation                          0x000000019c1cca60 -[NSCalendarDate initWithCoder:] + 0
	3   UIKitCore                           0x00000001c5137cfc -[UICollectionViewData indexPathForItemAtGlobalIndex:] + 172
	4   UIKitCore                           0x00000001c5429d74 __114-[UICollectionView _createAndAppendViewAnimationsForInsertsInCurrentUpdate:appearingAnimations:newSubviewManager:]_block_invoke + 76
	5   UIKitCore                           0x00000001c5429c78 -[UICollectionView _createAndAppendViewAnimationsForInsertsInCurrentUpdate:appearingAnimations:newSubviewManager:] + 1304
	6   UIKitCore                           0x00000001c5428ba8 -[UICollectionView _viewAnimationsForCurrentUpdateWithCollectionViewAnimator:] + 244
	7   UIKitCore                           0x00000001c542ee84 __102-[UICollectionView _updateWithItems:tentativelyForReordering:propertyAnimator:collectionViewAnimator:]_block_invoke.748 + 180
	8   UIKitCore                           0x00000001c5011034 +[UIView(Animation) performWithoutAnimation:] + 76
	9   UIKitCore                           0x00000001c542e3bc -[UICollectionView _updateWithItems:tentativelyForReordering:propertyAnimator:collectionViewAnimator:] + 1388
	10  UIKitCore                           0x00000001c5428278 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] + 8608
	11  UIKitCore                           0x00000001c5430b98 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:animationHandler:] + 512
	12  SwiftUI                             0x00000001daf7aaec OUTLINED_FUNCTION_7 + 10996
	13  SwiftUI                             0x00000001db151160 OUTLINED_FUNCTION_2 + 52
	14  SwiftUI                             0x00000001db151188 OUTLINED_FUNCTION_2 + 92
	15  UIKitCore                           0x00000001c5011034 +[UIView(Animation) performWithoutAnimation:] + 76
...


2022-11-22 15:03:07.461972+0100 CameraCompanionBETA[3997:41963] [General] An uncaught exception was raised
2022-11-22 15:03:07.462026+0100 CameraCompanionBETA[3997:41963] [General] request for index path for global index 4 when there are only 4 items in the collection view
2022-11-22 15:03:07.462092+0100 CameraCompanionBETA[3997:41963] [General] (
	0   CoreFoundation                      0x000000019b28c418 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000019add6ea8 objc_exception_throw + 60
	2   Foundation                          0x000000019c1cca60 -[NSCalendarDate initWithCoder:] + 0
	3   UIKitCore                           0x00000001c5137cfc -[UICollectionViewData indexPathForItemAtGlobalIndex:] + 172
	4   UIKitCore                           0x00000001c5429d74 __114-[UICollectionView _createAndAppendViewAnimationsForInsertsInCurrentUpdate:appearingAnimations:newSubviewManager:]_block_invoke + 76
	5   UIKitCore                           0x00000001c5429c78 -[UICollectionView _createAndAppendViewAnimationsForInsertsInCurrentUpdate:appearingAnimations:newSubviewManager:] + 1304
	6   UIKitCore                           0x00000001c5428ba8 -[UICollectionView _viewAnimationsForCurrentUpdateWithCollectionViewAnimator:] + 244
	7   UIKitCore                           0x00000001c542ee84 __102-[UICollectionView _updateWithItems:tentativelyForReordering:propertyAnimator:collectionViewAnimator:]_block_invoke.748 + 180
	8   UIKitCore                           0x00000001c5011034 +[UIView(Animation) performWithoutAnimation:] + 76
	9   UIKitCore                           0x00000001c542e3bc -[UICollectionView _updateWithItems:tentativelyForReordering:propertyAnimator:collectionViewAnimator:] + 1388
	10  UIKitCore                           0x00000001c5428278 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] + 8608
	11  UIKitCore                           0x00000001c5430b98 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:animationHandler:] + 512
	12  SwiftUI                             0x00000001daf7aaec OUTLINED_FUNCTION_7 + 10996
	13  SwiftUI                             0x00000001db151160 OUTLINED_FUNCTION_2 + 52
	14  SwiftUI                             0x00000001db151188 OUTLINED_FUNCTION_2 + 92
	15  UIKitCore                           0x00000001c5011034 +[UIView(Animation) performWithoutAnimation:] + 76
	16  SwiftUI                             0x00000001daf7a934 OUTLINED_FUNCTION_7 + 10556
	17  SwiftUI                             0x00000001da9da4b0 OUTLINED_FUNCTION_10 + 77892
...

Forgot the error description...  *** Assertion failure in -[UICollectionViewData indexPathForItemAtGlobalIndex:], UICollectionViewData.mm:835

2022-11-22 15:03:07.448874+0100 CameraCompanionBETA[3997:41963] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for index path for global index 4 when there are only 4 items in the collection view'

Never mind - Seems like I resolved the issue. Looks like it is a bad idea to put a LazyVGrid into a List View. I removed the surrounding List View and now it seems fine. Somehow strange that it did work before Ventura.

iOS App/Designed for iPad crashing in Ventura - suspect LazyVGrid.
 
 
Q