I'm having trouble putting up together Kotlin Flows and async DiffUtil.
I have this function in my RecyclerView.Adapter that computes on a computation thread a DiffUtil and dispatch updates to the RecyclerView on the Main thread :
suspend fun updateDataset(newDataset: List<Item>) = withContext(Dispatchers.Default) {
        val diff = DiffUtil.calculateDiff(object : DiffUtil.Callback()
        {
            override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean
                    = dataset[oldItemPosition].conversation.id == newDataset[newItemPosition].conversation.id
            override fun getOldListSize(): Int = dataset.size
            override fun getNewListSize(): Int = newDataset.size
            override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean
                    = dataset[oldItemPosition] == newDataset[newItemPosition]
        })
        withContext(Dispatchers.Main) {
            dataset = newDataset // <-- dataset is the Adapter's dataset
            diff.dispatchUpdatesTo(this@ConversationsAdapter)
        }
    }
I call this function from my Fragment like this :
private fun updateConversationsList(conversations: List<ConversationsAdapter.Item>)
{
    viewLifecycleOwner.lifecycleScope.launch {
        (listConversations.adapter as ConversationsAdapter).updateDataset(conversations)
    }
}
updateConversationsList() is called multiple times within a very short period of time because this function is called by Kotlin's Flows like Flow<Conversation>. 
Now with all that, I'm sometimes getting a java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder error. Reading this thread I understand that it is a threading problem and I've read lots of recommendation like this one that all say : the thread that updates the dataset of the Adapter and the thread that dispatches updates to the RecyclerView must be the same. 
As you can see, I already respect this by doing :
withContext(Dispatchers.Main) {
    dataset = newDataset
    diff.dispatchUpdatesTo(this@ConversationsAdapter)
}
Since the Main thread, and only it, does these two operations, how is it possible that I get this error ?
 
    