Outlining tag calculation should not block document open
See original GitHub issueCurrently, outlining tags are synchronously computed during document open. This calculation is not always fast, and will hang the editor for some files. Outlining tags should be asynchronously computed to avoid delays in presenting a file.
🔗 Originally reported at https://developercommunity.visualstudio.com/content/problem/466998/vs-1597-ide-hang.html
Stack trace taken during a UI delay:
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.SyntaxNode.GetRedElement(ref Microsoft.CodeAnalysis.SyntaxNode element, int slot) Unknown
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Syntax.SyntaxList.SeparatedWithManyChildren.GetNodeSlot(int i) Unknown
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.ChildSyntaxList.ItemInternal(Microsoft.CodeAnalysis.SyntaxNode node, int index) Unknown
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.SyntaxNavigator.GetPreviousToken(Microsoft.CodeAnalysis.SyntaxToken current, System.Func<Microsoft.CodeAnalysis.SyntaxToken, bool> predicate, bool searchInsideCurrentTokenLeadingTrivia, System.Func<Microsoft.CodeAnalysis.SyntaxTrivia, bool> stepInto) Unknown
> Microsoft.CodeAnalysis.CSharp.Features.dll!Microsoft.CodeAnalysis.CSharp.Structure.InitializerExpressionStructureProvider.CollectBlockSpans(Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax node, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder<Microsoft.CodeAnalysis.Structure.BlockSpan> spans, Microsoft.CodeAnalysis.Options.OptionSet options, System.Threading.CancellationToken cancellationToken) Line 65 C#
Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.Structure.AbstractSyntaxNodeStructureProvider<Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax>.CollectBlockSpans(Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder<Microsoft.CodeAnalysis.Structure.BlockSpan> spans, Microsoft.CodeAnalysis.Options.OptionSet options, System.Threading.CancellationToken cancellationToken) Line 47 C#
Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.Structure.AbstractSyntaxNodeStructureProvider<System.__Canon>.CollectBlockSpans(Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder<Microsoft.CodeAnalysis.Structure.BlockSpan> spans, System.Threading.CancellationToken cancellationToken) Line 26 C#
Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.Structure.BlockSpanCollector.GetBlockSpans(Microsoft.CodeAnalysis.SyntaxNode node) Line 65 C#
Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.Structure.BlockSpanCollector.Collect(Microsoft.CodeAnalysis.SyntaxNode root) Line 59 C#
Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.Structure.AbstractBlockStructureProvider.ProvideBlockStructureWorker(Microsoft.CodeAnalysis.Structure.BlockStructureContext context, Microsoft.CodeAnalysis.SyntaxNode syntaxRoot) Line 70 C#
Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.Structure.AbstractBlockStructureProvider.ProvideBlockStructure(Microsoft.CodeAnalysis.Structure.BlockStructureContext context) Line 38 C#
Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.Structure.BlockStructureServiceWithProviders.GetBlockStructure(Microsoft.CodeAnalysis.Document document, System.Threading.CancellationToken cancellationToken) Line 60 C#
Microsoft.CodeAnalysis.EditorFeatures.Wpf.dll!Microsoft.CodeAnalysis.Editor.Implementation.Structure.AbstractStructureTaggerProvider<Microsoft.VisualStudio.Text.Tagging.IOutliningRegionTag>.ProduceTagsSynchronously(Microsoft.CodeAnalysis.Editor.Tagging.TaggerContext<Microsoft.VisualStudio.Text.Tagging.IOutliningRegionTag> context, Microsoft.CodeAnalysis.Editor.DocumentSnapshotSpan documentSnapshotSpan, int? caretPosition) Line 127 C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Tagging.AbstractAsynchronousTaggerProvider<Microsoft.VisualStudio.Text.Tagging.IOutliningRegionTag>.ProduceTagsSynchronously(Microsoft.CodeAnalysis.Editor.Tagging.TaggerContext<Microsoft.VisualStudio.Text.Tagging.IOutliningRegionTag> context) Line 214 C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Tagging.AbstractAsynchronousTaggerProvider<Microsoft.VisualStudio.Text.Tagging.IOutliningRegionTag>.TagSource.GetAccurateTagIntervalTreeForBuffer(Microsoft.VisualStudio.Text.ITextBuffer buffer, System.Threading.CancellationToken cancellationToken) Line 662 C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Tagging.AbstractAsynchronousTaggerProvider<Microsoft.VisualStudio.Text.Tagging.IOutliningRegionTag>.Tagger.GetTagsWorker(Microsoft.VisualStudio.Text.NormalizedSnapshotSpanCollection requestedSpans, bool accurate, System.Threading.CancellationToken cancellationToken) Line 236 C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Tagging.AbstractAsynchronousTaggerProvider<System.__Canon>.Tagger.GetAllTags(Microsoft.VisualStudio.Text.NormalizedSnapshotSpanCollection requestedSpans, System.Threading.CancellationToken cancellationToken) Line 219 C#
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractLanguageService<Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage, Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpLanguageService>.EnsureOutliningTagsComputed(Microsoft.VisualStudio.Text.Editor.IWpfTextView wpfTextView) Line 351 C#
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractLanguageService<Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage, Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpLanguageService>.ConditionallyCollapseOutliningRegions(Microsoft.VisualStudio.TextManager.Interop.IVsTextView textView, Microsoft.VisualStudio.Text.Editor.IWpfTextView wpfTextView, Microsoft.CodeAnalysis.Workspace workspace, bool isOpenMetadataAsSource) Line 311 C#
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractLanguageService<Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage, Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpLanguageService>.SetupNewTextView(Microsoft.VisualStudio.TextManager.Interop.IVsTextView textView) Line 254 C#
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractLanguageService<Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage, Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpLanguageService>.VsCodeWindowManager.AddAdornments() Line 156 C#
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.CompoundTextViewWindow.TextDocData_OnNewLanguageService(ref System.Guid sidLangServiceID) Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.CompoundTextViewWindowPane.OnTextViewHostUpdated(object sender, System.EventArgs e) Unknown
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.Init_InitializeWpfTextView() Unknown
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Outlining tag calculation should not block document open
Trying to open a particular code file in the IDE regularly causes a hang. I have attached a memory dump. fixed in: visual...
Read more >The Document Outline Dilemma
However, the specifications defined a “Document Outline Algorithm” which would re-calculate the heading levels for the existing numbered heading ...
Read more >Computer says NO to HTML5 document outline
The simple reason for this change is that the HTML5 document outline is not implemented and despite efforts to get it implemented, ...
Read more ><h1>–<h6>: The HTML Section Heading elements
Heading information can be used by user agents to construct a table of contents for a document automatically. Do not use heading elements...
Read more >Reading Order tool for PDFs (Acrobat Pro)
The Reading Order tool in Adobe Acrobat provides the easiest and quickest way to fix reading order and basic tagging problems.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Great catch, this is one of the known sources of delays on file open. I reactivated the ticket and moved it to the editor. Feel free to close this issue.
Got it. Tracked internally by AB#1180986, this one can be closed then.