Skip to content

Conversation

@ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Mar 22, 2025

This previously failed with integration test failures. I attribute this to previously trying to move the VisualStudioMetadataReferenceManager to bg thread construction when that very much wants to be on the main thread. Instead, just ensure that the code that creates the VisualStudioMetadataReferenceManager is on the main thread when that value is needed (it already was).

This previously failed with integration test failures. I attribute this to previously trying to move the VisualStudioMetadataReferenceManager when that very much wants to be on the main thread. Instead, just ensure that the code that creates the VisualStudioMetadataReferenceManager  is on the main thread when that value is needed (it already was).

1) Move MiscellaneousFilesWorkspace to bg thread MEF construction
2) Move HostServicesProvider to location of VisualStudioMefHostServices and use in a couple places (this prevents MiscellaneousFilesWorkspace from needing to MEF import VisualStudioWorkspace in it's ctor)
@ToddGrun ToddGrun requested a review from a team as a code owner March 22, 2025 17:13
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 22, 2025
@ToddGrun
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

IMetadataAsSourceFileService fileTrackingMetadataAsSourceService,
VisualStudioWorkspace visualStudioWorkspace)
: base(visualStudioWorkspace.Services.HostServices, WorkspaceKind.MiscellaneousFiles)
Lazy<IMetadataAsSourceFileService> fileTrackingMetadataAsSourceService,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why making the IMetadataAsSourceFileService lazy? Was there some other hidden UI thread dependency there, or it's just a generally big service and there's no reason to ask for it early? A comment might be good either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to flip that question and rather us question why parameters aren't lazy in the package load path. This one switched over to being lazy pretty easily, so I did.

Comment on lines 125 to 126
// VisualStudioMetadataReferenceManager construction requires the main thread
_threadingContext.ThrowIfNotOnUIThread();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a bug tracking fixing this already? It'd be good to link to this to make sure we don't forget to clean it up later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went ahead and created something:

#77791

Comment on lines 288 to 289
// Potential calculation of _metadataReferences requires being on the main thread
_threadingContext.ThrowIfNotOnUIThread();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: consider adding a comment here to wahtever bug we have tracking cleaning this up.

@ToddGrun ToddGrun merged commit 2e8fcbe into dotnet:release/dev17.15 Mar 26, 2025
25 checks passed
ToddGrun added a commit to ToddGrun/roslyn that referenced this pull request Apr 8, 2025
ToddGrun added a commit that referenced this pull request Apr 12, 2025
…78051)

This PR restores behavior introduced in #77768 that were reverted in PR #77983.
The revert occurred as it was flagged for causing ddrit regressions in some of the WinformsVS64.Designer tests. I was unable to reproduce this scenario locally,
but the RPS tests are able to reliably hit this issue.

Digging into it a bit indicated that creating the OpenTextBufferProvider on a bg thread somehow a thread affinity that caused
microsoft.visualstudio.shell.design.ni!DocData.CreateNativeDocData's call to msenv!CEditorManager::RegisterInvisibleEditor's to require an RPC main->bg thread switch.
This breaks the assumptions of RegisterInvisibleEditor and weird things start happening. Jason helped track down the likely culprit, and logged
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2441480 to track that work.

This PR works around that issue by obtaining the RDT while on the main thread. I've logged #78050 to track the Roslyn cleanup
necessary once obtaining the rdt can be done from a background thread.

a) Restores changes from PR #77768 that were reverted in PR #77983
b) Ensure OpenTextBufferProvider._runningDocumentTable is initialized on the main thread.
c) Added comments about https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2441480 and created a tracking bug for us to clean this up once it's fixed (#78050)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants