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

In WPF, calling dispose in WebView2 component from ProcessFailed event context will raise an exception #996

Closed
neidantaslopez opened this issue Feb 26, 2021 · 7 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@neidantaslopez
Copy link

neidantaslopez commented Feb 26, 2021

Description
In WPF, calling dispose in WebView2 object from ProcessFailed event context will raise the following exception:

Message = "The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)"

StackTrace = " at Microsoft.Web.WebView2.Core.Raw.ICoreWebView2.remove_ContentLoading(EventRegistrationToken token)\r\n at Microsoft.Web.WebView2.Core.CoreWebView2.remove_ContentLoading(EventHandler`1 value) in D:\a\1\s\third_party\edge_webview2\win\webview2_api_writer\dotNetAPIWrapper\Microsoft.Web.WebView2.Core\obj\PrereleasePackage\Generated.cs:line 5324\r\n at Microsoft.Web.WebView2.Wpf.WebView2.Dispose(Boolean disposing)\r\n at System.Windows.Interop.HwndHost.Dispose()\r\n at WpfAppWebView2Dispose.MainWindow.CoreWebView2_ProcessFailed(Object sender, CoreWebView2ProcessFailedEventArgs e) in C:\r\WpfAppWebView2Dispose\MainWindow.xaml.cs:line 52"

Version
SDK: either 1.0.790-prerelease or 1.0.705.50 reproduce the same issue
Runtime: either Evergreen WebView2 Runtime 88.0.705.81 or Fixed Version WebView2 Runtime 88.0.705.81 reproduce the same issue
Framework: WPF, .NET Framework 4.6.2
OS: either Win10 or Win7 reproduce the same issue

Repro Steps

  1. Execute WpfAppWebView2Dispose.zip;
  2. Observe that by hitting the button "Dispose" (which call Dispose outside ProcessFailed event context), it works fine...
  3. Now kill msedgewebview2.exe processes then observe the exception mentioned will be raised. This is in order to simulate when process ends unexpectedly or becomes unresponsive;

image

By the references bellow, I understand the behavior mentioned above is incorrect (Dispose should work fine and no exception should be raised):

#774 (comment)
#799
https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1065#dispose-methods

AB#31870655

@neidantaslopez neidantaslopez added the bug Something isn't working label Feb 26, 2021
@johna-ms
Copy link
Contributor

Hey there's a fix in the works for this issue but it's taking longer than expected to turn around. Thank you for the repro app because when we tried calling Dispose in ProcessFailed ourselves, there were no issues. I'll be investigating your app and get back to you soon.

@champnic champnic added the tracked We are tracking this work internally. label Feb 26, 2021
@johna-ms
Copy link
Contributor

Hey @neidantaslopez just tried out your app and it indeed repros on 88.0.705.81 but I found it's fixed in 90.0.803.0 which is the current Edge Dev version. Could you please see if running a newer runtime fixes your scenario? You can have your app favor loading Edge Dev or Canary by setting the environment variable with this command: Environment.SetEnvironmentVariable("WEBVIEW2_RELEASE_CHANNEL_PREFERENCE", "1");

@neidantaslopez
Copy link
Author

@johna-ms it worked on Canary 90.0.803.0. When could we expect the fix to be on Evergreen WebView2 Runtime and Fixed Version WebView2 Runtime?

@johna-ms
Copy link
Contributor

johna-ms commented Mar 1, 2021

Good news, the fix should be in the latest of both runtimes in just a couple days on 3/4 :)

Please update here if that's not the case!

@orrindeng
Copy link

Thanks for your good work.
I'm using runtime 89.0.774.45 and SDK 1.0.790-prerelease. It's OK now.

@johna-ms
Copy link
Contributor

johna-ms commented Mar 9, 2021

Happy to help! Glad things are working. @neidantaslopez are things alright with you? Just want to confirm so I can close out this issue.

@neidantaslopez
Copy link
Author

Happy to help! Glad things are working. @neidantaslopez are things alright with you? Just want to confirm so I can close out this issue.

It's OK now. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

4 participants