MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: Host process handles remain after repeatedly creating and closing the WebView2 environment/controller

Open
#5,704 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

On a native WebView2 host running on Windows 11, host process handles remain after creating and closing the WebView2 environment/controller 100 times and releasing the references. The detailed report and the minimal reproduction code (WebViewRuntimeLifecycleProbe.cpp) are included in the attached ZIP file.

The probe runs a message pump on an STA thread. After controller.Close(), it waits for the browser process to terminate at the kernel level and for BrowserProcessExited. It then removes the event subscription, releases the environment reference, and continues pumping messages for another 10 seconds. The probe does not use PALF/VCL, databases, external pages, host objects, or WebMessage.

Environment Runtime Result (after 100 completed cycles, relative to the 10th warm-up baseline)
Windows 11 Pro / 26200.9445 / 64-bit OS, 32-bit host 152.0.4191.66 +272
Windows 10 Pro / 19045.6466 / 32-bit OS, 32-bit host 152.0.4191.66 0 increase

The issue is also reproducible on the Windows 11 development PC. An independent Win64 probe, Fixed Runtime 151/152, and SDK 1.0.4191.47 also showed an increase. A 100-cycle control test that only performed ordinary CreateProcess, process termination, and handle release showed no increase.

The verification configuration was Win32 / C++Builder 13 BCC32C / Release (-O2), using the COM declarations from Microsoft SDK 1.0.3296.44 and the signed WebView2 Loader. Verification with MSVC has not been performed.

By default, the controller is closed immediately after it is created. With --navigate-before-close, the probe waits for a successful NavigationCompleted event for a fixed local HTML file before closing the controller. Some 100-cycle runs showed no increase with this option, but another run showed +30. Therefore, this is not considered a guaranteed workaround.

Could you please confirm whether the shutdown order is missing any required step, and whether there is a known issue, fix, or supported release procedure for this case? We have not forcibly closed any handle whose ownership was unknown.

Detailed report and reproduction code:

webview2-feedback-draft.zip

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 WebViewRuntimeLifecycleProbe.cpp in the attached ZIP and run the documented 100-cycle probe on the stated Windows configurations. Compare host handle counts with the warm-up baseline and the ordinary CreateProcess control, then review the reported shutdown sequence and event-subscription removal. Done means identifying whether the sequence is missing a supported step or confirming a WebView2 runtime issue with reproducible evidence.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.