jacobdufault / fullinspector

Full Inspector supercharges Unity's inspector
MIT License
111 stars 27 forks source link

Visual Studio CPU usage spikes when working on a GetEditor() method for the Toolkit #197

Closed SugoiDev closed 7 years ago

SugoiDev commented 7 years ago

This a crazy one! I'm submitting this as an issue to help future visitors know they are not crazy, since I doubt JetBrains will ever have a chance to actually fix this and there isn't much that can be done on FullInspector's side. Maybe this would be better suited to a wiki page.

I submitted a bug report to JetBrains, but, again, this is a pretty esoteric situation.


My workaround: use Rider to edit stuff related to the toolkit. Rider flies even on a large solution and frequent reloads.


Issue description and investigation

I noticed that when creating editors using the toolkit, Visual Studio would use more and more CPU until it hanged. It eventually comes back to life, but can take a long time.

I tracked down the issue to double clicking anything inside a tkControlEditor GetEditor() method. It seems related to the how partial classes are used in the toolkit. From what I could figure, ReSharper will make VisualStudio's analyzers repeatedly parse the code, which causes the high CPU usage.

Disabling the analyzers (with a ruleset file) didn't make any difference.

Once the GetEditor method grows a bit (over 50 lines or so), it'll be unbearable.

The issue is also present in DLL builds.

To discard any interference, I tested with the following (including combinations)

Visual Studio 2015, update1, update2, update3 Visual Studio 2017RC up to latest release as of 2016/12/26. ReSharer 2016.1/2/3 up to EAP7. Clean Windows install with clean VS (only ReSharper installed) and ReSharper installs (no plugins).

The issue will still occur even with ReSharper's solution analysis disabled. It will not occur if we suspend ReSharper, but suspending it while the issue is happening will not make it stop.

Here's a gif of it going on. Double clicking literally anything inside a GetEditor method will trigger it the same.

The CPU usage will grow every time you select something, until it hangs.

demonstration

Note: You'll notice I'm using C#6's nameof, but this is not related to the issue itself (tested on C#4 previously).

jacobdufault commented 7 years ago

:(, Visual Studio 2017 works pretty well even without resharper. I doubt there is much that can be done on the FI side to fix this.

SugoiDev commented 7 years ago

You bet.

Since I'm using Rider quite a bit (alongside with VS), I'm not feeling that much. It is pretty bizarre, though! If I had a bit more time, I would dig into it to try to understand just what could be happening behind the scenes.

I'll go ahead and close this issue. It'll still be around for people to search, but there isn't a lot that can be done about this.

Future travelers, here be dragons.