Skip to content

Simplify initialization of OpenFileTracker #79281

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jasonmalinowski
Copy link
Member

There's only two things here that could potentially need the UI thread:

  1. The Running Document Table subscription, but OpenTextBufferProvider already abstracted that away.
  2. The IEditorOptionsFactoryService usage, which being a MEF component shouldn't care, but even then we don't need it right away.

It's easy to clean all this up, so just do so.

@jasonmalinowski jasonmalinowski self-assigned this Jul 8, 2025
@jasonmalinowski jasonmalinowski requested a review from a team as a code owner July 8, 2025 01:02
_isExternalErrorDiagnosticUpdateSourceSubscribedToSolutionBuildEvents = true;
}

public async Task InitializeUIAffinitizedServicesAsync(IAsyncServiceProvider asyncServiceProvider)
Copy link
Contributor

Choose a reason for hiding this comment

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

var openFileTracker = await OpenFileTracker.CreateAsync(this, ProjectSystemProjectFactory, asyncServiceProvider).ConfigureAwait(true);

Does the SwitchToMainThreadAsync call above still need to always yield since the amount of work being done is much less now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, maybe getting the telemetry session is still potentially costly

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a pretty old dependency, might be worth checking whether that still needs to happen on the ui thread

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm ahead of you! #79282

Copy link
Member Author

Choose a reason for hiding this comment

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

And @davkean confirmed the session is created really early during VS startup, so no worries about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Is the yielding on the main thread switch still worthwhile then?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm leaving it, since once this is in, I'm doing a follow-up to delete the initialize method entirely since the only remaining work would be the UIContext stuff which doesn't need the UI thread anymore either.

@jasonmalinowski jasonmalinowski force-pushed the simplify-openfiletracker-initialization branch 2 times, most recently from 619ee89 to c8cbf5b Compare July 8, 2025 20:21
There's only two things here that could potentially need the UI thread:

1. The Running Document Table subscription, but OpenTextBufferProvider
   already abstracted that away.
2. The IEditorOptionsFactoryService usage, which being a MEF component
   shouldn't care, but even then we don't need it right away.

It's easy to clean all this up, so just do so.
@jasonmalinowski jasonmalinowski force-pushed the simplify-openfiletracker-initialization branch from c8cbf5b to 7051de1 Compare July 9, 2025 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants