Skip to content

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

Closed

Description

@hhu-mahmoud
  • .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 ?

Activity

  1. Symbai commented on Mar 28, 2022

    @Symbai
    Contributor

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

  2. hhu-mahmoud commented on Mar 28, 2022

    @hhu-mahmoud
    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.

  3. amaitland commented on Mar 28, 2022

    @amaitland

    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.

  4. added
    Bug
    and removed on Mar 30, 2022
  5. SamBent commented on Mar 30, 2022

    @SamBent
    Contributor

    @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.

  6. added
    needs more information
    on Mar 30, 2022
  7. amaitland commented on Mar 30, 2022

    @amaitland

    @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.

  8. hhu-mahmoud commented on Mar 31, 2022

    @hhu-mahmoud
    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

  9. SamBent commented on Mar 31, 2022

    @SamBent
    Contributor

    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.

  10. znakeeye commented on Apr 5, 2022

    @znakeeye

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

  11. 39 remaining items

  12. werksarztzentrum commented on Feb 10, 2023

    @werksarztzentrum

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

  13. amaitland commented on Feb 10, 2023

    @amaitland

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

  14. HenningOI commented on Mar 2, 2023

    @HenningOI

    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)

  15. znakeeye commented on Mar 2, 2023

    @znakeeye

    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.

  16. HenningOI commented on Mar 2, 2023

    @HenningOI

    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?

  17. gavinr99 commented on Mar 2, 2023

    @gavinr99

    @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)

  18. HenningOI commented on Mar 3, 2023

    @HenningOI

    @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

  19. dipeshmsft commented on Apr 18, 2023

    @dipeshmsft
    Member

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

  20. hhu-mahmoud commented on Apr 24, 2023

    @hhu-mahmoud
    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.

  21. dipeshmsft commented on Apr 24, 2023

    @dipeshmsft
    Member

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

  22. HenningOI commented on Apr 24, 2023

    @HenningOI

    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?

  23. dipeshmsft commented on Apr 24, 2023

    @dipeshmsft
    Member

    @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.

  24. HenningOI commented on Apr 24, 2023

    @HenningOI

    @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.

  25. ghost locked as resolved and limited conversation to collaborators on May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bugarea-Tooltip

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions