-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Avoid accessing DocData prior to document initialization #67978
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
Conversation
| (int)frameType == (int)__WindowFrameTypeFlags.WINDOWFRAMETYPE_Document) | ||
| { | ||
| TrackNewActiveWindowFrame(frame); | ||
| var runningDocumentTable = ThreadingContext.JoinableTaskFactory.Run(() => GetRunningDocumentTableAsync(ThreadingContext.DisposalToken).AsTask()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this just block here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➡️ In general, no. This method returns immediately in all but the first invocation, and the first invocation should come through the other path. In the event it doesn't it'll wait here for the service to be initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not especially worried here because in the off chance there is a problem, it'll be an item on the call stack in RPS results.
| { | ||
| if (docData is IVsTextBuffer bufferAdapter) | ||
| { | ||
| TextBuffer = _documentTracker._editorAdaptersFactoryService.GetDocumentBuffer(bufferAdapter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to make sure, is our cleanup code resilient to this not being her
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the stack here is null annotated and everything I saw had null checks in place. To outside code, this just shows up as the DocumentId being null, which is also the case any time a non-Roslyn document has focus.
This change builds off observations and instructions provided by @RadwanFaci.
Supersedes #67976