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

[Problem/Bug]: Process holding webview2 when deleting profile #4384

Closed
riyafa opened this issue Feb 21, 2024 · 6 comments
Closed

[Problem/Bug]: Process holding webview2 when deleting profile #4384

riyafa opened this issue Feb 21, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@riyafa
Copy link

riyafa commented Feb 21, 2024

What happened?

I have webview2 running on wpf. After closing the webview2 window and after window closing event is received and completed, we are deleting the contents of the webview2 profile folder.
We are getting a

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

What other process could be holding onto the profile files when the webview2 window is already closed?
This does not always happen and hence hard to reproduce locally. We see this happening in prod instances. We cannot call CoreWebView2Profile.Delete method because we may not always have access to CoreWebView2Profile.

How can we find what the issue is and properly delete the webview2 profile folder all the time?

Importance

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

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

121.0.2277.128

SDK Version

1.0.2210.55

Framework

WPF

Operating System

Windows 10

OS Version

No response

Repro steps

Try closing webview2 window running in wpf and deleting the contents of the webview2 profile folder programmatically. Repeat this multiple times and note that an io exception is thrown because the folder contents cannot be deleted because another process is holding onto it.

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

@riyafa riyafa added the bug Something isn't working label Feb 21, 2024
@riyafa
Copy link
Author

riyafa commented Mar 7, 2024

@peiche-jessica any update on this?

@peiche-jessica
Copy link
Collaborator

Hey there, could you please clarify why you don't always have access to the profile object? If you have access to the wpf WebView2 control, you can get the profile object via webView.CoreWebView2.Profile. Would you be able to do profile.Delete() and then close the WebView upon the profile.Deleted event?

@riyafa
Copy link
Author

riyafa commented Mar 13, 2024

We do not always have the profile object because we want to delete the user profiles when the user logs out of our desktop app. When logging out of the desktop app the user may or may not have opened the webview window or they might have closed it after opening it. When the webview window is not open we don't have the profile object, but we still want to delete the user profile object. This is the reason for trying to delete it manually and getting the error mentioned when deleting the profile folder at times.

@peiche-jessica
Copy link
Collaborator

When the window is closed, webview process might still be alive for a short period of time. You can check if there's still msedgewebview2.exe process running before you programmatically delete the profile folder.

@chambm
Copy link

chambm commented Apr 4, 2024

I am running into this as well. Even with code like this:

webView.CoreWebView2.Profile.Deleted += (s, ea) => Close();
webView.CoreWebView2.Profile.Delete();

From the Deleted event documentation (and my experience), it seems like it triggers right when Delete() is called, before the deletion is actually finished. If that's true, then that event seems misnamed. And not as useful as an event that triggers when the profile is actually deleted (and/or the msedgewebview2.exe child process terminates). Now I'm going to look up how to monitor a named child process for closing...

@bdovaz
Copy link

bdovaz commented Jun 14, 2024

Related #4628

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

4 participants