New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash in CollectionViewDiffCalculator #45
Comments
What is the actual exception that is being thrown? It looks like an
internal UIKit assertion is being violated.
…On Thu, Jan 5, 2017 at 6:00 AM, Markus Klepp ***@***.***> wrote:
Hi,
my app sometimes crashes when updating the CollectionView. Unfortunately
I'm not able to reproduce the crashes, but the same code (using the
TableViewDiffCalculator) works without problems for my tableviews.
I'm using pagination and want to eliminate possible duplicates - hence the
diff function here.
// strongSelf is from a guard clause in the callback
let diff = strongSelf.itemList.diff(newItems)
strongSelf.itemList.append(contentsOf: strongSelf.itemList.apply(diff))
the didset iss correctly triggered with the append
var itemList: Array<Item> = [] {
didSet {
self.diffCalculator?.rows = itemList
}
}
Relevant crashlog:
#0. Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x181562014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x18162a450 pthread_kill + 112
2 libsystem_c.dylib 0x1814d63e0 abort + 140
3 libsystem_malloc.dylib 0x1815a6a38 _nano_vet_and_size_of_live + 330
4 libsystem_malloc.dylib 0x1815a8bf0 _nano_malloc_check_clear + 392
5 libsystem_malloc.dylib 0x1815a7b3c nano_malloc + 44
6 libsystem_malloc.dylib 0x1815962c4 malloc_zone_malloc + 172
7 CoreFoundation 0x18246615c _CFRuntimeCreateInstance + 312
8 CoreFoundation 0x182551604 __CFStringCreateImmutableFunnel3 + 2116
9 CoreFoundation 0x18247034c CFStringCreateCopy + 504
10 CoreFoundation 0x1825519f0 _CFStringCreateWithFormatAndArgumentsAux2 + 256
11 CoreFoundation 0x182575b98 _CFLogvEx2Predicate + 156
12 CoreFoundation 0x182575eec _CFLogvEx3 + 408
13 Foundation 0x18305c454 _NSLogv + 132
14 Foundation 0x182f8335c NSLog + 32
15 Foundation 0x18301f76c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 64
16 UIKit 0x188ce90e8 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] + 13428
17 UIKit 0x188cecc34 -[UICollectionView _endUpdatesWithInvalidationContext:tentativelyForReordering:animator:] + 92
18 UIKit 0x188cecf14 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] + 384
19 UIKit 0x188cecd74 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 96
20 UIKit 0x188ceccf8 -[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 84
21 UIKit 0x1885c71c0 -[UICollectionView performBatchUpdates:completion:] + 64
22 Dwifft 0x100f1439c CollectionViewDiffCalculator.rows.setter (Dwifft+UIKit.swift)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#45>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAtM5--lbdhjr8xLpumpRp2_bx30BdUrks5rPM1EgaJpZM4Lbktu>
.
|
The error message is But, there seem to be two kinds of errors leading to this crash: one with the stacktrace/error above and an Stacktrace:
Thanks for helping, I'm totally clueless here. |
Update on my side: Found this blogpost describing the problem: https://fangpenlin.com/posts/2016/04/29/uicollectionview-invalid-number-of-items-crash-issue/ After changing the way I handle the collection view update it seems to not crash anymore:
Which brings me to this question: Is it ok to use the rows of the diffCalculator directly? Or put another way: Is there a reason why you recommend updating the diffcalculator with the |
I think the important thing here is how you implement |
(closing as I am fairly certain this is not an internal Dwifft issue.) |
Hi,
my app sometimes crashes when updating the CollectionView. Unfortunately I'm not able to reproduce the crashes, but the same code (using the TableViewDiffCalculator) works without problems for my tableviews.
I'm using pagination and want to eliminate possible duplicates - hence the diff function here.
the didset iss correctly triggered with the append
Relevant crashlog:
Any idea what could be happening here?
The text was updated successfully, but these errors were encountered: