MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: WebView2 process not disposing

Open
#4,628 1 comment 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?

I get this error:

System.IO.IOException: The process cannot access the file 'AssistanceHomeSQLite' because it is being used by another process.

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

1.0.2535.41

Framework

WPF

Operating System

Windows 11

OS Version

No response

Repro steps

I am trying to execute this code:

string webViewUserDataFolder = WebView.CoreWebView2.Environment.UserDataFolder;

int webViewProcessId = Convert.ToInt32(WebView.CoreWebView2.BrowserProcessId);

Process webViewProcess = Process.GetProcessById(webViewProcessId);

WebView.Dispose();

using CancellationTokenSource cts = new(5000);

try
{
   // Never ends
    await webViewProcess.WaitForExitAsync(cts.Token);
}
catch (OperationCanceledException e)
{
}

// This line fails
Directory.Delete(webViewUserDataFolder, recursive: true);
Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Don't know

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 WPF reproduction using WebView.Dispose, CoreWebView2.Environment.UserDataFolder, BrowserProcessId, and WaitForExitAsync. Reproduce the failure on Windows 11 with SDK 1.0.2535.41 and determine why the process remains active; done means the user data folder can be deleted after disposal without the file-in-use error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.