-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Attempt to clean-up WV2 data folder on window close #349
Conversation
Hey @aluhrs13, thanks a lot for the PR! I tested it out, and it seems that WebView still leaves behind some files: What I'm observing is that after closing the window for the first time, the user profile folder is deleted, but then next time you open and close it, at least some files in the folder remain. I don't think I'm opening and closing the window too quickly, as I wait around 3 seconds – and that time is consistently enough to clear the data on the first attempt. |
Hey @Tyrrrz It's Daniel here, I replied to your post on Twitter and your post on webview2 feedback tracker. I have some code that does some cleaning up, it's along the same line as what the OP provided but a little more in-depth. I'll need to do some testing to see if what I have helps it further. Cheers |
Thanks, Daniel. Would be awesome. |
Ok I'm posting the code that I have in my app when I am closing the browser. I haven't got to putting this in your app yet to see if it helps (I just got home) but will do so. A suggestion on my side is that you create the folder in someone's appdata folder and not the same as the main program- to avoid permission issues if someone put this in their program files folder. Here's the code that I have in my app:
|
That seems more or less the same as what @aluhrs13 suggested, right? |
Yes, it's pretty much the same, only difference is that I'm removing files and folders one by one and I also got logic where if the deleting failed for any reason, it won't crash the application (something that I ran into in my early days). Let's wait and see what the guys at webview2 say (if they can offer some work around in the interim). |
@Danielx64 - With that logic is there a certain file the consistently doesn't get deleted? |
Good question, I haven't really looked into that, the most I worry about was how big the entire folder is. I seen it go from say 50mb right down to 1 5 mb. In some cases (not always) the whole folder gets removed. The delay I put in was designed to give it time before trying to delete files etc. Mind you that's in my app and not this one. |
Gonna close this for now as it doesn't work as well as I'd hoped (see my above comment). Hopefully, WebView2 will provide an out-of-the-box support for a fully in-memory execution mode. |
Taking a quick stab at the direction of cleaning up WV2 data. This will clear the browsing data when the user closes the auth window, trigger a dispose of the control, then delete the entire user data folder once the WV2 processes finish getting shutdown.
I'm not the best WPF developer, so I'm not sure doing this on
Click
is actually correct, but figured sharing something is better than nothing 😊. I was also able to hit some mild race condition that left the data folder by very quickly opening and closing the auth window. That's partially why there's theClearBrowsingData
call - the deleting of the UDF is "best effort" butClearBrowsingData
has a stronger guarantee that data will be deleted, just not all of it.