Entries with the uicollectionview tag
Pull request Add collection view batch updates on composed-swift/ComposedUI
The idea of this is that without breaking the API the collection view will batch updates.
Inserting a large number of sections is the main area of performance loss we are currently encountering, because the sections are inserted individually and not batched. This change alone has reduce the initial load time of one our screens (which has 100-150 sections added at once) from 30-45 seconds down to less than a second (at least it is not noticeable).
I had created https://github.com/composed-swift/Composed/pull/17 to try and address this, which has the advantage that it would apply to other view types (e.g. UITableView
), but I believe does not offer the same performance improvements and it is restricted to a single ComposedSectionProvider
.
This is a draft to collect feedback; as you can see there are some TODOs but I think there's enough implemented to provide an overview of the changes that would be required to implement this.
This does not currently work; there are situations that cause the collection NSInternalInconsistencyException', reason: 'Invalid update
error. I have some failing tests that demonstrate what the result should be.
Pull request Potential fix for invalidation crashes on composed-swift/ComposedUI
As mentioned in https://github.com/composed-swift/ComposedUI/issues/13 and https://github.com/composed-swift/ComposedUI/issues/8 there are some scenarios where the collection view’s data is out-of-sync with the data in composed.
As mentioned in https://github.com/composed-swift/ComposedUI/issues/13 calling layoutIfNeeded
can trigger the data to be in sync again. In this I have added it to mappingWillBeginUpdating(_:)
which appears to solve the problem.
It might be needed in replace(sectionProvider:)
(because reloadData
is called) and/or mappingDidInvalidate(_:)
(for the same reason) but I’m still investigating.
I have validated this fix against https://github.com/composed-swift/ComposedUI/issues/8 and it fixes the crash.
https://github.com/composed-swift/ComposedUI/issues/13 still needs to be investigated and may require layoutIfNeeded
to be called in mappingDidInvalidate
. Marking as a draft until this is checked.
Pull request Add GitHub actions on composed-swift/ComposedUI
The tests are currently essentially empty but at a minimum this makes sure things compile on Xcode 11.7 and 12.0.
@shaps80 I think this will need updates to the repo settings to enable GitHub Actions.
Pull request Fix swift 5.2 compiling on composed-swift/ComposedUI
Introduced in #9. #12 adds GitHub actions to ensure this doesn't occur again.
Pull request Fix crash when performing update while animating on composed-swift/ComposedUI
The completion
block is called when the animation has completed, but at the end of the updates
block the data has already been updated (from the perspective of the UICollectionView
).
Not calling reset()
and setting defersUpdate = false
could cause crashes e.g. due to changes being applied multiple times.
The best way to recreate this is to have a series of updates occur very close to each other but with the "Slow Animation" setting enabled in the simulator.
This change might also apply to table views, I have not checked.
The crash would often be along the lines of "Tried to delete section at index 11 but there were only 11 sections" or would occur in elementsProvider(for:)
with the error "No UI configuration available for section 11"
when performing a non-data change e.g. a reload of a section