MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
447 stars 53 forks source link

Sudden shutdown when opening Ookii.Dialogs.Wpf.VistaSaveFileDialog from a WebMessageReceived event handler #2453

Closed zspitz closed 2 years ago

zspitz commented 2 years ago

Description
When opening an instance of Ookii.Dialogs.Wpf's VistaSaveFileDialog from within a handler on the CoreWebView2.WebMessageReceived` event, the application intermittently shuts down without any exception.

Version
SDK: NuGet package Microsoft.Web.WebView2 1.0.1210.39 Runtime: 101.0.1210.39 Framework: WPF OS: Win10 21H2 build 19044.1645

Repro Steps

  1. Insert a WebView2
  2. Add an event handler for the CoreWebView2.MessageReceived event.
  3. Within the handler, create and ShowDialog on a VistaSaveFileDialog instance.

Additional context

It feels as though there's a certain time period before the shutdown.

It only happens in Debug mode with VS attached; not in Release mode.

Cleaning the bin/obj folders and rebuilding the solution doesn't prevent this.

I've found there's a brief period of unresponsiveness before the shutdown.

Sample project:
testWebviewDialogs.zip

LogLog-lgtm commented 2 years ago

Ran into similar problem when launching dialogs inside of an event handler. Follow the examples on reentrancy

zspitz commented 2 years ago

@LogLog-lgtm Why only in Debug mode and not in Release mode?

zspitz commented 2 years ago

@LogLog-lgtm Also, is it safe to post messages back to the WebView2 using PostWebMessageAsString or PostWebMessageAsJson from within the synchronized callback?

zspitz commented 2 years ago

@LogLog-lgtm 's suggestion appears to have resolved the issue. Thanks.