Description
Describe the bug
This is the root cause of https://developercommunity.visualstudio.com/t/Visual-Studio-freeze-with-message-Loadi/10730260
There are multiple contributing factors, such as an action in VS causing the markdown editor to load even though it's not needed, and the VS SDK not using the vs-threading analyzer to warn about an API that should be called on the UI thread.
in the package init code:
MarkdownEditor/src/MarkdownEditor.Shared/MarkdownEditorPackage.cs
Lines 94 to 96 in a4484fb
RegisterEditorFactory
is being called before switching to the UI thread. However, it turns out that RegisterEditorFactory
calls a COM object, and therefore the UI thread is needed. However, COM isn't JTF aware, hence the deadlock if the UI thread is being blocked until the package load is complete. These two lines should be switched, so the method is called on the UI thread.
To Reproduce
Steps to reproduce the behavior:
- Open a markdown file, but then switch to a different editor, so the markdown editor is in the background.
- Close VS
- Open a new VS instance, and open the same solution.
- Right click the solution and choose Manage NuGet Packages.
Expected behavior
NuGet's package manager opens
Screenshots
I don't want to share another customer's screenshot, but VS has a dialog saying "opening document", that never goes away, and the main VS window becomes "not responding"
Additional context
N/A