Repository navigation
Description
- .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
Symbai commentedon 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 commentedon Mar 28, 2022
@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 commentedon Mar 28, 2022
The problem was introduced in #4623
wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PopupControlService.cs
Line 602 in 869d4e0
A simple fix would look something like
The GetOwner method potentially returns null with other references performing null checks.
SamBent commentedon 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.
amaitland commentedon Mar 30, 2022
@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.
hhu-mahmoud commentedon Mar 31, 2022
@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
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 commentedon Mar 31, 2022
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.
znakeeye commentedon 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.39 remaining items
werksarztzentrum commentedon Feb 10, 2023
We need also a quick fix for .NET Framework 4.8, all our Windows 11 Users have this problem in WPF.
amaitland commentedon Feb 10, 2023
For those seeing this issue in the context of
CefSharp, there is a potential workaround available at cefsharp/CefSharp#4048 (comment)HenningOI commentedon 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 commentedon Mar 2, 2023
You are probably running
4.8.1even though you're targeting4.8.HenningOI commentedon 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.1On my old computer:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Release = 528372 = 4.8So 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 commentedon 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)
HenningOI commentedon Mar 3, 2023
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.
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 = truedipeshmsft commentedon Apr 18, 2023
@czdietrich @hhu-mahmoud @znakeeye can you verify if the latest release ( 7.0.5 / 6.0.16 ) resolves issues in your applications ?
hhu-mahmoud commentedon Apr 24, 2023
@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 commentedon Apr 24, 2023
Thanks @hhu-mahmoud for the confirmation. Closing this issue now.
HenningOI commentedon Apr 24, 2023
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 commentedon 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.
HenningOI commentedon Apr 24, 2023
@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.