Open jasin755 opened 5 years ago
Same here... Precondition makes the shipped code to crash (very seldom).
open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
precondition(indexPath.item < _sectionModels[indexPath.section].items.count)
return configureCell(self, collectionView, indexPath, self[indexPath])
}
Is there any chance to reproduce/fix the issue?
# OS Version: 12.2.0 (16E227)
# Device: iPhone X
# RAM Free: 3.8%
# Disk Free: 50.7%
#0. Crashed: com.apple.main-thread
0 Prjkt Prod 0x10070e570 CollectionViewSectionedDataSource.collectionView(_:cellForItemAt:) (CollectionViewSectionedDataSource.swift:133)
1 Prjkt Prod 0x10070e5f0 @objc CollectionViewSectionedDataSource.collectionView(_:cellForItemAt:) (<compiler-generated>)
2 Prjkt Prod 0x1006f3ee4 @objc RxCollectionViewDataSourceProxy.collectionView(_:cellForItemAt:) (RxCollectionViewDataSourceProxy.swift:66)
3 UIKitCore 0x204764ca4 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 428
4 UIKitCore 0x2047666ec -[UICollectionView _prefetchItemsForVelocity:maxItemsToPrefetch:invalidateCandidatesOnDirectionChanges:] + 480
5 UIKitCore 0x20476d8b4 -[UICollectionView layoutSubviews] + 732
6 UIKitCore 0x2052f9e54 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1292
7 QuartzCore 0x1dceca1f0 -[CALayer layoutSublayers] + 184
8 QuartzCore 0x1dcecf198 CA::Layer::layout_if_needed(CA::Transaction*) + 332
9 UIKitCore 0x2052e5e88 -[UIView(Hierarchy) layoutBelowIfNeeded] + 544
10 UIKitCore 0x2047832c0 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] + 244
11 UIKitCore 0x2047831ac -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 96
12 UIKitCore 0x204783130 -[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 84
13 UIKitCore 0x20478306c -[UICollectionView performBatchUpdates:completion:] + 64
14 Prjkt Prod 0x1007136cc UICollectionView.performBatchUpdates<A>(_:animationConfiguration:) (UI+SectionedViewType.swift:101)
15 Prjkt Prod 0x10070fc80 closure #1 in RxCollectionViewSectionedAnimatedDataSource.collectionView(_:throttledObservedEvent:) (RxCollectionViewSectionedAnimatedDataSource.swift:95)
16 Prjkt Prod 0x100710304 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed RxCollectionViewSectionedAnimatedDataSource<A>, @guaranteed [A]) -> () (<compiler-generated>)
17 Prjkt Prod 0x1006d05f4 partial apply for closure #1 in closure #1 in Binder.init<A>(_:scheduler:binding:) (Binder.swift:38)
18 Prjkt Prod 0x1007542a8 MainScheduler.scheduleInternal<A>(_:action:) (MainScheduler.swift:63)
19 Prjkt Prod 0x10077008c protocol witness for ImmediateSchedulerType.schedule<A>(_:action:) in conformance SerialDispatchQueueScheduler (<compiler-generated>)
20 Prjkt Prod 0x1006d0130 closure #1 in Binder.init<A>(_:scheduler:binding:) (Binder.swift:36)
21 Prjkt Prod 0x1006d025c Binder.on(_:) (Binder.swift:52)
22 Prjkt Prod 0x10070f9bc RxCollectionViewSectionedAnimatedDataSource.collectionView(_:throttledObservedEvent:) (RxCollectionViewSectionedAnimatedDataSource.swift:110)
23 Prjkt Prod 0x100710214 partial apply for closure #1 in RxCollectionViewSectionedAnimatedDataSource.init(animationConfiguration:decideViewTransition:configureCell:configureSupplementaryView:moveItem:canMoveItemAtIndexPath:) (RxCollectionViewSectionedAnimatedDataSource.swift:58)
24 Prjkt Prod 0x100710278 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed UICollectionView, @guaranteed Event<[A]>) -> () (<compiler-generated>)
25 Prjkt Prod 0x10075cf54 closure #1 in ObservableType.subscribe(onNext:onError:onCompleted:onDisposed:) (ObservableType+Extensions.swift:65)
26 Prjkt Prod 0x10075d154 partial apply for closure #1 in ObservableType.subscribe(onNext:onError:onCompleted:onDisposed:) (<compiler-generated>)
27 Prjkt Prod 0x10071f688 AnonymousObserver.onCore(_:) (AnonymousObserver.swift:24)
28 Prjkt Prod 0x10075f8d4 ObserverBase.on(_:) (ObserverBase.swift:21)
29 Prjkt Prod 0x10075fa5c protocol witness for ObserverType.on(_:) in conformance ObserverBase<A> (<compiler-generated>)
30 Prjkt Prod 0x1007737d0 Sink.forwardOn(_:) (Sink.swift:34)
31 Prjkt Prod 0x10077f1e8 ThrottleSink.sendNow(element:) (Throttle.swift:123)
32 Prjkt Prod 0x10077f400 ThrottleSink.propagate(_:) (Throttle.swift:132)
33 Prjkt Prod 0x100728928 thunk for @escaping @callee_guaranteed (@unowned Int) -> (@out Disposable) (<compiler-generated>)
34 Prjkt Prod 0x10074bb8c closure #2 in DispatchQueueConfiguration.scheduleRelative<A>(_:dueTime:action:) (CompositeDisposable.swift:75)
35 Prjkt Prod 0x1002c4270 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
36 libdispatch.dylib 0x1d847d7d4 _dispatch_client_callout + 16
37 libdispatch.dylib 0x1d8454c34 _dispatch_continuation_pop$VARIANT$armv81 + 404
38 libdispatch.dylib 0x1d8464800 _dispatch_source_invoke$VARIANT$armv81 + 1232
39 libdispatch.dylib 0x1d845d8d4 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 736
40 CoreFoundation 0x1d89cdec0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
41 CoreFoundation 0x1d89c8df8 __CFRunLoopRun + 1924
42 CoreFoundation 0x1d89c8354 CFRunLoopRunSpecific + 436
43 GraphicsServices 0x1dabc879c GSEventRunModal + 104
44 UIKitCore 0x204e71b68 UIApplicationMain + 212
45 Prjkt Prod 0x10003043c main (CatalogSearchEditColorsCell.swift:47)
46 libdyld.dylib 0x1d848e8e0 start + 4
--
#0. Crashed: com.apple.main-thread
0 Prjkt Prod 0x10070e570 CollectionViewSectionedDataSource.collectionView(_:cellForItemAt:) (CollectionViewSectionedDataSource.swift:133)
1 Prjkt Prod 0x10070e5f0 @objc CollectionViewSectionedDataSource.collectionView(_:cellForItemAt:) (<compiler-generated>)
2 Prjkt Prod 0x1006f3ee4 @objc RxCollectionViewDataSourceProxy.collectionView(_:cellForItemAt:) (RxCollectionViewDataSourceProxy.swift:66)
3 UIKitCore 0x204764ca4 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 428
4 UIKitCore 0x2047666ec -[UICollectionView _prefetchItemsForVelocity:maxItemsToPrefetch:invalidateCandidatesOnDirectionChanges:] + 480
5 UIKitCore 0x20476d8b4 -[UICollectionView layoutSubviews] + 732
6 UIKitCore 0x2052f9e54 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1292
7 QuartzCore 0x1dceca1f0 -[CALayer layoutSublayers] + 184
8 QuartzCore 0x1dcecf198 CA::Layer::layout_if_needed(CA::Transaction*) + 332
9 UIKitCore 0x2052e5e88 -[UIView(Hierarchy) layoutBelowIfNeeded] + 544
10 UIKitCore 0x2047832c0 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] + 244
11 UIKitCore 0x2047831ac -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 96
12 UIKitCore 0x204783130 -[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 84
13 UIKitCore 0x20478306c -[UICollectionView performBatchUpdates:completion:] + 64
14 Prjkt Prod 0x1007136cc UICollectionView.performBatchUpdates<A>(_:animationConfiguration:) (UI+SectionedViewType.swift:101)
15 Prjkt Prod 0x10070fc80 closure #1 in RxCollectionViewSectionedAnimatedDataSource.collectionView(_:throttledObservedEvent:) (RxCollectionViewSectionedAnimatedDataSource.swift:95)
16 Prjkt Prod 0x100710304 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed RxCollectionViewSectionedAnimatedDataSource<A>, @guaranteed [A]) -> () (<compiler-generated>)
17 Prjkt Prod 0x1006d05f4 partial apply for closure #1 in closure #1 in Binder.init<A>(_:scheduler:binding:) (Binder.swift:38)
18 Prjkt Prod 0x1007542a8 MainScheduler.scheduleInternal<A>(_:action:) (MainScheduler.swift:63)
19 Prjkt Prod 0x10077008c protocol witness for ImmediateSchedulerType.schedule<A>(_:action:) in conformance SerialDispatchQueueScheduler (<compiler-generated>)
20 Prjkt Prod 0x1006d0130 closure #1 in Binder.init<A>(_:scheduler:binding:) (Binder.swift:36)
21 Prjkt Prod 0x1006d025c Binder.on(_:) (Binder.swift:52)
22 Prjkt Prod 0x10070f9bc RxCollectionViewSectionedAnimatedDataSource.collectionView(_:throttledObservedEvent:) (RxCollectionViewSectionedAnimatedDataSource.swift:110)
23 Prjkt Prod 0x100710214 partial apply for closure #1 in RxCollectionViewSectionedAnimatedDataSource.init(animationConfiguration:decideViewTransition:configureCell:configureSupplementaryView:moveItem:canMoveItemAtIndexPath:) (RxCollectionViewSectionedAnimatedDataSource.swift:58)
24 Prjkt Prod 0x100710278 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed UICollectionView, @guaranteed Event<[A]>) -> () (<compiler-generated>)
25 Prjkt Prod 0x10075cf54 closure #1 in ObservableType.subscribe(onNext:onError:onCompleted:onDisposed:) (ObservableType+Extensions.swift:65)
26 Prjkt Prod 0x10075d154 partial apply for closure #1 in ObservableType.subscribe(onNext:onError:onCompleted:onDisposed:) (<compiler-generated>)
27 Prjkt Prod 0x10071f688 AnonymousObserver.onCore(_:) (AnonymousObserver.swift:24)
28 Prjkt Prod 0x10075f8d4 ObserverBase.on(_:) (ObserverBase.swift:21)
29 Prjkt Prod 0x10075fa5c protocol witness for ObserverType.on(_:) in conformance ObserverBase<A> (<compiler-generated>)
30 Prjkt Prod 0x1007737d0 Sink.forwardOn(_:) (Sink.swift:34)
31 Prjkt Prod 0x10077f1e8 ThrottleSink.sendNow(element:) (Throttle.swift:123)
32 Prjkt Prod 0x10077f400 ThrottleSink.propagate(_:) (Throttle.swift:132)
33 Prjkt Prod 0x100728928 thunk for @escaping @callee_guaranteed (@unowned Int) -> (@out Disposable) (<compiler-generated>)
34 Prjkt Prod 0x10074bb8c closure #2 in DispatchQueueConfiguration.scheduleRelative<A>(_:dueTime:action:) (CompositeDisposable.swift:75)
35 Prjkt Prod 0x1002c4270 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
36 libdispatch.dylib 0x1d847d7d4 _dispatch_client_callout + 16
37 libdispatch.dylib 0x1d8454c34 _dispatch_continuation_pop$VARIANT$armv81 + 404
38 libdispatch.dylib 0x1d8464800 _dispatch_source_invoke$VARIANT$armv81 + 1232
39 libdispatch.dylib 0x1d845d8d4 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 736
40 CoreFoundation 0x1d89cdec0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
41 CoreFoundation 0x1d89c8df8 __CFRunLoopRun + 1924
42 CoreFoundation 0x1d89c8354 CFRunLoopRunSpecific + 436
43 GraphicsServices 0x1dabc879c GSEventRunModal + 104
44 UIKitCore 0x204e71b68 UIApplicationMain + 212
45 Prjkt Prod 0x10003043c main (CatalogSearchEditColorsCell.swift:47)
46 libdyld.dylib 0x1d848e8e0 start + 4
#1. com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x1d85cf0f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1d85ce5a0 mach_msg + 72
2 CoreFoundation 0x1d89cdcb4 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x1d89c8bc4 __CFRunLoopRun + 1360
4 CoreFoundation 0x1d89c8354 CFRunLoopRunSpecific + 436
5 CFNetwork 0x1d8fe174c -[__CoreSchedulingSetRunnable runForever] + 216
6 Foundation 0x1d94c26e4 __NSThread__start__ + 984
7 libsystem_pthread.dylib 0x1d865c2c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x1d865c220 _pthread_start + 44
9 libsystem_pthread.dylib 0x1d865fcdc thread_start + 4
#2. com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x1d85cf0f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1d85ce5a0 mach_msg + 72
2 CoreFoundation 0x1d89cdcb4 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x1d89c8bc4 __CFRunLoopRun + 1360
4 CoreFoundation 0x1d89c8354 CFRunLoopRunSpecific + 436
5 Foundation 0x1d9395fcc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
6 Foundation 0x1d9395e5c -[NSRunLoop(NSRunLoop) runUntilDate:] + 96
7 UIKitCore 0x204f57540 -[UIEventFetcher threadMain] + 136
8 Foundation 0x1d94c26e4 __NSThread__start__ + 984
9 libsystem_pthread.dylib 0x1d865c2c0 _pthread_body + 128
10 libsystem_pthread.dylib 0x1d865c220 _pthread_start + 44
11 libsystem_pthread.dylib 0x1d865fcdc thread_start + 4
#3. com.twitter.crashlytics.ios.MachExceptionServer
0 Prjkt Prod 0x10085de2c CLSProcessRecordAllThreads (CLSProcess.c:376)
1 Prjkt Prod 0x10085e214 CLSProcessRecordAllThreads (CLSProcess.c:407)
2 Prjkt Prod 0x10084db98 CLSHandler (CLSHandler.m:26)
3 Prjkt Prod 0x100848f88 CLSMachExceptionServer (CLSMachException.c:446)
4 libsystem_pthread.dylib 0x1d865c2c0 _pthread_body + 128
5 libsystem_pthread.dylib 0x1d865c220 _pthread_start + 44
6 libsystem_pthread.dylib 0x1d865fcdc thread_start + 4
#4. Thread
0 libsystem_kernel.dylib 0x1d85dab74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1d865d1f8 _pthread_wqthread + 532
2 libsystem_pthread.dylib 0x1d865fcd4 start_wqthread + 4
#5. Thread
0 libsystem_kernel.dylib 0x1d85dab74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1d865d1f8 _pthread_wqthread + 532
2 libsystem_pthread.dylib 0x1d865fcd4 start_wqthread + 4
#6. Thread
0 libsystem_kernel.dylib 0x1d85dab74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1d865d138 _pthread_wqthread + 340
2 libsystem_pthread.dylib 0x1d865fcd4 start_wqthread + 4
#7. Thread
0 libsystem_kernel.dylib 0x1d85dab74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1d865d1f8 _pthread_wqthread + 532
2 libsystem_pthread.dylib 0x1d865fcd4 start_wqthread + 4
#8. Thread
0 libsystem_kernel.dylib 0x1d85dab74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1d865d1f8 _pthread_wqthread + 532
2 libsystem_pthread.dylib 0x1d865fcd4 start_wqthread + 4
#9. AVAudioSession Notify Thread
0 libsystem_kernel.dylib 0x1d85cf0f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1d85ce5a0 mach_msg + 72
2 CoreFoundation 0x1d89cdcb4 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x1d89c8bc4 __CFRunLoopRun + 1360
4 CoreFoundation 0x1d89c8354 CFRunLoopRunSpecific + 436
5 AVFAudio 0x1de886378 GenericRunLoopThread::Entry(void*) + 156
6 AVFAudio 0x1de8b0c60 CAPThread::Entry(CAPThread*) + 88
7 libsystem_pthread.dylib 0x1d865c2c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x1d865c220 _pthread_start + 44
9 libsystem_pthread.dylib 0x1d865fcdc thread_start + 4
#10. Thread
0 libsystem_kernel.dylib 0x1d85dab74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1d865d138 _pthread_wqthread + 340
2 libsystem_pthread.dylib 0x1d865fcd4 start_wqthread + 4
#11. Thread
0 libsystem_kernel.dylib 0x1d85dab74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1d865d138 _pthread_wqthread + 340
2 libsystem_pthread.dylib 0x1d865fcd4 start_wqthread + 4
#12. Thread
0 libsystem_kernel.dylib 0x1d85dab74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1d865d138 _pthread_wqthread + 340
2 libsystem_pthread.dylib 0x1d865fcd4 start_wqthread + 4
#13. JavaScriptCore bmalloc scavenger
0 libsystem_kernel.dylib 0x1d85d9ee4 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x1d86594a4 _pthread_cond_wait$VARIANT$armv81 + 628
2 libc++.1.dylib 0x1d7bb1090 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 24
3 JavaScriptCore 0x1dfb9e238 void std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 108
4 JavaScriptCore 0x1dfba222c bmalloc::Scavenger::threadRunLoop() + 176
5 JavaScriptCore 0x1dfba19a4 bmalloc::Scavenger::Scavenger(std::__1::lock_guard<bmalloc::Mutex>&) + 10
6 JavaScriptCore 0x1dfba33e4 std::__1::__thread_specific_ptr<std::__1::__thread_struct>::set_pointer(std::__1::__thread_struct*) + 38
7 libsystem_pthread.dylib 0x1d865c2c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x1d865c220 _pthread_start + 44
9 libsystem_pthread.dylib 0x1d865fcdc thread_start + 4
#14. WebThread
0 libsystem_kernel.dylib 0x1d85cf0f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1d85ce5a0 mach_msg + 72
2 CoreFoundation 0x1d89cdcb4 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x1d89c8bc4 __CFRunLoopRun + 1360
4 CoreFoundation 0x1d89c8354 CFRunLoopRunSpecific + 436
5 WebCore 0x1e1622480 RunWebThread(void*) + 600
6 libsystem_pthread.dylib 0x1d865c2c0 _pthread_body + 128
7 libsystem_pthread.dylib 0x1d865c220 _pthread_start + 44
8 libsystem_pthread.dylib 0x1d865fcdc thread_start + 4
Hi. I can't reproduce this. It is random crash and I tried fix it many times and I don't know what caused this problem :/
Hi. Reproduced during very fast scrolling in collectionView with lots of items
I have the same one
Does anyone know the reason. It has not happened often. So, It's very difficult to reproduce.
It looks like the same crash as in #311. Based on that description, I would assume it's a concurrency issue.
There is an animation happening (ex: reload, dequeue, selecting row), while the data gets changed. And the animation is trying to access something based on the old data, but the new data no longer has that index.
@lordzsolt Does anyone have solutions for that? I'm working with million users app so it can be a big problem. Thanks in advance.
@lordzsolt Does anyone have solutions for that? I'm working with million users app so it can be a big problem. Thanks in advance.
What do you mean by 'it can be a big problem'?
Are you experiencing already a high number of these crashes? Is it one of your most frequent crashes and you need to fix it? Or you're just thinking that it could happen?
Because if it happens once in a blue moon, who cares? Apple randomly crashes more of your users at that point.
If it is happening very often and you need to fix it, I'm not sure... First, make sure that it's not a threading issue, like the data source gets the items on a background thread.
I could imagine some hacky solution like limiting your data source to 100-1000 items at a time, then switching out the items when the user reaches the end/start of the page. Not sure if you can make it look seamless.
Is it solved now, please? What is the approximate reason?
Is it solved now, please? What is the approximate reason?
Hi, I have had mysterious crash for long time. Sometimes app crashed on
cellForItemAtIndexPath
inside RxDataSources library. How is it possible?