You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We intercept the NewWindowRequested event and show a window with tabs. If you open a new tab (by middle-clicking a link in the first tab, say), and then quickly close the tab you're on, the app hardcrashes.
It seems that assigning e.NewWindow = newWebView.CoreWebView2 when the requesting tab/webview2 is disposed of leads to this crash
If I dispose of the first webview2 immediately in the NewWindowRequestedHandler, I get this crash:
If I dispose of it in a Task (which is more like what's happening in my app), I get this crash:
Generally, in my app (though didn't repro in the minimal example yet), I'd get this crash:
(oh I think that's the same issue as above just hitting in WebView2 code this time)
It would be nice if WebView2 handled this case for us.
What I'm having to do is grab the sender passed to NewWindowRequestedHandler and right before assigning the new WebView2 that I created to NewWindow, I check if the sender webview2 is disposed. (and also having to close the new tab that was opened to avoid a blank new tab)
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
131.0.2903.70
SDK Version
1.0.2783-prerelease and 1.0.2535.41
Framework
Winforms
Operating System
Windows 11
OS Version
23H@ 22631.4460
Repro steps
download WinForms sample app from webview2
In WebView2Control_CoreWebView2InitializationCompleted, add this.webView2Control.CoreWebView2.NewWindowRequested += (sender, e) => CoreWebView2_NewWindowRequested(sender, e, false);
and below:
WebView2 _primaryWebView = null;
private async void CoreWebView2_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEventArgs e, bool fromOtherWebView)
{
e.Handled = true;
using (e.GetDeferral())
{
Form form = new Form();
form.Size = new Size(800, 600);
WebView2 webView = new WebView2();
await webView.EnsureCoreWebView2Async();
webView.CoreWebView2.NewWindowRequested += (sender, e) => CoreWebView2_NewWindowRequested(sender, e, true);
form.Controls.Add(webView);
form.Visible = true;
webView.Dock = DockStyle.Fill;
if (fromOtherWebView)
{
await Task.Run(() =>
{
_primaryWebView.Dispose(); // dispose requesting window
});
}
else
{
// save off the first webview
_primaryWebView = webView;
}
e.NewWindow = webView.CoreWebView2;
}
}
then
start app
open devtools and run window.open("https://google.com")
in the Google window, middle click the About link to trigger a new window
observe crash
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered:
It seems that your issue contains the word "crash". If you have not already, could you attach a crash dump as a comment?
WV2 crash dumps are located in a subfolder of the app's user data folder (UDF): <UDF>\EBWebView\Crashpad\reports\. By default, the user data folder is created in the app's folder with a name like <App Exe Name>.exe.WebView2. Refer to Crash Diagnostics for more information.
Thank you for your cooperation!
pushkin-
changed the title
[Problem/Bug]: App hard-crashes if a webview opens another window and we assign NewWindow, but then the opening webview is disposed
[Problem/Bug]: App hard-crashes if the requesting webview is disposed around the time we assign the new webview to NewWindow
Dec 13, 2024
What happened?
We intercept the
NewWindowRequested
event and show a window with tabs. If you open a new tab (by middle-clicking a link in the first tab, say), and then quickly close the tab you're on, the app hardcrashes.It seems that assigning
e.NewWindow = newWebView.CoreWebView2
when the requesting tab/webview2 is disposed of leads to this crashIf I dispose of the first webview2 immediately in the NewWindowRequestedHandler, I get this crash:
If I dispose of it in a Task (which is more like what's happening in my app), I get this crash:
Generally, in my app (though didn't repro in the minimal example yet), I'd get this crash:
(oh I think that's the same issue as above just hitting in WebView2 code this time)
It would be nice if WebView2 handled this case for us.
What I'm having to do is grab the sender passed to
NewWindowRequestedHandler
and right before assigning the new WebView2 that I created toNewWindow
, I check if the sender webview2 is disposed. (and also having to close the new tab that was opened to avoid a blank new tab)Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
131.0.2903.70
SDK Version
1.0.2783-prerelease and 1.0.2535.41
Framework
Winforms
Operating System
Windows 11
OS Version
23H@ 22631.4460
Repro steps
WebView2Control_CoreWebView2InitializationCompleted
, addthis.webView2Control.CoreWebView2.NewWindowRequested += (sender, e) => CoreWebView2_NewWindowRequested(sender, e, false);
and below:
then
window.open("https://google.com")
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered: