MicrosoftEdge / MicrosoftEdge/WebView2Feedback

The CacheFolder is locked by msedgewebview2.exe and cannot be deleted even when the app is closed.

Open
#4,983 1 comment 0 reactions 1 assignee View on GitHub

@dianaqu is already working on this.

Since Dec 13, 2024.

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

Description

What happened?

Once you register a browser extension with AddBrowserExtensionAsync, the CacheFolder is locked by msedgewebview2.exe and cannot be deleted even when the app is closed.

environment
Microsoft Visual Studio Community 2022 (64 bit) - Preview
Version 17.13.0 Preview 2.0

  1. cacheFolderPath 「%temp%\WebView2Cache」

  2. 「Microsoft Visual Studio 2022」closed.

  3. 「%temp%\WebView2Cache」Folder deletion failed.

  4. Search for "WebView2Cache" in resmon.exe
    The results are as follows:
    img01

  5. Upon checking, I found that 「%temp%\WebView2Cache」 was not terminated and remained locked by "msedgewebview2.exe".

  6. During debugging, "msedgewebview2.exe" does not terminate 「%userprofile%\AppData\Local\Microsoft\VisualStudio\Webview2Cache」.

  7. The folder can be deleted by terminating the "msedgewebview2.exe" process.
    However, there is still a problem with unnecessary processes remaining.

Importance

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

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

131.0.2903.86

SDK Version

1.0.2903.40

Framework

Winforms

Operating System

Windows 11

OS Version

24H2 26100.2454

Repro steps

code

using Microsoft.Web.WebView2.Core;
using System;

using System.Threading.Tasks;
using System.Windows.Forms;

namespace WebView2_TEST_C_
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private async Task InitializeAsync()
        {
            WebView2.CoreWebView2InitializationCompleted += WebView2_CoreWebView2InitializationCompleted;
            
            string cacheFolderPath = @"<%temp%>\WebView2Cache";
            options.AreBrowserExtensionsEnabled = true;
            CoreWebView2Environment environment = await CoreWebView2Environment.CreateAsync(null, cacheFolderPath, options);
            await WebView2.EnsureCoreWebView2Async(environment);
        }

        private async void Form1_Load(object sender, EventArgs e)
        {
            await InitializeAsync();
        }

        private async void WebView2_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
        {
            // Operation confirmed on edge
            var path = @"<%userprofile%>AppData\Local\Microsoft\Edge\User Data\Default\Extensions\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\1.0.0.0_0";
            var extension = await WebView2.CoreWebView2.Profile.AddBrowserExtensionAsync(path);
        }
    }
}
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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.