As soon as the user enters, I get the results (text) by moving the local graph of words in the background thread. Each key press cancels the previous operation. If the operation is completed, the data source is updated and reloadData is called in the main thread. This works fine and very fast (as fast as the user can type), even when tens of thousands of results are returned.
To adjust the size of each cell in the collection view, I applied sizeForItemAtIndexPath to the delegate UICollectionViewDelegateFlowLayout. Unfortunately, this leads to a small but noticeable lag when the user types. To be sure that no time was lost in my size calculation logic, I tried just returning a fixed size, but it still killed performance. I am surprised by this, because at any given time on the screen there are only ~ 120 cells or so. Commenting on this method, the response time is immediately immediate again, even for very large data sets.
Any ideas on improving the performance of a UICollectionView with custom cell sizes?
thanks
Further clarification ...
The program returns all possible words from a given set of letters, then sorts by score or alphabetically, etc. As the user types, the total number of words grows rapidly (exponentially if multiple wildcards are entered). Words change as you type so that the width of the cells is updated accordingly and transferred to the next line, processed by the layout of the stream.
It seems that the problem is the number of cells displayed on the screen at any given time. In sizeForItemAtIndexPath, if I just return the large size, where only one or two cells are visible, the update happens very quickly; however, if I return a size that just matches the text, I get 100 + visible cells, and there is a lag. If I comment on sizeForItemAtIndexPath and just use a fixed size cell, it is fast, but that is not what I am going to do.