I have an application in active use with a rarely occurring 'freeze' of the UI thread. This of course results in the application becoming unresponsive and requires the user to terminate it manually.
Due to how difficult this issue is to reproduce, I'd like to develop some tools to help gather data on when it's happening in the field and what's occurring at the time. What I'm thinking about is some sort of background watchdog task that would monitor a 'heartbeat' from a periodically scheduled UI thread task. If it goes quiet for too long, I can say that the UI is effectively locked up (or at least stalled for way longer than I'd ever want) and hence gather data.
So, in preparation for this, a few questions:
Does something like this already exist? This seems like a reasonably common problem, so if there are existing tools to help diagnose this, it might be worth using those rather than rolling my own solution.
I'm still debating what information I should try to gather when the freeze is detected. Is there some way for me to easily grab the stack trace of the UI thread so that it can be logged? Possibly grab stack traces from all active threads? Is there some way I can capture a complete debug dump?