Debugging: Detecting that UI thread is blocked?
Update: The source for my quick and dirty MonitorUIResponse:
https://drive.google.com/file/d/0B1MyXorVzay9ZjFJc3B6VjI3MUU/view?usp=sharing
Does anyone know of a tool or method that can monitor and log the responsiveness of a UI? I.e. flag occasions where the app is in “Not responding” mode for a period of time (1 sec or more) ?
I’m trying to track down a strange “lagginess” which doesn’t directly reflect in the debug out log.
http://stackoverflow.com/questions/6781852/what-does-process-responding-really-mean
/sub
madexcept has an option “check for frozen main thread”.
Maybe thread with message loop, and timer on main form with PostThreadMessage(…) and in this thread check timestamps of messages?
Jacek Laskowski SendMessageTimeout is the thing that allows you to do this from the outside
Doing it from the outside is a point here. Heisenberg and all.
/sub
David Heffernan That tip worked beautifully!
Uwe Raabe I noticed but haven’t used that “check for frozen main thread” madExcept option. How would it do if it has detected a the main thread’s frozen?
The source for my quick and dirty MonitorUIResponse:
https://drive.google.com/file/d/0B1MyXorVzay9ZjFJc3B6VjI3MUU/view?usp=sharing
Edwin Yip As default it will show the usual exception box.
/interesting
Lars Fosdal hehe now you can do like android or java and ask the user to kill the unresponsive app
There’s a lack of error checking in that code. It’s really very easy to jam in Win32Check calls.
Lars Fosdal nice project, the icing in the cake would be to log the thread(s) stack trace to guess the reason, but anyway, just a breakpoint there is a wonderful tool
David Heffernan you read the “quick and dirty” disclaimer, right? You got the source, you fix it 😉
David Berneda I have a detailed timestamped debug log from the app I’m monitoring, so that will give me a pretty good idea. I’ve already seen stutter where I expected none, and we’ve done some changes to what is pre-cached in the db, and what is done on the fly. The main thing is that I can drop this in with a real user, working on live data and get objective information on the performance, instead of the rather vague and subjective opinion of the users.
WinDbg attached to the application can show the threads and, if there is one thread hang, it can show you the instruction
http://blogs.msdn.com/b/benjaminperkins/archive/2013/01/08/debugging-a-hung-application-with-windbg.aspx
Alexandre Machado Hangs are easy to find. Stuttering is much harder, since it is over literally in seconds.
Lars Fosdal I think it would be nice to log the stack trace when the GUI is busy (hangs)? I think I can make that part with my AsmProfiler (my sampling profiler already can fetch the stack of an external explication, when you have debug symbols ofcourse 🙂 )
André Mussche You have my “go ahead” for creating your own version of this, and add the stack trace. It would indeed be neat.
Lars Fosdal I added an option to my profiler (using your code 🙂 ) to take samples (snapshots of the stack of threads) when UI is busy: https://plus.google.com/+AndréMussche/posts/gtp1nfikvz4
I hope it will be useful for you (it is a nice option which I will use myself from now on!)
André Mussche That is AWESOME! Thank you!
I’ve sanitized the comment list, removing the back and forths on error checking. As much as I enjoy having my imperfect code analyzed, it was strictly off topic.
Let’s just agree that error checking is a good thing. If anyone find my quick and dirty code sample lacking checks, please take care to add them before use.
I think I accidentally deleted someone’s /sub – my apologies.
Lars Fosdal Unfortunately, André Mussche did not correct the most significant mistake.
I suggest you discuss that with him in private, David Heffernan.