Aspnetcore: Semantic Tokens Exception: The collections refer to different snapshots

Created on 2 Sep 2020  路  6Comments  路  Source: dotnet/aspnetcore

System.ArgumentException
  HResult=0x80070057
  Message=The collections refer to different snapshots.
  Source=Microsoft.VisualStudio.Text.Data
  StackTrace:
   at Microsoft.VisualStudio.Text.NormalizedSnapshotSpanCollection.Union(NormalizedSnapshotSpanCollection left, NormalizedSnapshotSpanCollection right)
   at Microsoft.VisualStudio.LanguageServer.Client.SemanticTokensRangeClassificationTagger.GetVisibleSpansInAllTextViewsWithSafetyMargin() in 
   SemanticTokensRangeClassificationTagger.cs:line 357
   at Microsoft.VisualStudio.LanguageServer.Client.SemanticTokensRangeClassificationTagger.OnLayoutChanged(Object sender, TextViewLayoutChangedEventArgs e) in SemanticTokensRangeClassificationTagger.cs:line 173
   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent[TArgs](Object sender, EventHandler`1 eventHandlers, TArgs args)
  This exception was originally thrown at this call stack:
    [External Code]
    Microsoft.VisualStudio.LanguageServer.Client.SemanticTokensRangeClassificationTagger.GetVisibleSpansInAllTextViewsWithSafetyMargin() in SemanticTokensRangeClassificationTagger.cs
    Microsoft.VisualStudio.LanguageServer.Client.SemanticTokensRangeClassificationTagger.OnLayoutChanged(object, Microsoft.VisualStudio.Text.Editor.TextViewLayoutChangedEventArgs) in SemanticTokensRangeClassificationTagger.cs
    [External Code]

cc/ @ryanbrandenburg

External area-razor.tooling bug feature-razor.vs

All 6 comments

Were you able to reproduce this more than once and if so what were the steps?

Were you able to reproduce this more than once and if so what were the steps?

No, I encountered this while I was debugging something else so just captured the error info. I don't have any firm re-pro steps unfortunately. I was running a patched LSP platform, but it didn't have any changes from the main branch.

Isn't this an LSP platform semantic token issue? /cc @gundermanc

Thanks for the report, I've migrated to Editor area path: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1193189

Just to close the loop, @TanayParikh I believe I have a fix for this here, but I wasn't able to repro: https://devdiv.visualstudio.com/DevDiv/_git/VSLanguageServerClient/pullrequest/272708.

Did you see this somewhat consistently and does this look like something that needs to go in 16.8 vs. 16.9?

Based on the code path, it looks extremely obscure:

This exception should only be possible if 1) range parse is still active (first-full-document parse hasn't completed yet) 2) multiple views are attached to the same text buffer and tagger 3) one of the views is in a layout, preventing access to the TextViewLines collection, causing the lastVisibleLines collection from a previous snapshot to be used. When this collection is unioned with another view that has already done its layout, Union() throws because they are on different text snapshots.

If it indeed is just a gold bar and as rare as it seems, I think we can safely defer the fix to 16.9.

Did you see this somewhat consistently and does this look like something that needs to go in 16.8 vs. 16.9?

I saw this only once, so I think it should be pretty safe to defer to 16.9.

Thanks for looking into it!

Was this page helpful?
0 / 5 - 0 ratings