Skip to content

Fatal error: Incorrect item identifier crash in LayoutModel.removeItem(by: itemId: UUID) #100

@milosjagetic

Description

@milosjagetic

Hello,
I'm currently getting an assertionFailure:
ChatLayout/LayoutModel.swift:188: Fatal error: Incorrect item identifier.
Method in question: LayoutModel.removeItem(by: itemId: UUID)

Call stack:

#6	0x000000011383534c in LayoutModel.removeItem(by:) at ChatLayout/Classes/Core/Model/LayoutModel.swift:188
#7	0x0000000113852600 in StateController.process(changeItems:) at ChatLayout/Classes/Core/Model/StateController.swift:843
#8	0x0000000113820c00 in CollectionViewChatLayout.prepare(forCollectionViewUpdates:) at /ChatLayout/Classes/Core/CollectionViewChatLayout.swift:714
#28	0x000000018573c55c in ___lldb_unnamed_symbol337207 ()
#29	0x000000011348b3e8 in ChatViewController.applySnapshot(animated:completion:) at ChatModule/Chat/ChatViewController.swift:75
...
...

I'm using NSDiffableDataSource as a datasource. I have had this crash occur and it is consistently reproducable.
Following are the IDs of items/sections in the current (before the snapshot that causes the crash) snaphost held by the datasource:

- Section: 1779746400
-- loading

The following are the IDs of the snapshot that causes the crash, which is applied after the previous one:

- SECTION: 1779228000
-- loading
-- 1779228000.0
-- $FICvyAodTh2liiyPLF4pA5M38SowG24SVNHxxQPlDA
- SECTION: 1779660000
-- 1779660000.0
-- $RRwD2RdKq2veamHLyYyhvTwj_PUj32aagDAj3cNOhQ
-- $UcSZaB4_FUbtUJ253Gk09dDu8NOSMfri0WthkmunRM
-- $tO5VN_SvIdYqhIcCjz7giBhKsVKS0gHBBRsxZVosrU
-- $oDdWook54twBDg32r1ii_tZjIINB5js8RsaPhjDRps
-- $vM4Sn1UCdDl5ubtfwisJEYLntEqHg0Vg91HbQixkwY
-- $1b_QQxhS9TzI_U4beoxyl7ip0Ku8trv0Phniypfa7I
-- $CXTO6BzenmRYW5rHeQ5vLavxUli0NuhPV_m-VByZ5o
-- $v3elyATmsB31j0K1fUprP75xEDPP1cROYdm1eSLt084
-- $S5-171fkqdEUAeJh1m1gHtDyt9kGOmNlB7G3ou5SvI

In StateController.process(changeItems:) the deletedSectionsIndexesArray contains only 0 and deletedItemsIndexesArray contains only 0; 0, which reflects that only section and its only item from the "before" snapshot I guess. That was the item removeItem(by:) was called with.
I have managed to work around the issue by keeping the loading item in it's own section from the "before" snapshot, ie. not inserting it at the top of new sections which have arrived.
Reproducible in 2.3.2 and 2.4.2 releases

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions