Skip to content
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

(ToolTip ) System.ArgumentNullException: Value cannot be null. (Parameter 'element') #6319

Closed
hhu-mahmoud opened this issue Mar 28, 2022 · 56 comments
Assignees
Labels
area-Tooltip Bug Product bug (most likely)

Comments

@hhu-mahmoud
Copy link

hhu-mahmoud commented Mar 28, 2022

  • .NET Core Version: 6.0.3
  • Windows version: Win10
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Repros on .NET 4.8.1 only.
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)?: No

Problem description:
App Crash .. the Problem should be resolved but it comes again and again.

BTW: I don't use any Tooltip in my App, regardless the problem come again and again during the working!

Actual behavior:

Application: Project.exe
CoreCLR Version: 6.0.322.12309
.NET Version: 6.0.3
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException: Value cannot be null. (Parameter 'element')
at System.Windows.Controls.ToolTipService.GetBetweenShowDelay(DependencyObject element)
at System.Windows.Controls.PopupControlService.CloseToolTip(ToolTip tooltip)
at System.Windows.Controls.PopupControlService.OnPostProcessInput(Object sender, ProcessInputEventArgs e)
at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(Tuple`2 postProcessInput, ProcessInputEventArgs processInputEventArgs)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.MouseDevice.Synchronize()
at System.Windows.Input.MouseDevice.ChangeMouseCapture(IInputElement mouseCapture, IMouseInputProvider providerCapture, CaptureMode captureMode, Int32 timestamp)
at System.Windows.Input.MouseDevice.Capture(IInputElement element, CaptureMode captureMode)
at CefSharp.Wpf.ChromiumWebBrowser.OnMouseDown(MouseButtonEventArgs e) in C:\projects\cefsharp\CefSharp.Wpf\ChromiumWebBrowser.cs:line 2239
at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at Application.Desktop.App.Main()

Expected behavior:
App should not be crashed

How could i solve the Problem fastly ?

@Symbai
Copy link
Contributor

Symbai commented Mar 28, 2022

Can you try running it on 6.0.2? There is a known issue introduced with 6.0.3 related to Popupcontrolservice

@hhu-mahmoud
Copy link
Author

Can you try running it on 6.0.2? There is a known issue introduced with 6.0.3 related to Popupcontrolservice

@Symbai it was also on 6.0.2. I wait for the Update of 6.0.3 but it still exist !! I need a workaround until they solve this problem.

@amaitland
Copy link

The problem was introduced in #4623

int betweenShowDelay = ToolTipService.GetBetweenShowDelay(owner);

A simple fix would look something like

 int betweenShowDelay = owner == null ? 0 : ToolTipService.GetBetweenShowDelay(owner);

The GetOwner method potentially returns null with other references performing null checks.

@SamBent
Copy link
Contributor

SamBent commented Mar 30, 2022

@hhu-mahmoud - Your app clearly is using tooltips, otherwise it wouldn't reach this codepath. The tooltips probably belong to built-in controls or to 3rd party controls that your app uses, so your app doesn't declare them directly.

The diagnosis and proposed fix from @amaitland doesn't go deep enough. A codepath that reaches that far into CloseToolTip should have owner != null; this is true in all our tests and in every example we've seen. So your app (or probably the 3rd party control) is doing something unusual while opening or closing the tooltip. We need to understand what that is, to avoid other problems that might be lying behind this crash.

Please attach (or link) a sample app that repros the crash. (If it relies on 3rd party controls, include those as well - we need to be able to run your app and debug the behavior that leads to the crash.) If that's not feasible, a time-travel trace of the crash is the next best thing.

@SamBent SamBent added the needs more information Not enough information has been provided. Please share more detail as requested label Mar 30, 2022
@amaitland
Copy link

@SamBent Thanks for the prompt reply 👍

What steps will reproduce the problem?

Please provide detailed information here, enough for someone else to reproduce your problem.
It's hard to reproduce the problem. It comes during the working

As per cefsharp/CefSharp#4048 (comment) The bug report completed by @hhu-mahmoud doesn't provide a reproduction unfortunately.

So your app (or probably the 3rd party control) is doing something unusual while opening or closing the tooltip.

The code in question is part of CefSharp.

A DispatcherTimer is used to delay showing the tooltip to better mimic the behaviour of chromium.

The same code works in every version of WPF prior to 6.

The diagnosis and proposed fix from @amaitland doesn't go deep enough.

No argument there, only have the stack trace to go by. It's not clear how owner is actually null, just that it is.

Please attach (or link) a sample app that repros the crash. (If it relies on 3rd party controls, include those as well - we need to be able to run your app and debug the behavior that leads to the crash.) If that's not feasible, a time-travel trace of the crash is the next best thing.

I'll defer to @hhu-mahmoud here as I've yet to reproduce the issue myself.

@hhu-mahmoud
Copy link
Author

@SamBent Thanks for reply.

@amaitland has said all information, what i have.

Actually i become everyday reports from employees, that the app crashed between 2 until 14 times per day with 8 Hours work. I tried to reproduce the problem on the developing machine but no thing happend and everything works fine. At the client PCs i copied the error as StackTrace from "Windows Events" and I posted it here.

I have downgraged the App to .Net5 and everything works since 2 days fine and perfect and no one reported this problem. I asked the employees also and they are too happy with .Net5 because it makes no problems!!

I did not changed anything in the code just downgraded to .Net5 with exactly the same code.

I use 3rd party controls such as MahApps and CefSharp. I removed the MahApps but i still have the same error with ToolTip.

I don't use any ToolTip only the Standard ToolTips (Minimize, Maximize, Close) and this one:

grafik

and it works fine with .Net5 and .Net6 this tooltip:

grafik

I use CefSharp as Browser and inside it should run a Website (Web Application) and this website has many tooltips inside it but it's a Website and it comes from outside and runs into a browser, regardless i have never had a problem with it, only with .Net6 and during the work in this Website the app crashs. It seems. that the app makes no problem, if i just start the app without working on the Website in the browser inside it (if the app in idle mode). i can also post another stack trace from Windows Events, where the CefSharp is not menthioned

Application: Project.exe CoreCLR
Version: 6.0.322.12309
.NET Version: 6.0.3
Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentNullException: Value cannot be null. (Parameter 'element') at System.Windows.Controls.ToolTipService.GetBetweenShowDelay(DependencyObject element) at System.Windows.Controls.PopupControlService.CloseToolTip(ToolTip tooltip) at System.Windows.Controls.PopupControlService.OnPostProcessInput(Object sender, ProcessInputEventArgs e) at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(Tuple`2 postProcessInput, ProcessInputEventArgs processInputEventArgs) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run() at Application.Desktop.App.Main()

I'm trying since 1 Hour to reproduce the errory myself but it too hard, because i don't work on the web application inside the app just trying to do some clicks

@SamBent
Copy link
Contributor

SamBent commented Mar 31, 2022

To summarize what we know (or suspect):

  • (suspect) The crash involves tooltips belonging to the CefSharp browser control, on behalf of the web content it displays
  • (suspect) There is a race condition that leads to the crash. "app crashed between 2 until 14 times per day"
  • (know) CefSharp manages its tooltips in a non-standard way. @amaitland showed us code that manipulates tooltips directly, instead of setting ToolTipService properties and letting WPF manipulate the tooltips accordingly.
  • (know) You can't turn off WPF's logic completely. WPF will respond to user actions by manipulating tooltips, for example if you move the mouse away from a control, WPF will try to close its tooltip. That's what's happening in the callstacks. (To be precise, the callstacks definitely show WPF trying to close a tooltip because of a user gesture, but they don't say which gesture. Moving the mouse away is the most common reason, but it could be others: deactivating the app (Alt-Tab), clicking the mouse, typing, etc.)
  • (suspect) The alleged race condition is between CefSharp's logic and WPF's. In the example, CefSharp's direct manipulation has somehow broken WPF's assumption "owner != null".

To fix the bug correctly, we need to discover how CefSharp's logic interacts with WPF's, which of WPF's assumptions are not justified in light of CefSharp's direct manipulation, and what to do when they don't hold. To that end:

@hhu-mahmoud Can you get more information from your users? Specifically

  • any patterns they have observed. Does the crash always involve a particular tooltip, or a particular type of tooltip (e.g. "content is image", or "show-duration is > 10 seconds"? Does it involve a particular gesture, or combination of gestures? Best of all would be specific steps that crash reliably (or with high probablity).
  • a time-travel trace of the crash

@amaitland Can you provide

  • a time-travel trace of the correct (non-crashing) behavior of opening and closing a CefSharp tooltip.
  • pointers to all the tooltip code in CefSharp (in case the list you already shared isn't everything)
  • even better, an app that contains CefSharp's tooltip logic, but nothing else. I.e. no web functionality, just a couple of buttons whose tooltips are managed with your logic.

Besides fixing the bug, I want to add test coverage of the "direct manipulation" scenario, to prevent future regressions. CefSharp isn't doing anything wrong AFAIK, but we're not testing what it does do.

@znakeeye
Copy link

znakeeye commented Apr 5, 2022

This has nothing to do with CefSharp. It's a bug introduced in .NET 6. We have it in our pure WPF project too.

@hhu-mahmoud
Copy link
Author

This has nothing to do with CefSharp. It's a bug introduced in .NET 6. We have it in our pure WPF project too.

@znakeeye do have a way to reproduce the exception? it comes by us randomly during the working and we did not find a way to reproduce it with certain steps!

@ghost
Copy link

ghost commented Apr 6, 2022

@SamBent
We are also facing this issue. We upgraded recently to 6.0.x, We are constantly facing app crash. This issue occurs when tool tip is invoked as soon as xaml is loaded. This happens for wpf controls not any third party.

CurrentDomain FirstChanceException
Message: Value cannot be null. (Parameter 'element') Type: System.ArgumentNullException
at System.Environment.get_StackTrace()
at ApplicationName.App.CurrentDomain_FirstChanceException(Object sender, FirstChanceExceptionEventArgs e) in App.xaml.cs:line 128
at System.Windows.Controls.ToolTipService.GetBetweenShowDelay(DependencyObject element)
at System.Windows.Controls.PopupControlService.CloseToolTip(ToolTip tooltip)
at System.Windows.Controls.PopupControlService.PromotePendingToolTipToCurrent(TriggerAction triggerAction)
at System.Windows.Controls.PopupControlService.<>c__DisplayClass9_0.b__0(Object s, EventArgs e)
at System.Windows.Threading.DispatcherTimer.FireTick()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at ApplicationName.App.Main()

@SamBent
Copy link
Contributor

SamBent commented Apr 6, 2022

@kvijay22 - please attach a sample app, with precise steps to repro the crash. Including exactly what you mean by "tool tip is invoked as soon as xaml is loaded".

We tried an app containing <Button ToolTip="my tooltip"/> and hovering the mouse over the button as soon as the xaml is loaded. That doesn't crash.

@znakeeye
Copy link

znakeeye commented Apr 6, 2022

No sample project needed. The exact commit is highlighted above - with a 100% valid fix. Please just push it now, and release 6.0.4 asap.

@batzen
Copy link
Contributor

batzen commented Apr 7, 2022

@znakeeye I strongly disagree that there is no repro needed as there seems to be a usage scenario neither the WPF team nor the tests are aware of. A repro is quite important to prevent issues in the future.
I strongly agree that this should be fixed as soon as possible. But without a repro the fix might be incomplete.

@znakeeye
Copy link

znakeeye commented Apr 7, 2022

@znakeeye I strongly disagree that there is no repro needed as there seems to be a usage scenario neither the WPF team nor the tests are aware of. A repro is quite important to prevent issues in the future. I strongly agree that this should be fixed as soon as possible. But without a repro the fix might be incomplete.

Usually, I would agree. This time, however, my experience tells me otherwise.

  • Nobody will manage to create a repro project. It's a complex timing issue that occurs intermittently in rather complex scenarios. E.g. virtualization, recycling, data templates, ContentControls, style triggers etc. Hovering different items...
  • A null-check in 6.0.3 would have given us some time to breathe.

Root cause
Anyway, the real bug can be found at PopupControlService.cs(478). There you have it. A memory leak which explains why CloseToolTip() is intermittently called for non-owned dangling objects.

CurrentToolTipTimer.Tick += new EventHandler(OnShowDurationTimerExpired);

On all places where CurrentToolTipTimer is re-assigned, you must remove that Tick handler. I suppose this memory leak could break tooltips in other ways too.

@hhu-mahmoud
Copy link
Author

@SamBent unfortunately the problem still with the new .Net Version 6.0.4 and nothing is getting better.
We have been downgraded the system to .Net 5, because it's stable and after every update for .Net we let one employee to test .Net 6 until the app crashs. This time the app crashes after about 3 Hours without intensive working!!

-- if A null-check can give us something to breathe and it could solve the problem! So where the problem of making a Null-Check ?

The problem is not new and it dosen't solve until today and the .Net 5 is not the solution for this problem, because we will be not uptodate! Unfortunately we are thinking now to stop using WPF and stay by Winforms and ASP.

I don't know, how it will be with .Net 7. I hope that, they do not have like this problem.


Anyway here is the result of the exception and we hope to find the solution in .Net 6.0.5!!:

XML:

1026 2 0 0x80000000000000 45525 Application PC1388 Application: Project.exe CoreCLR Version: 6.0.422.16404 .NET Version: 6.0.4 Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentNullException: Value cannot be null. (Parameter 'element') at System.Windows.Controls.ToolTipService.GetBetweenShowDelay(DependencyObject element) at System.Windows.Controls.PopupControlService.CloseToolTip(ToolTip tooltip) at System.Windows.Controls.PopupControlService.OnPostProcessInput(Object sender, ProcessInputEventArgs e) at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(Tuple`2 postProcessInput, ProcessInputEventArgs processInputEventArgs) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.MouseDevice.Synchronize() at System.Windows.Input.MouseDevice.ChangeMouseCapture(IInputElement mouseCapture, IMouseInputProvider providerCapture, CaptureMode captureMode, Int32 timestamp) at System.Windows.Input.MouseDevice.Capture(IInputElement element, CaptureMode captureMode) at CefSharp.Wpf.ChromiumWebBrowser.OnMouseDown(MouseButtonEventArgs e) in C:\projects\cefsharp\CefSharp.Wpf\ChromiumWebBrowser.cs:line 2239 at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run() at Application.Desktop.App.Main()

Exception:

Application: Project.exe
CoreCLR Version: 6.0.422.16404
.NET Version: 6.0.4
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException: Value cannot be null. (Parameter 'element')
at System.Windows.Controls.ToolTipService.GetBetweenShowDelay(DependencyObject element)
at System.Windows.Controls.PopupControlService.CloseToolTip(ToolTip tooltip)
at System.Windows.Controls.PopupControlService.OnPostProcessInput(Object sender, ProcessInputEventArgs e)
at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(Tuple`2 postProcessInput, ProcessInputEventArgs processInputEventArgs)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.MouseDevice.Synchronize()
at System.Windows.Input.MouseDevice.ChangeMouseCapture(IInputElement mouseCapture, IMouseInputProvider providerCapture, CaptureMode captureMode, Int32 timestamp)
at System.Windows.Input.MouseDevice.Capture(IInputElement element, CaptureMode captureMode)
at CefSharp.Wpf.ChromiumWebBrowser.OnMouseDown(MouseButtonEventArgs e) in C:\projects\cefsharp\CefSharp.Wpf\ChromiumWebBrowser.cs:line 2239
at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at Application.Desktop.App.Main()


XML

1000 2 100 0x80000000000000 45526 Application PC1388 BibliothekSystem.exe 1.0.0.0 61e1d8d9 KERNELBASE.dll 10.0.17763.2803 bfcd0c87 e0434352 0000000000039319 2094 01d8589e2484668b C:\Program Files\Project\Project.exe C:\Windows\System32\KERNELBASE.dll 108bbd7d-0ede-41d2-a40f-55b762a52ac3

Exception

Name der fehlerhaften Anwendung: Project.exe, Version: 1.0.0.0, Zeitstempel: 0x61e1d8d9
Name des fehlerhaften Moduls: KERNELBASE.dll, Version: 10.0.17763.2803, Zeitstempel: 0xbfcd0c87
Ausnahmecode: 0xe0434352
Fehleroffset: 0x0000000000039319
ID des fehlerhaften Prozesses: 0x2094
Startzeit der fehlerhaften Anwendung: 0x01d8589e2484668b
Pfad der fehlerhaften Anwendung: C:\Program Files\Project\Project.exe
Pfad des fehlerhaften Moduls: C:\Windows\System32\KERNELBASE.dll
Berichtskennung: 108bbd7d-0ede-41d2-a40f-55b762a52ac3
Vollständiger Name des fehlerhaften Pakets:
Anwendungs-ID, die relativ zum fehlerhaften Paket ist:

@znakeeye
Copy link

-- if A null-check can give us something to breathe and it could solve the problem! So where the problem of making a Null-Check ?

A null-check would indeed allow your app to run for more than 3 hours. But instead you would end up with even more leaked timers, causing an overall performance degradation. Your app would stop working at some point.

As I see it, we have three viable options:

  1. Run .NET 5 until Microsoft fixes this.
  2. Create a PR with a fix. That means fixing the memory leak. Not just a null-check!
  3. Use a workaround. (Working on it.)

@znakeeye
Copy link

@hhu-mahmoud Can you please check if your app runs under 100% DPI setting when the crash occurs?

Tooltips are still broken in .NET 6.0.4 when running with higher System DPI. E.g. 150%.

@SamBent
Copy link
Contributor

SamBent commented Apr 28, 2022

@hhu-mahmoud @kvijay22 et al. - please provide a repro. If that's not possible, provide a time-travel trace of the crashing scenario. (It seems to involve opening a tooltip while another tooltip is already open, so be sure the trace includes opening the earlier tooltip.)

I don't doubt that there's a bug here. But we need the repro (or trace) to understand how to fix the full scenario. Adding a null check may not address deeper issues, but instead will make them much harder to find and fix.

@znakeeye - what's leaking? The code you cite only adds references to the new EventHandler and to the PopupControlService itself. Both references go away when the timer is cleared in ResetCurrentToolTipTimer, which is called in many places including when the tooltip closes. There's no leak, at least not when the tooltips are opened and closed in the standard ways.

@EamonHetherton
Copy link

I have been able to reliably reproduce the problem in my application now, though the application is quite large so I'm trying to reduce it to a simple demo application (not as simple as I had hoped).

Essentially, the full application does background updates that can affect the layout on the screen (e.g. ItemsControl bound to an ObservableCollection<> of view models that change.

If I have the tooltip showing for one of the records when the update happens and that record is removed, I get the error every time. I'll try to produce a reproduction application and submit.

@EamonHetherton
Copy link

Unfortunately I've not been able to reproduce the problem in a simple application but I've also discovered that in my actual application the issue is no longer reproducible after runtime 6.0.3. Our current release is targeting 6.0.1 and I am able to trigger the issue on 6.0.1 and 6.0.2, but 6.0.3, 6.0.4 and 6.0.5 all appear to have the issue solved in my case at least.

@pchaurasia14
Copy link
Member

@hhu-mahmoud - Are you seeing this issue with 6.0.5 as well ?

@hhu-mahmoud
Copy link
Author

@pchaurasia14 - We are still using .Net5 but i will tell one from the employee to make a test again.
I updated now all packages in the project and also the .Net 6 version for the employees PCs to .Net 6.0.5 . As soon as I get the result, then i will post it here.

@jaapversloot
Copy link

We encounter the same issue as described by @fresche-gavin.

Setup:

  • Windows 10
  • .net 6.0.8
  • CefSharp.Wpf.NETCroe 96.0.180

What seems to help is to remove the title attribute from all the buttons etc.

@czdietrich
Copy link

We encounter the same issue even without using CefSharp. While we were also using CefSharp to show web content, we switched to WebView2 some time ago and still see this issue.

In our case the application is mixed WinForms / WPF and the crashes are not necessarily related to showing web content.

Setup: Windows 10, .NET 6.0.8

@mol
Copy link

mol commented Nov 22, 2022

We're using CefSharp and seeing it about 600 times a day for our users.

~95% are on Windows 11. I understand that a time-travel trace might help, so we'll try and get one. So far we've been unable to reproduce it internally.

@czdietrich
Copy link

If I understood correctly, they can already reproduce the issue and have a fix for it. But unfortunately, there is no new information since.

@dipeshmsft dipeshmsft assigned dipeshmsft and unassigned SamBent Dec 1, 2022
@dipeshmsft dipeshmsft removed the needs more information Not enough information has been provided. Please share more detail as requested label Dec 1, 2022
@hhu-mahmoud
Copy link
Author

We have since 4 days changed from .Net5 to .Net7 (Desktop Runtime Version 7.0.2) => Everything looks fine since 4 days and we have no problems until now!

@czdietrich
Copy link

I am uncertain that it is actually fixed in .NET 7, since the related PR is sill open.
But I can tell that the tooltip issue still exists in the latest version of .NET 6 (6.0.13), which is LTS and therefore needs to be fixed finally.

@werksarztzentrum
Copy link

We need also a quick fix for .NET Framework 4.8, all our Windows 11 Users have this problem in WPF.

@amaitland
Copy link

For those seeing this issue in the context of CefSharp, there is a potential workaround available at cefsharp/CefSharp#4048 (comment)

@Lumoryel
Copy link

Lumoryel commented Mar 2, 2023

I can reproduce this exception in a .NET Framework 4.8 WPF Application.
I debugged and saw that PopupControlService.CloseToolTip is called.
This method is not existing in the reference source for .NET Framework 4.8, at least what I have found here:

https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Controls/PopupControlService.cs,595

Also the code here can not lead to this exception, because "o" is checked for null before.
Is this not the current .NET Framework 4.8 Source code?

It happens to me since I have a new computer with windows 11.
But it also happened to a colleague with windows 10 19045 (like my old computer, where the exception never showed up)

@znakeeye
Copy link

znakeeye commented Mar 2, 2023

I can reproduce this exception in a .NET Framework 4.8 WPF Application. I debugged and saw that PopupControlService.CloseToolTip is called. This method is not existing in the reference source for .NET Framework 4.8, at least what I have found here:

https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Controls/PopupControlService.cs,595

Also the code here can not lead to this exception, because "o" is checked for null before. Is this not the current .NET Framework 4.8 Source code?

It happens to me since I have a new computer with windows 11. But it also happened to a colleague with windows 10 19045 (like my old computer, where the exception never showed up)

You are probably running 4.8.1 even though you're targeting 4.8.

@Lumoryel
Copy link

Lumoryel commented Mar 2, 2023

Good point @znakeeye ! That's it thank you.

On my new computer:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Release = 533320 = 4.8.1

On my old computer:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Release = 528372 = 4.8

So https://referencesource.microsoft.com/ shows only 4.8 code.
Where can I find the 4.8.1 code ?

Maybe the main description of this issue should state that it also happens in 4.8, if 4.8.1 is installed?

@gavinr99
Copy link

gavinr99 commented Mar 2, 2023

@Lumoryel @znakeeye Yes, as previously mentioned, we could not replicate it in .Net 4.8, but can replicate it in .Net 4.8.1 (both on Windows 10).

For the time being, one of our devs (@cmunforte) found a workaround fix mentioned here: cefsharp/CefSharp#4048 (comment) (assuming you are using CefSharp)

@Lumoryel
Copy link

Lumoryel commented Mar 3, 2023

@Lumoryel @znakeeye Yes, as previously mentioned, we could not replicate it in .Net 4.8, but can replicate it in .Net 4.8.1 (both on Windows 10).

It would have helped me a lot if this behavior is written in the original bug description ("it can happen in .net 4.8, if 4.8.1 is installed" or similar). Because this is a behavior I didn't expect at all and is very hard to find out!
I thought there are different dlls loaded for each .net framework version.

For the time being, one of our devs (@cmunforte) found a workaround fix mentioned here: cefsharp/CefSharp#4048 (comment) (assuming you are using CefSharp)

Thanks a lot, I tried this on my WFP element which has a tooltip and the exception is gone:
myBorder.ToolTipOpening += (s, e) => e.Handled = true

@dipeshmsft
Copy link
Member

@czdietrich @hhu-mahmoud @znakeeye can you verify if the latest release ( 7.0.5 / 6.0.16 ) resolves issues in your applications ?

@hhu-mahmoud
Copy link
Author

@dipeshmsft since the Update 7.0.2 and now 7.0.5 I have received no complaint from the employees. Everything works fine.

I don't know about .Net6, cus we already updated to .Net7 since few months.

@dipeshmsft
Copy link
Member

Thanks @hhu-mahmoud for the confirmation. Closing this issue now.

@Lumoryel
Copy link

Please consider that "Does the bug reproduce also in WPF for .NET Framework 4.8?: No" is not really correct.
It happens on Windows 11 with a .NET Framework 4.8 targeted program. Is it possible to change that on the initial post?

@dipeshmsft
Copy link
Member

dipeshmsft commented Apr 24, 2023

@Lumoryel, this fix has been included in .NET Framework 4.8.1 as well. Is that what you were asking here? Updated the initial post as well.

@Lumoryel
Copy link

@dipeshmsft The fact that 4.8.1 code is running although target is 4.8 (but only on windows 11) confused me alot. If this would be stated somehow in the first post, would have helped me alot.

@ghost ghost locked as resolved and limited conversation to collaborators May 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tooltip Bug Product bug (most likely)
Projects
None yet
Development

No branches or pull requests