prodot / ReCommended-Extension

Code analysis improvements and context actions
Apache License 2.0
59 stars 11 forks source link

CSharpIdentifierTooltipProvider.GetRichTooltip should not be called on the UI thread due to performance reasons #60

Closed sergeyQx closed 1 year ago

sergeyQx commented 1 year ago

See https://youtrack.jetbrains.com/issue/RSRP-491292/2023.1-EAP4-No-Intellisense-After-Unknown-Activity#focus=Comments-27-6867353.0-0

05:07:00.755 |E| CSharpIdentifierTooltipProvider| :1                 | Running on main thread can cause UI freeze

--- EXCEPTION #1/1 [LoggerException]
Message = “Running on main thread can cause UI freeze”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
Data.ManagedThreadName = <NULL>
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
  at JetBrains.Util.ILoggerEx.LogMessage(ILogger this, LoggingLevel level, String message) in LogMessage.il:line IL_002E mvid CF22
     at JetBrains.ReSharper.Daemon.CSharp.Stages.CSharpIdentifierTooltipProvider.AssertBackgroundThread() in AssertBackgroundThread.il:line IL_004C mvid BCCA
     at JetBrains.ReSharper.Daemon.CSharp.Stages.CSharpIdentifierTooltipProvider.GetRichTooltip(IHighlighter highlighter, HighlighterTooltipKind where) in GetRichTooltip.il:line IL_0006 mvid BCCA
     at GammaJul.ReSharper.EnhancedTooltip.VisualStudio.MainQuickInfoSource.<GetTooltipContents>d__2.MoveNext() in GetTooltipContents.il:line IL_00A8 mvid C2F3
     at GammaJul.ReSharper.EnhancedTooltip.VisualStudio.MainQuickInfoSource.<>c__DisplayClass0_0.<AugmentQuickInfoSessionCore>g__GetEnhancedTooltips|0() in MainQuickInfoSource.il:line IL_01A7 mvid C2F3
     at JetBrains.Threading.ReentrancyGuard.Execute(String name, Action action) in Execute.il:line IL_00ED mvid CF22
     at JetBrains.Threading.ReentrancyGuard.TryExecute(String name, Action action) in TryExecute.il:line IL_008F mvid CF22
     at GammaJul.ReSharper.EnhancedTooltip.VisualStudio.MainQuickInfoSource.AugmentQuickInfoSessionCore(IQuickInfoSession session, IList`1 quickInfoContent, IDocumentMarkup documentMarkup, TooltipFormattingProvider tooltipFormattingProvider, ITrackingSpan& applicableToSpan) in AugmentQuickInfoSessionCore.il:line IL_007E mvid C2F3
     at GammaJul.ReSharper.EnhancedTooltip.VisualStudio.QuickInfoSourceBase.AugmentQuickInfoSession(IQuickInfoSession session, IList`1 quickInfoContent, ITrackingSpan& applicableToSpan) in AugmentQuickInfoSession.il:line IL_0055 mvid C2F3
     at Microsoft.VisualStudio.Language.Intellisense.Implementation.LegacyQuickInfoSource.AugmentQuickInfoSession(IAsyncQuickInfoSession session, IList`1 content, ITrackingSpan& applicableToSpan) in AugmentQuickInfoSession.il:line IL_0059 mvid F2B6
     at Microsoft.VisualStudio.Language.Intellisense.Implementation.AsyncQuickInfoSession.<TryComputeContentFromLegacySourceAsync>d__48.MoveNext() in TryComputeContentFromLegacySourceAsync.il:line IL_00B7 mvid F2B6
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in RunInternal.il:line IL_0079 mvid 861E
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in Run.il:line IL_0009 mvid 861E
     at System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() in Run.il:line IL_0024 mvid 861E
     at Microsoft.VisualStudio.Threading.JoinableTaskFactory.SingleExecuteProtector.TryExecute() in TryExecute.il:line IL_0032 mvid 146C
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) in InternalRealCall.il:line IL_0077 mvid 4C1C or InternalRealCall.il:line IL_008E mvid 4C1C
     at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) in TryCatchWhen.il:line IL_0002 mvid 4C1C
     at System.Windows.Threading.DispatcherOperation.InvokeImpl() in InvokeImpl.il:line IL_007A mvid 4C1C
     at System.Windows.Threading.DispatcherOperation.Invoke() in Invoke.il:line IL_0034 mvid 4C1C
     at System.Windows.Threading.Dispatcher.ProcessQueue() in ProcessQueue.il:line IL_00F6 mvid 4C1C
     at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) in WndProcHook.il:line IL_0090 mvid 4C1C
     at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) in WndProc.il:line IL_0030 mvid 4C1C
     at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) in DispatcherCallbackOperation.il:line IL_0036 mvid 4C1C
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) in InternalRealCall.il:line IL_0077 mvid 4C1C or InternalRealCall.il:line IL_008E mvid 4C1C
     at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) in TryCatchWhen.il:line IL_0002 mvid 4C1C
     at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) in LegacyInvokeImpl.il:line IL_00BB mvid 4C1C
     at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) in SubclassWndProc.il:line IL_0130 mvid 4C1C
”
michael-damatov commented 1 year ago

Thanks for reporting the issue. Unfortunately, the stack trace does provide any insights to improve my R# extension. The ReCommended Extension for ReSharper doesn't use any tool tips directly, it only provides suggestions and warnings, which are picked up and displayed by the R# infrastructure.

sergeyQx commented 1 year ago

Ooops, sorry. I have reported the issue to a wrong plugin.