4

Is there any way to detect when the main thread is locked/busy (aka will not respond to touch events) ?

possible directions check the size of the dispatch_get_main_queue (but i dont know how to manipulate this object to see its size)

[[UIApplication sharedApplication] isIgnoringInteractionEvents] but this method only works part of the time

user353877
  • 1,211
  • 1
  • 15
  • 21
  • Can you give us more context? Why do you want to do this? – John Estropia Feb 17 '12 at 03:37
  • You might want to do this to improve application responsiveness. I am also trying to find a way to detect calls that are blocking main thread for more then X seconds. Of course you can use Time Profiler but it does not show you the absolute time ui thread (main thread) was blocked. – Kostia Kim May 03 '13 at 07:25
  • You can try to print the ID number of the running thread and then get some intuition which thread currently runs. – Mike.R May 03 '13 at 12:42

1 Answers1

4

Use instruments tool "time profiler" and then find the clue about what's blocking your main thread.

For example: I find a method is running 12.7% cpu time of main thread. Then I find it has name "waitingThread". It looks like the method is blocking the main thread.

enter image description here

hrchen
  • 1,223
  • 13
  • 17