Skip to content

[Problem/Bug]: CoreWebView2Controller.Close() sometimes hangs when disposing a windows forms webview2 browser control #4817

Open
@peh-87

Description

@peh-87

What happened?

We are using an instance of a WebView2 browser control within our application.
The Microsoft.Web.WebView2.WinForms.WebView2 control is embedded within a user control of our own.

When shutting down the application, it will sometimes hang within DestroyWindow, which is called within the EmbeddedBrowserWebView.dll triggered by CoreWebView2Controller.Close ().

The issue will only sometimes occur within our automated test system.

We already updated the sdk to the latest version and tried removing all event handlers from the webview2 control and the CoreWebView2 instance before calling dispose on the windows forms web view2 control. We also made sure that each instance of our software will use its own UserDataFolder, as we were experiencing other issues when sharing the UserDataFolder through multiple instances.

However the problem persists.

Is there anything else we can try or anything we can do to analyze this issue?

win32u.dll!NtUserDestroyWindow()	Unknown
EmbeddedBrowserWebView.dll!00007ff9f9d3a813()	Unknown
EmbeddedBrowserWebView.dll!00007ff9f9d42f70()	Unknown
EmbeddedBrowserWebView.dll!00007ff9f9d6ed8f()	Unknown
EmbeddedBrowserWebView.dll!00007ff9f9d42aaf()	Unknown
[Managed to Native Transition]	
Microsoft.Web.WebView2.Core.dll!Microsoft.Web.WebView2.Core.CoreWebView2Controller.Close()	Unknown
Microsoft.Web.WebView2.WinForms.dll!Microsoft.Web.WebView2.WinForms.WebView2.UnsubscribeHandlersAndCloseController(bool browserCrashed)	Unknown
Microsoft.Web.WebView2.WinForms.dll!Microsoft.Web.WebView2.WinForms.WebView2.Dispose(bool disposing)	Unknown
System.dll!System.ComponentModel.Component.Dispose()	Unknown

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

1.0.2739.15

Framework

Winforms

Operating System

Windows 11

OS Version

No response

Repro steps

The problem is hard to manually reproduce, as it will only occur rarely on our automated test system

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions