ASCollectionView
ASCollectionView copied to clipboard
Crash when rotating to landscape and back to portrait
Describe the bug I have setup a project to support portrait and landscape left/right device orientation. When displaying an ASCollectionView in may app, then rotating the device to any landscape orientation and then back to portrait the app crashes with the following error (I'll attach a full stack trace at the bottom). As far as I can tell from the debug navigator the crash occurs in line 72 of AS_UICollectionView.swift ("view.frame = CGRect(origin: view.frame.origin, size: size)")
*** Assertion failure in -[_UIRTree insertFrame:forIndex:], _UIRTree.mm:419
2020-12-26 23:16:29.141941+0100 MyApp[23565:1258540] *** Assertion failure in -[_UIRTree insertFrame:forIndex:], _UIRTree.mm:419
2020-12-26 23:16:29.155303+0100 MyApp[23565:1258540] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !CGRectIsNull(frame)'
To Reproduce A similar crash occurs when rotating the App Store Demo of the ASCollectionViewDemo app.
Expected behaviour I would expect the app not to crash
Xcode Version: Version 12.3 (12C33)
Simulator, Device, Both? Both
Stack Trace
2020-12-26 23:22:00.150920+0100 Myapp[23844:1275914] *** Assertion failure in -[_UIRTree insertFrame:forIndex:], _UIRTree.mm:419
2020-12-26 23:22:00.165021+0100 Myapp[23844:1275914] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !CGRectIsNull(frame)'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff20420af6 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20177e78 objc_exception_throw + 48
2 CoreFoundation 0x00007fff2042091f +[NSException raise:format:] + 0
3 Foundation 0x00007fff2077056a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 UIKitCore 0x00007fff23d23c9f -[_UIRTree insertFrame:forIndex:] + 953
5 UIKitCore 0x00007fff23d1128d -[_UICollectionLayoutSectionEstimatedSolver _solveWithParameters:] + 4449
6 UIKitCore 0x00007fff23d0e640 -[_UICollectionLayoutSectionEstimatedSolver solveForContainer:traitCollection:layoutAxis:frameCount:preferredSizes:layoutRTL:] + 284
7 UIKitCore 0x00007fff23cedb99 -[_UICollectionCompositionalLayoutSolver _solveWithSectionLayouts:preferredSizesDict:dataSourceSnapshot:update:] + 1693
8 UIKitCore 0x00007fff23ced4e5 -[_UICollectionCompositionalLayoutSolver _solve] + 201
9 UIKitCore 0x00007fff23ce7bea -[_UICollectionCompositionalLayoutSolver resolveForContainerChange:] + 472
10 UIKitCore 0x00007fff23cde3c8 -[UICollectionViewCompositionalLayout _boundsChangeResolve] + 241
11 UIKitCore 0x00007fff23cdbe5d -[UICollectionViewCompositionalLayout invalidateLayoutWithContext:] + 430
12 UIKitCore 0x00007fff23dcd774 -[UICollectionViewLayout _invalidateLayoutUsingContext:] + 56
13 UIKitCore 0x00007fff23d6f226 -[UICollectionView setFrame:] + 726
14 ASCollectionViewDynamic 0x00000001113b217d $s16ASCollectionView013AS_CollectionB10ControllerC18viewWillTransition2to4withySo6CGSizeV_So06UIVieweH11Coordinator_ptF + 1117
15 ASCollectionViewDynamic 0x00000001113b2af4 $s16ASCollectionView013AS_CollectionB10ControllerC18viewWillTransition2to4withySo6CGSizeV_So06UIVieweH11Coordinator_ptFTo + 84
16 UIKitCore 0x00007fff23f76366 -[UIViewController viewWillTransitionToSize:withTransitionCoordinator:] + 1156
17 SwiftUI 0x00007fff575f0153 $s7SwiftUI19UIHostingControllerC18viewWillTransition2to4withySo6CGSizeV_So06UIViewdG11Coordinator_ptF + 99
18 SwiftUI 0x00007fff575f01d3 $s7SwiftUI19UIHostingControllerC18viewWillTransition2to4withySo6CGSizeV_So06UIViewdG11Coordinator_ptFTo + 67
19 UIKitCore 0x00007fff23f76366 -[UIViewController viewWillTransitionToSize:withTransitionCoordinator:] + 1156
20 UIKitCore 0x00007fff23e9a142 -[UINavigationController viewWillTransitionToSize:withTransitionCoordinator:] + 81
21 UIKitCore 0x00007fff23f76366 -[UIViewController viewWillTransitionToSize:withTransitionCoordinator:] + 1156
22 SwiftUI 0x00007fff575f0153 $s7SwiftUI19UIHostingControllerC18viewWillTransition2to4withySo6CGSizeV_So06UIViewdG11Coordinator_ptF + 99
23 SwiftUI 0x00007fff575f01d3 $s7SwiftUI19UIHostingControllerC18viewWillTransition2to4withySo6CGSizeV_So06UIViewdG11Coordinator_ptFTo + 67
24 UIKitCore 0x00007fff23f76366 -[UIViewController viewWillTransitionToSize:withTransitionCoordinator:] + 1156
25 UIKitCore 0x00007fff23e658a1 -[UITabBarController viewWillTransitionToSize:withTransitionCoordinator:] + 42
26 UIKitCore 0x00007fff23f76366 -[UIViewController viewWillTransitionToSize:withTransitionCoordinator:] + 1156
27 SwiftUI 0x00007fff575f0153 $s7SwiftUI19UIHostingControllerC18viewWillTransition2to4withySo6CGSizeV_So06UIViewdG11Coordinator_ptF + 99
28 SwiftUI 0x00007fff575f01d3 $s7SwiftUI19UIHostingControllerC18viewWillTransition2to4withySo6CGSizeV_So06UIViewdG11Coordinator_ptFTo + 67
29 UIKitCore 0x00007fff23f6b490 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 153
30 UIKitCore 0x00007fff23f83176 -[UIViewController(AdaptiveSizing_Internal) _window:viewWillTransitionToSize:withTransitionCoordinator:] + 862
31 UIKitCore 0x00007fff246d8636 __59-[UIWindow _rotateToBounds:withAnimator:transitionContext:]_block_invoke + 175
32 UIKitCore 0x00007fff246d84bb -[UIWindow _rotateToBounds:withAnimator:transitionContext:] + 374
33 UIKitCore 0x00007fff246db22e -[UIWindow _rotateWindowToOrientation:updateStatusBar:duration:skipCallbacks:] + 2330
34 UIKitCore 0x00007fff246db80f -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 615
35 UIKitCore 0x00007fff246da7c0 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 99
36 UIKitCore 0x00007fff246d96b3 __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 218
37 UIKitCore 0x00007fff246d94d5 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 1447
38 CoreFoundation 0x00007fff20361f12 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
39 CoreFoundation 0x00007fff20361ee1 ___CFXRegistrationPost_block_invoke + 49
40 CoreFoundation 0x00007fff203615ff _CFXRegistrationPost + 454
41 CoreFoundation 0x00007fff20360f6d _CFXNotificationPost + 796
42 Foundation 0x00007fff207e498a -[NSNotificationCenter postNotificationName:object:userInfo:] + 59
43 UIKitCore 0x00007fff2426c282 -[UIDevice setOrientation:animated:] + 281
44 UIKitCore 0x00007fff23cc3726 __134-[_UIWindowSceneDeviceOrientationSettingsDiffAction _updateDeviceOrientationWithSettingObserverContext:windowScene:transitionContext:]_block_invoke + 137
45 UIKitCore 0x00007fff241556ab +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 871
46 UIKitCore 0x00007fff2426865e _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 240
47 UIKitCore 0x00007fff23cc366b -[_UIWindowSceneDeviceOrientationSettingsDiffAction _updateDeviceOrientationWithSettingObserverContext:windowScene:transitionContext:] + 248
48 UIKitCore 0x00007fff23cc34e8 -[_UIWindowSceneDeviceOrientationSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 233
49 UIKitCore 0x00007fff23ae896f __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 797
50 UIKitCore 0x00007fff23ae7419 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 253
51 UIKitCore 0x00007fff23ae85a8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 208
52 UIKitCore 0x00007fff2417df23 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 502
53 FrontBoardServices 0x00007fff25aa28c7 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 530
54 FrontBoardServices 0x00007fff25acc149 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 133
55 FrontBoardServices 0x00007fff25aafad5 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209
56 FrontBoardServices 0x00007fff25acc091 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke + 372
57 libdispatch.dylib 0x00000001115bf9c8 _dispatch_client_callout + 8
58 libdispatch.dylib 0x00000001115c2910 _dispatch_block_invoke_direct + 295
59 FrontBoardServices 0x00007fff25af07a5 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
60 FrontBoardServices 0x00007fff25af048b -[FBSSerialQueue _targetQueue_performNextIfPossible] + 433
61 FrontBoardServices 0x00007fff25af0950 -[FBSSerialQueue _performNextFromRunLoopSource] + 22
62 CoreFoundation 0x00007fff2038f38a __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
63 CoreFoundation 0x00007fff2038f282 __CFRunLoopDoSource0 + 180
64 CoreFoundation 0x00007fff2038e764 __CFRunLoopDoSources0 + 248
65 CoreFoundation 0x00007fff20388f2f __CFRunLoopRun + 878
66 CoreFoundation 0x00007fff203886d6 CFRunLoopRunSpecific + 567
67 GraphicsServices 0x00007fff2bededb3 GSEventRunModal + 139
68 UIKitCore 0x00007fff24690e0b -[UIApplication _run] + 912
69 UIKitCore 0x00007fff24695cbc UIApplicationMain + 101
70 Myapp 0x000000010fef63eb main + 75
71 libdyld.dylib 0x00007fff202593e9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !CGRectIsNull(frame)'
terminating with uncaught exception of type NSException
CoreSimulator 732.18.6 - Device: iPhone 12 Pro (8E18C05A-DD81-44F0-A5E0-A4DF6D5C658A) - Runtime: iOS 14.3 (18C61) - DeviceType: iPhone 12 Pro