ra1028 / DiffableDataSources

💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.

Home Page:https://ra1028.github.io/DiffableDataSources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dear, please help me: I probably found a big bug, in iOS 10.3 and iOS 11, update datasource will not work correctly, please look at below.

willokyes opened this issue · comments

commented

Dear,

I use IBPCollectionViewCompositionalLayout in iOS 13 will no problem, but in iOS 10 and iOS 11 is not ok, please see the screenshot and the IBPCollectionViewCompositionalLayout.zip example that I sent to you below, run and select OrthogonalScrollBehaviorViewController.swift with iOS 10.3, the Xcode will crash.

Why it is, please help me, I take two days to debug this question, but no answer.

I put the demo.zip project on the Aliyun OSS, sincerely hope you can download the demo project and debug it.

Please download the demo: https://dxy-demo.oss-ap-northeast-1.aliyuncs.com/IBPCollectionViewCompositionalLayout.zip

Or the link of github: https://github.com/willokyes/IBPCollectionViewCompositionalLayout-Demo

I'm looking forward to your reply.

Thank you.

70385899-e38e5480-19cc-11ea-9e25-0b016531e582

@willokyes

Sorry for my very late reply.

This could be due to a custom layout.
Open a similar issue at IBP and seek advice.

For anyone checking this issue: I've ran into this as well.

As it turns out UICollectionViewFlowLayout and UICollectionViewCompositionalLayout have issues with the layout attributes of decoration views when func performBatchUpdates is used. DiffableDataSources always uses func performBatchUpdates even when not animating.

Developers at Apple found this as well and in a later beta of iOS 13 UICollectionViewDiffableDataSource uses func reloadData when not animating the changes, this fixed the crash at least when not animating. The bug was completely patched in iOS 14.

My solution was to create a wrapper around UICollectionViewDiffableDataSource that uses UICollectionViewDiffableDataSource on iOS 13+ and the old UICollectionViewDataSource on iOS 12- and it doesn't animate the changes when it knows the decoration views will change.