mayerwin / vs-customize-window-title

Customize Visual Studio Window Title - Visual Studio Extension
https://marketplace.visualstudio.com/items?itemName=mayerwin.RenameVisualStudioWindowTitle
MIT License
108 stars 30 forks source link

Extension causes VS to freeze sporadically #42

Closed amorpheus closed 5 years ago

amorpheus commented 5 years ago

I've seen the "this extension has caused X seconds of unresponsiveness" warning multiple times today, for version 4.3.0. First time was 5, just a few minutes ago it was 6.

The only settings I've changed from defaults were the "solution in X mode" ones: [solutionName] [[tfsBranchName]] (Debugging) - [ideName] [solutionName] [[tfsBranchName]] - [ideName] [solutionName] [[tfsBranchName]] (Running) - [ideName]

I've turned on the Debug option and can hopefully contribute something more substantial when this happens again.

mayerwin commented 5 years ago

Can you confirm what is your version of Visual Studio, and if you're using other extensions?

mayerwin commented 5 years ago

If the issue is consistent, it'd be good if you can temporarily try removing [tfsBranchName] from the pattern to see if this is related to this tag (which does take some time to resolve, though normally it should be asynchronous).

amorpheus commented 5 years ago

Microsoft Visual Studio Professional 2017 Version 15.9.11 VisualStudio.15.Release/15.9.11+28307.586 Microsoft .NET Framework Version 4.7.03190

Extension use is relatively minor, one internal one that has a few helpful shortcuts, ReSharper, and a few of the Power Tools.

I'll try removing the branch tag and see how it goes.

mayerwin commented 5 years ago

For reference: https://resharper-support.jetbrains.com/hc/en-us/articles/115001013390--We-ve-noticed-that-extension-ReSharper-Ultimate-is-slowing-Visual-Studio-message-

mayerwin commented 5 years ago

Hum, it is very much possible that [tfsBranchName] is causing the slowness, as it is the only tag that needs to run on the UI thread for the resolution:

Globals.InvokeOnUIThread(() => name = TfsHelper.GetBranchNameFromLocalFile(Path.GetDirectoryName(sn)));

I need to check if there is a way to run it outside the UI thread, but I remember I added this invoke because it was otherwise throwing exceptions.

mayerwin commented 5 years ago

https://github.com/mayerwin/vs-customize-window-title/blob/master/CustomizeVSWindowTitle/Resolvers/TfsBranchResolver.cs

amorpheus commented 5 years ago

Thanks for the updates. Is resolving the branch name something that needs to ping the TFS server, or where could the slowness happen?

mayerwin commented 5 years ago

Yes, apparently with TFS it needs to ping the server, which is slow. But this alone is not a problem. The problem is if we have to run this on the UI thread.

mayerwin commented 5 years ago

Do you think I could cache the result of the branch name for a particular solution file?

mayerwin commented 5 years ago

Is it guaranteed to not change (my instinct tells me that it can change if the branch is switched while the solution is still open in Visual Studio)?

amorpheus commented 5 years ago

Personally, I don't think I would ever need my VS title to adapt to a new branch name after opening a solution. Maybe checking the branch name could depend on other variables that trigger it?

mayerwin commented 5 years ago

I prefer to be safe and always recheck if it can change (otherwise it can cause bad surprises for users). Since the branch name change could be triggered outside of VS, I'm afraid there is no event we can hook to to refresh only when strictly needed. But anyway it shouldn't be a problem if we can run this asynchronously.

Can you try the following release 4.3.1, where I am running the offending line on the threadpool thread, and let me know if you see any error in the debug or notice any slowness, or crash?

CustomizeVSWindowTitle (4.3.1).vsix.zip

Just extract the vsix file (GitHub doesn't allow to upload vsix files) and install it, it should overwrite the existing version (and keep the link with the auto update if I push a new version on the gallery).

amorpheus commented 5 years ago

Got it running now and it seems to work just fine. :) Thanks!