Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package initialization can cause deadlock #243

Open
zivkan opened this issue Aug 27, 2024 · 2 comments
Open

package initialization can cause deadlock #243

zivkan opened this issue Aug 27, 2024 · 2 comments
Labels

Comments

@zivkan
Copy link

zivkan commented Aug 27, 2024

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:

RegisterEditorFactory(editorFactory);
await JoinableTaskFactory.SwitchToMainThreadAsync();

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:

  1. Open a markdown file, but then switch to a different editor, so the markdown editor is in the background.
  2. Close VS
  3. Open a new VS instance, and open the same solution.
  4. 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

@zivkan zivkan added the bug label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@zivkan and others