MicrosoftEdge / MicrosoftEdge/WebView2Feedback

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

Open
#4,817 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported shutdown path through WebView2.Dispose, UnsubscribeHandlersAndCloseController, and CoreWebView2Controller.Close, which reaches DestroyWindow in EmbeddedBrowserWebView.dll. Review the SDK version 1.0.2739.15 and the Windows 11 automated-test context, then seek a way to capture the intermittent hang. Done means identifying a reproducible cause or actionable diagnostic guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.