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

Unable to remove user data folder for security concerns #4107

Closed
reynoldslabware opened this issue Oct 26, 2023 · 3 comments
Closed

Unable to remove user data folder for security concerns #4107

reynoldslabware opened this issue Oct 26, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@reynoldslabware
Copy link

What happened?

We would like to purge the web view 2 user data folder when our application closes.
The folder is created upon the first webView2 creation.
We open a web page, do stuff and then close our Window.
We also call m_controller->Close() and several other APIs to delete callback tokens of the webView2 world.
I did not see anything at the webView2 environment level to say "all done".
FWIW, CEF3 has a shutdown() API.
We close our intermediate DLL.
We are trying to delete the user folder via

 SHFILEOPSTRUCT shfo = {
		NULL,
		FO_DELETE,
		userDataFolder,
		NULL,
		FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION,
		FALSE,
		NULL,
		NULL };
UINT32 rc = SHFileOperation(&shfo);

We try this in our DLL both prior to its closing and afterward with another mechanism.
The user data folder remains in %TEMP%.
The return code seen is x20
"The process cannot access the file because it is being used by another process."

Any suggestions?

Importance

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

Runtime Channel

Prerelease (Edge Canary/Dev/Beta)

Runtime Version

No response

SDK Version

117.0.2045.31.manifest

Framework

Win32

Operating System

Windows 10

OS Version

No response

Repro steps

See description above.

Regression

No, this never worked

Last working version (if regression)

No response

@reynoldslabware reynoldslabware added the bug Something isn't working label Oct 26, 2023
@LiangTheDev
Copy link
Member

You could use BrowserProcessExited event to know when all related WebView2 browser processes have exited. We actually have exactly the same scenario (close and delete user data folder) in our sample app: https://github.com/MicrosoftEdge/WebView2Samples/blob/861920924264964808ed3806853fef84455ad5ef/SampleApps/WebView2APISample/AppWindow.cpp#L1964.

@reynoldslabware
Copy link
Author

Thank you for the suggestion. I will add this hook and observe what exit callbacks occur for our application and their timing relative to our application closing.

@reynoldslabware
Copy link
Author

All good now. Thank you.

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