Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTableView is very laggy while scrolling

In my OS X application, which uses Core Data my table view is very laggy while scrolling and I have only about 100+ rows there...I'm using Cocoa bindings with NSArrayController to show my data in table view.

I have only one Entity with 13 attributes, but still that table view/scroll view is very laggy.

Is there some common bug / bad coding what causes that behavior? My CPU-usage is around 85% while I'm scrolling.

Anybody have any ideas why is that? I'm using Xcode 7 released version.

UPDATE:

Instruments look like this (I used it first time): enter image description here

Update 2: Im using NSVisualEffectView and overriding allowsVibrancy to return true so I'm getting table views alternative row colors to be like this as in my another project Github- Debter

If I enable core animation layer for my view it helps a lot for scrolling, but my storyboard start do something weard stuff and I can't work well any UI-releated stuff anymore.

like image 762
Prontto Avatar asked Nov 10 '22 05:11

Prontto


1 Answers

Without seeing the code of your UITableView delegate and data source it is pretty hard to know the exact problem.

Some bad habits are:

  • Loading data from CoreData from any of the UITableViewDataSource methods or when the UITableViewCell is being rendered.
  • Loading images on the main thread or loading images in the background without caching them on local storage.
  • Doing complex operations (like image processing) on tableViewCellForIndexPath or other data source methods.

Some questions that might help you find the problem:

  • Are you using a NSFetchedResultsController? If your data set is long (although you mention is not) it could increase performance.
  • Have you checked the number of threads? If it is too high, you might want to use an NSOperationQueue to limit your background tasks.
like image 110
Eneko Alonso Avatar answered Nov 15 '22 05:11

Eneko Alonso