Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bearsInformation opened this issue Dec 10, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@bearsInformation
Copy link

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

@bearsInformation bearsInformation added the bug Something isn't working label Dec 10, 2024
@bearsInformation
Copy link
Author

Additional verification
If the browser extension is not registered

  1. Environment.ProcessInfosChanged event occurs
  2. Environment.BrowserProcessExited event occurs

If the browser extension is registered

  1. Environment.ProcessInfosChanged event occurs
    only

In both cases, CoreWebView2.ProcessFailed event does not occur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants