Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to find code that is blocking your main thread?

I have a UIScrollView in which I am placing a bunch of views as you are scrolling. it is downloading images from an api end point. The issue is that scrolling doesn't feel as smooth as it should be. I know this is because mostly something is blocking the main thread. I have searched through the whole code and commented out any UI update code, but scrolling fast is still laggy.

Any pointers on what is the best way to find which part of your code blocks the main thread?

like image 252
aherlambang Avatar asked Jun 16 '12 20:06

aherlambang


1 Answers

Instruments. There's abso-freaking-lutely nothing like it. Even apple's documentation on it mentions finding high-CPU related tasks.

Personally though, I recommend the Time Profiler. Of which, an excellent tutorial may be found here.

like image 191
CodaFi Avatar answered Oct 22 '22 11:10

CodaFi