-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Comments
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. |
The problem was introduced in #4623 Line 602 in 869d4e0
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. |
@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 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 Thanks for the prompt reply 👍
As per cefsharp/CefSharp#4048 (comment) The bug report completed by @hhu-mahmoud doesn't provide a reproduction unfortunately.
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.
No argument there, only have the stack trace to go by. It's not clear how owner is actually null, just that it is.
I'll defer to @hhu-mahmoud here as I've yet to reproduce the issue myself. |
@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: and it works fine with .Net5 and .Net6 this tooltip: 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 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 |
To summarize what we know (or suspect):
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
@amaitland Can you provide
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. |
This has nothing to do with |
@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! |
@SamBent CurrentDomain FirstChanceException |
@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 |
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. |
@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. |
Usually, I would agree. This time, however, my experience tells me otherwise.
Root cause CurrentToolTipTimer.Tick += new EventHandler(OnShowDurationTimerExpired); On all places where |
@SamBent unfortunately the problem still with the new .Net Version 6.0.4 and nothing is getting better. -- 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 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-55b762a52ac3Exception Name der fehlerhaften Anwendung: Project.exe, Version: 1.0.0.0, Zeitstempel: 0x61e1d8d9 |
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:
|
@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%. |
@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 |
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. |
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. |
@hhu-mahmoud - Are you seeing this issue with 6.0.5 as well ? |
@pchaurasia14 - We are still using .Net5 but i will tell one from the employee to make a test again. |
We encounter the same issue as described by @fresche-gavin. Setup:
What seems to help is to remove the title attribute from all the buttons etc. |
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 |
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. |
If I understood correctly, they can already reproduce the issue and have a fix for it. But unfortunately, there is no new information since. |
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! |
I am uncertain that it is actually fixed in .NET 7, since the related PR is sill open. |
We need also a quick fix for .NET Framework 4.8, all our Windows 11 Users have this problem in WPF. |
For those seeing this issue in the context of |
I can reproduce this exception in a .NET Framework 4.8 WPF Application. Also the code here can not lead to this exception, because "o" is checked for null before. It happens to me since I have a new computer with windows 11. |
You are probably running |
Good point @znakeeye ! That's it thank you. On my new computer: On my old computer: So https://referencesource.microsoft.com/ shows only 4.8 code. Maybe the main description of this issue should state that it also happens in 4.8, if 4.8.1 is installed? |
@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) |
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!
Thanks a lot, I tried this on my WFP element which has a tooltip and the exception is gone: |
@czdietrich @hhu-mahmoud @znakeeye can you verify if the latest release ( 7.0.5 / 6.0.16 ) resolves issues in your applications ? |
@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. |
Thanks @hhu-mahmoud for the confirmation. Closing this issue now. |
Please consider that "Does the bug reproduce also in WPF for .NET Framework 4.8?: No" is not really correct. |
@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. |
@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. |
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 ?
The text was updated successfully, but these errors were encountered: