First click on working directory freezes everything for way too long
Steps to reproduce:
- open a repository
- click on the working directory
- Never, under any circumstances, should the whole UI freeze and stop responding. Even if there is a legitimate reason why loading the data about the working directory would take any perceptible amount of time (i.e. more than a few milliseconds), the critical parts of the UI, and those not involved in the loading (e.g. scrolling the list of commits) should remain responsive. Any part of the UI that has a good reason for becoming unavailable while something is being processed, should become greyed out and a spinning icon or equivalent should be displayed.
- Loading the working directory shouldn't be particularly slow in the first place. A working directory that has no change at all should show up virtually instantly; one that only has a handful of changes should load so quickly that any violation of the expectations outlined in the previous point would become almost negligible.
- The whole UI freezes and becomes unresponsive while the data is loaded. It doesn't resopond to scrolling, to clicking anywhere, even to resizing or (un)maximizing the window.
- That lasts for a disproportionately long amount of time. With a particular repository that I tried to open a few minutes ago, it got frozen for several minutes and I ended up killing Thg. Even a working directory that has no changes at all takes a short but perceptible fraction of a second, enough to annoy you a little bit. If there are just a handful of changes it can take a few seconds. Something is not being done efficiently enough.
The slowness in and of itself, and the fact that during that time the whole UI stops responding, are two separate issues each of which needs fixing on its own, even though fixing either will somewhat alleviate the impact of the other (and certainly the freezing is the most serious one).
BTW, this is a regression. Until recently I was using Ubuntu 16.04, and I had installed whatever version of THG was available through the package system. Then, upon upgrading to 20.04, Ubuntu decided to uninstall THg without asking, and it was no longer available via ppa, so I installed it from source. I never observed the issue on the older version.