cef
cef copied to clipboard
Not all file handles are closed after Cef.Shutdown
Describe the bug I'm coming from CefSharp and was told to open an issue here. I hope this is fine. This is the original issue: https://github.com/cefsharp/CefSharp/issues/4852
I have set a custom RootCache path and want to delete that cache folder after Cef.Shutdown is called (during the application shutdown). But using the (new) Chrome Bootstrap some files still have open handles so the whole folder can't be deleted. Changing the runtime back to Alloy Bootstrap (in the same version) the folder can be deleted afterwards as expected.
Note: There is a big difference in what is written to that directory (not sure if this is a problem too).
This is what I get with Alloy Bootstrap:
and this is what I get with Chrome Bootstrap:
Expected behavior All file handles should be cleared after Cef.Shutdown was successfully called.
Versions (please complete the following information):
- OS: Windows 11 (Version 23H2 Build 22631.3810)
- CEF Version: 126.2.7
Additional context
Does the problem reproduce with the cefclient or cefsimple sample application at the same version?
Not tested, but I don't think so since the folder isn't deleted afaik.
Does the problem reproduce with Google Chrome at the same version?
No
What are the files with open handles? See here for tools that will tell you.
Everything in the orange box:
Note that my RootCache path is: %localappdata%/CefSharp/RootCache
Are child processes still running after you call CefShutdown?
Doesn't look so.
Before Cef.Shutdown:
After Cef.Shutdown:
OK. Some of these files (like chrome_debug.log) likely aren't closed until all child processes have terminated.
But all child processes are closed. The one process marked in the second screenshot is the main process (CefSharp...exe)
But all child processes are closed. The one process marked in the second screenshot is the main process (CefSharp...exe)
Right, but in case they're not closed immediately after CefShutdown returns (for you or someone else), it could still be an issue.
We are also facing this exact issue, with no current solution.
The following files are being held and can not be deleted when the application exits.
This issue still exists in CefSharp.WinForms version 128.4.9.
A lot of time has passed since this issue was created. Is there already a plan to solve this problem? Is anyone working on this problem at all?
same issue,is anyone has solution or workaround?
The workaround is to delete the cache on next application start (before calling CefInitialize) instead of during application shutdown.
The workaround is to delete the cache on next application start (before calling CefInitialize) instead of during application shutdown.
thats not a solution at all if you are writing to a GUID folder and allow multiple instances of your application to run at the same time
Spawn another instance of your application on shutdown that waits a short amount of time then performs the cleanup. You just pass in a set of command line args saying cleanup folder x then terminate.
That's hardly a sensible option. How long is a short period of time? Is that constant on all devices this might get installed on?
It's a reliable and achievable option that ppl are currently using.
The workaround we currently use for this: We are using the PID as folder name to allow multiple instances to run at the same time. When closing, we compare running processes and existing folders using PID and delete those that are no longer used. We do not clean up the current folder, but we do clean up all previous folders, which is at least sufficient for our purposes.
he PID as folder name to allow multiple instances to run at the same time. When closing, we compare running processes and existing folders using PI
i did something similar, but just delete all the folders that have my temp folder prefix if i am the only process running. This way the last running process does all the cleanup
It's a reliable and achievable option that ppl are currently using.
If this is the offcial advice does that mean there is no intention to fix this bug?
Hi Alex,
Have you considered adding an option for ClearCacheOnShutdown as a Boolean property of CefSharpSettings that spawns a process on CefShutdown to clear files in the CachePath / RootCachePath specified during initialization? That is how I handle this issue. I built that as a submodule that can be added easily to all of my CefSharp projects
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Saurbaum @.> Sent: Wednesday, June 11, 2025 6:13:04 AM To: chromiumembedded/cef @.> Cc: Stephen Soper @.>; Comment @.> Subject: Re: [chromiumembedded/cef] Not all file handles are closed after Cef.Shutdown (Issue #3726)
[https://avatars.githubusercontent.com/u/7288848?s=20&v=4]Saurbaum left a comment (chromiumembedded/cef#3726)https://github.com/chromiumembedded/cef/issues/3726#issuecomment-2962661088
It's a reliable and achievable option that ppl are currently using.
If this is the offcial advice does that mean there is no intention to fix this bug?
— Reply to this email directly, view it on GitHubhttps://github.com/chromiumembedded/cef/issues/3726#issuecomment-2962661088, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB3SCNFSHJFUQI4EMYISKBD3DATOBAVCNFSM6AAAAAB2ESR4BGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNRSGY3DCMBYHA. You are receiving this because you commented.Message ID: @.***>