Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out which function is cased hang on main thread

Is there any way to easy to debug out what cause my hang on main thread? when I debug without enable the breakpoint, there's a moment that the tableView will hang for a while, but how to found what cause that?

EDIT I have upload the thread status when the app is hang, and I click the Pause button. show bellow:

enter image description here enter image description here

EDIT I have upload the Profile of Instruments, which selected duration is which the screen is hang.

enter image description here

Edit I have create a root problem question about this.Image download and save to file, Image read from file will cause lock?

like image 991
JerryZhou Avatar asked Oct 15 '25 04:10

JerryZhou


1 Answers

You can use Instruments for that. Choose Product / Profile. Choose Time Profiler. Start profiling by pressing Record (the red circle). When the table view hangs, you'll most likely see a change in the graph. Select the region on the graph corresponding to the time when the table view hanged, and see what's being done on the main thread. You can find more info on Instruments on the web.

Another option is to start normal debugging, and then press "Pause" right when the tableView hangs. And then look at the stack trace for the main thread.

like image 178
FreeNickname Avatar answered Oct 17 '25 18:10

FreeNickname



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!