Bug #97934 UI delay in mysql.visualstudio.dll MySqlQuickInfoController.OnTextViewMouseHover
Submitted: 9 Dec 2019 22:55 Modified: 2 Jun 2021 17:15
Reporter: Christian Gunderman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Visual Studio Integration Severity:S5 (Performance)
Version: OS:Windows
Assigned to: CPU Architecture:Any

[9 Dec 2019 22:55] Christian Gunderman
Description:
Users of the MySql extension for Visual Studio frequently experience UI delays, ranging from 2 to 20 seconds, with the following stack:

microsoft.visualstudio.platform.vseditor.dll!Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.OnHoverTimer
95.8%
microsoft.visualstudio.platform.vseditor.dll!Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.RaiseHoverEvents
95.8%
mysql.visualstudio.dll!MySql.Data.VisualStudio.LanguageService.MySqlQuickInfoController.OnTextViewMouseHover
95.8%
microsoft.visualstudio.platform.vseditor.dll!Microsoft.VisualStudio.Language.Intellisense.Implementation.LegacyQuickInfoBroker.TriggerQuickInfo
95.4%
microsoft.visualstudio.threading.dll!Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[System.__Canon]
88.4%
microsoft.visualstudio.threading.dll!Microsoft.VisualStudio.Threading.JoinableTask`[System.__Canon].CompleteOnCurrentThread
88.2%
microsoft.visualstudio.threading.dll!Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread
88.2%
microsoft.visualstudio.threading.dll!Microsoft.VisualStudio.Threading.JoinableTaskFactory.WaitSynchronously
59.2%
microsoft.visualstudio.threading.dll!Microsoft.VisualStudio.Threading.JoinableTaskFactory.WaitSynchronouslyCore
59.2%
mscorlib.dll!System.Threading.Tasks.Task.Wait
59.2%
mscorlib.dll!System.Threading.Tasks.Task.InternalWait
59.2%
mscorlib.dll!System.Threading.Tasks.Task.SpinThenBlockingWait
59.2%
mscorlib.dll!System.Threading.Monitor.Wait
53.2%
clr.dll!ObjectNative::WaitTimeout
53.2%
clr.dll!SyncBlock::Wait
53.2%
clr.dll!Thread::Block
53.2%
clr.dll!CLREventBase::Wait
53.2%
clr.dll!CLREventBase::WaitEx
53.2%
clr.dll!Thread::DoAppropriateWait
53.2%
clr.dll!Thread::DoAppropriateWaitWorker
53.2%
clr.dll!Thread::DoSyncContextWait
53.2%
clr.dll!MethodDescCallSite::CallTargetWorker
53.2%
clr.dll!CallDescrWorkerWithHandler
53.2%
clr.dll!CallDescrWorkerInternal
53.2%
mscorlib.dll!System.Threading.SynchronizationContext.InvokeWaitMethodHelper
53.2%
microsoft.visualstudio.threading.dll!Microsoft.VisualStudio.Threading.NoMessagePumpSyncContext.Wait
53.2%
kernelbase.dll!WaitForMultipleObjects

The implementation of the MySql extension quick info relies on legacy (pre-2017 15.6) VS Quick Info APIs, which are UI thread affinitized and blocking.

In VS 2017 15.6, these APIs were replaced with async quick info, which can be called in a non-blocking fashion off the UI thread to reduce the incidence of UI delays, however, the legacy APIs are still supported, albeit with some caveats.

How to repeat:
Repro is unknown, this bug was detected via automated diagnostics.

Suggested fix:
To improve UI thread responsiveness of tooltips, I'd like to request that MySql's VS extension switch to using the non-UI-thread affinitized async quick info API, per the example here: https://github.com/microsoft/vs-editor-api/tree/master/samples
[17 Dec 2019 17:12] MySQL Verification Team
Thank you for the bug report and suggestion fix.
[7 Apr 2020 13:04] Reggie Burnett
Thank you for the bug report and suggestion. Sounds like the right approach.  I'll discuss with the team responsible and see when we can get this implemented.

Thanks!
[19 Jan 2021 5:55] David Kean
Hey folks, I'm from the Visual Studio performance team from Microsoft.

This is the 12th worst UI delay across all Visual Studio sessions by severity. 25% of folks that hit this will see Visual Studio become unresponsive for at minimum 3.5 seconds, but sometimes up to 20 seconds. This has resulted in over 10,700 missed mouse & keyboard events* just in the past 28 days. 

The APIs that this code path is calling have been deprecated and will likely be removed in a future version of Visual Studio. Moving over the asynchronous APIs will have a great impact on the user experience that your customers have with your extension and will future proof your extension for releases to come.

* This is where the user click or type something in Visual Studio and it was not responding because of this delay.
[21 Jan 2021 0:18] Jose Ramirez
Hello David,

thank you for the additional info. This is Jose Ramirez from the Oracle team
and I've recently started reviewing this bug.

I've been able to validate that the
MySqlQuickInfoController.OnTextViewMouseHover method is being called on
multiple occasions when using a text editor (coding on source files from a
proyect) and/or clicking/right clicking on elements in the UI (e.g. Solution
Explorer items and right clicking on the text editor). Having said that, I'm
not seeing any long-standing delays.

Is there a specific use-case in which you are able to consistently reproduce
the long-standing delay that will help to ensure that the changes that I will
be making actually fix the issue?

Thank you.
[21 Jan 2021 0:54] David Kean
Unfortunately, I don't have a repro, we have just gathered this from our telemetry data that shows these delays in real world usage. The long running isn't showing up in the data, so I can't tell you whereabouts the slowness is.

Regardless, moving the async API called out by Christian will avoid needing to block the UI thread to calculate the data to show in Quick Info.
[1 Feb 2021 1:38] Jose Ramirez
I see, thank you for the additional input. We'll proceed to upgrade to the Async Quick Info API nonetheless.

Having said that, if we were to provide a package containing the fix, would it be possible for your team to assist us with running your tests against said package? If that is not possible, is there some setup that you can kindly provide/recommend that we could implement on our side to run similar tests?

Thank you.
[11 Feb 2021 16:36] Jose Ramirez
Hello David/Christian
Is there any input you can kindly provide regarding my last comment?

Thank you.
[13 Feb 2021 1:57] Christian Gunderman
The bug has no known consistent repro with the existing MySql Extension codebase. We know of it from automated ETW trace collection instrumentation which has reported these UI delays as frequently occurring for customers.

You can potentially simulate the UI delay by adding a Thread.Sleep() call within IAsyncQuickInfoSource.GetQuickInfoItemAsync(). In the obsolete, IQuickInfoSource variant of this API, the call is made on the UI thread, and would cause a UI delay. The new async API is called from a background thread, however, and should not cause a UI delay in any case.
[26 Mar 2021 21:41] Christine Cole
Fixed as of the upcoming MySQL for Visual Studio 1.2.10 release, and here's the proposed changelog entry from the documentation team:

The performance associated with showing tooltips in MySQL for Visual
Studio now is enhanced by switching to (async) Quick Info for UI thread
affinity.

Thank you for the bug report.
[2 Jun 2021 17:15] Christian Gunderman
Hello, thank you for taking action on this issue. It looks like 1.2.10 is not yet released. Is there an ETA for its eventual release? VS team is tracking this UI delay as a high impact responsiveness issue.