-
Notifications
You must be signed in to change notification settings - Fork 54
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
Unhandled exception in Microsoft.Web.WebView2.Wpf.WebView2.Dispose #3752
Comments
@rozeboosje what is the WebView2 SDK version (the version of the nuget package got from https://www.nuget.org/packages/Microsoft.Web.WebView2)? I've created an internal tracking issue for this and see what we can repro/address it. |
The nuGet version is 10.0.22621.755 which I think is the current one? |
10.0.22621.755 is the Windows SDK version. WebView2 SDK version is something like 1.0.1938.49. |
Oops my bad.... I was looking at it cross eyed and ended up giving you the version for Microsoft.Windows.SDK.Contracts! Microsoft.Web.WebView2 is 1.0.1938.49 alright. |
Folks internal to Microsoft can find dumps for this issue in the following Watson buckets 1603193249604093317 |
Thanks for the Watson buckets. We will look into them. The call stack indicates that this is happening on finalizer worker thread and the WebView2 control has not been explicitly exposed before the finalizer. To mitigate the issue before we address the issue in WebView2 SDK, could you try to mitigate the issue by explicitly calling Dispose WebView2 controllers when we are done with them? |
I am not on the team that owns primary usage of the control in VS, but I have assigned the internal bug to them and linked this discussion. |
@LiangTheDev @ryanmolden I'm investigating from the VS control side of things. The stacks shown in those Watsons do not include some stack data we have from our partners that show this is happening as a result of us explicitly calling WebView2.Dispose. This happens when using the WPF version of WebView2, so no access to the CoreWebView2Controller class, just the control itself. The telemetry they collected only goes as far as our Dispose method that calls yours, but not actually into the WebView2 code itself. |
The stack in the first post shows that it is "System.Windows.Interop.HwndHost.Finalize()" that is calling Microsoft.Web.WebView2.Wpf.WebView2.Dispose, and it is consistent with the stack from Watson. From Watson stacks, there is a case where Dispose is explicitly called for WinForms WebView2 Controller. |
I got the same exception and I could only see the error information in Event Viewer, since my app crashed: In my case I use multiple WebView2 components for different purposes and views across C# and Delphi. Anyway I'm using the last nuget Version: 1.0.2903.40 |
As this happened once on a client machine, all I can give you is the error as it was logged in the Event Viewer:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidCastException
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(System.Object, IntPtr, IntPtr ByRef, Boolean ByRef)
at Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller.get_CoreWebView2()
at Microsoft.Web.WebView2.Core.CoreWebView2Controller.get_CoreWebView2()
at Microsoft.Web.WebView2.Wpf.WebView2.Uninitialize(Boolean)
at Microsoft.Web.WebView2.Wpf.WebView2.Dispose(Boolean)
at System.Windows.Interop.HwndHost.Finalize()
The next message in the event viewer then reads:
Faulting application name: our application here, time stamp: 0x64ef3c24
Faulting module name: KERNELBASE.dll, version: 6.3.9600.20772, time stamp: 0x639ac196
Exception code: 0xe0434352
Fault offset: 0x000000000000450c
Faulting process ID: 0x27938
Faulting application start time: 0x01d9dbe18e73726f
Faulting application path: path to our application
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report ID: 223dcf3a-47e4-11ee-84bb-40e2303bce86
Faulting package full name:
Faulting package-relative application ID:
Version
SDK: 10.0.22621.755
Runtime: 109.0.1518.115
Framework: .NET Framework 4.8, WPF
OS: Windows 8.1 Pro
Please note that I have Runtime 116.0.1938.62 on my own machine and I did notice an occasional error being raised during debugging but it never caused our application to crash so I never paid a lot of attention to it. Sorry. My own machine is Windows 11 22H2
Regression
Was this working before but has regressed? Unsure
If yes, what version did this last work on? Unsure
Repro Steps
Unsure. User stated the application just "crashed"
Not available
AB#46359270
The text was updated successfully, but these errors were encountered: