title: UICollectionView performance - _updateVisibleCellsNow
body: <p>I'm working on a custom <code>UICollectionViewLayout</code> that displays cells organized by day/week/month.</p>
  
  <p>It is not scrolling smooth, and it looks like the lag is caused by <code>[UICollectionView _updateVisibleCellsNow]</code> being called on each rendering loop.</p>
  
  <p>Performance is OK for &lt; 30 items, but at around 100 or more, its terribly slow. Is this a limitation of UICollectionView and custom layouts, or am I not giving the view enough information to perform correctly?</p>
  
  <p>Source here: <a href="https://github.com/oskarhagberg/calendarcollection" rel="noreferrer">https://github.com/oskarhagberg/calendarcollection</a></p>
  
  <p>Layout: <a href="https://github.com/oskarhagberg/calendarcollection/blob/master/CalendarHeatMap/OHCalendarWeekLayout.m" rel="noreferrer">https://github.com/oskarhagberg/calendarcollection/blob/master/CalendarHeatMap/OHCalendarWeekLayout.m</a></p>
  
  <p>Data source and delegate: <a href="https://github.com/oskarhagberg/calendarcollection/blob/master/CalendarHeatMap/OHCalendarView.m" rel="noreferrer">https://github.com/oskarhagberg/calendarcollection/blob/master/CalendarHeatMap/OHCalendarView.m</a></p>
  
  <p>Time Profile: 
  <img src="https://i.stack.imgur.com/gdJVG.png" alt="Time profile - Custom layout"></p>
  
  <p><strong>Update</strong></p>
  
  <p>Maybe its futile? Some testing with a plain <code>UICollectionViewController</code> with a <code>UICollectionViewFlowLayout</code> that is given approximately the same amount of cells/screen results in a similar time profile. </p>
  
  <p><img src="https://i.stack.imgur.com/SA9c8.png" alt="Time profile - Standard flow layout"></p>
  
  <p>I feel that it <em>should</em> be able to handle ~100 simple opaque cells at a time without the jitter. Am I wrong? </p>