One cache accessed by multiple instances of CEF

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

One cache accessed by multiple instances of CEF

Postby callum » Wed Aug 25, 2021 6:45 pm

Is it still true as of CEF 91+ that having the same cache directory for each CEF instance is going to have undefined and problematic behavior. Our app loads the CEF based code as a DLL/so and each one (there are around a dozen) uses the same cache folder.

If that's not supported then we might have to switch to a model where each instance gets its own folder but that would greatly complicate the code in our application.

Doesn't Chrome do this or is each tab a window and they are all children of a single process? If under those circumstances, sharing the cache folder is supported then perhaps we should consider changing our CEF code to use that model instead.

Are multiple windows just additional calls to CefBrowserHost::CreateBrowserSync(...)?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: One cache accessed by multiple instances of CEF

Postby amaitland » Wed Aug 25, 2021 6:56 pm

Only a single process can access the cache. When Chrome opens multiple windows they are all windows within a single process.

If you have multiple applications (processes) running concurrently then they will each need their own cache.

callum wrote:If that's not supported then we might have to switch to a model where each instance gets its own folder but that would greatly complicate the code in our application.


What's the complication exactly? You could use a simple convention where the executable name is used as part of the CachePath
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: One cache accessed by multiple instances of CEF

Postby callum » Wed Aug 25, 2021 7:13 pm

What's the complication exactly? You could use a simple convention where the executable name is used as part of the CachePath


The concerns are specific to our application and not a CEF concern.

For example, if we wanted to give each instance its own cache folder name, we would need to make that repeatable so the same instance, used the same cache folder each time between sessions. (each instance is the same DLL, loaded from the same app) Currently that would be hard - not impossible, but some significant additional complexity.

We also inject some cookies into the cache so that pages internal to the company can be opened without logging in again (you have to log into the application itself) - this means we'd have to regularly iterate over the whole set of cache dirs and inject the cookies we need manually. Again - all doable but a bit more work.

Sounds like it's required though - I saw some new fields in the settings (root_cache_dir, context_cache_dir from memory) so I wondered if things were different now.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: One cache accessed by multiple instances of CEF

Postby amaitland » Wed Aug 25, 2021 8:36 pm

The root cache path is for use with CefRequestContext, browsers within the same process can have different caches.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: One cache accessed by multiple instances of CEF

Postby callum » Wed Aug 25, 2021 9:27 pm

Understood but I don't understand when or why I should use a CefRequestContext - the official looking, first hit on Google is (for me at least) difficult to parse https://magpcss.org/ceforum/apidocs3/projects/(default)/CefRequestContext.html
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 96 guests