Changing cef settings at runtime ?

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.

Changing cef settings at runtime ?

Postby yag » Fri Mar 31, 2023 6:17 am

Hello,

I need to change the Settings.cache_path at runtime.
So i made a function where i call CefShutdown(), then CefInitialize(<new_parameters>), but it crashes.
The callstack shows the crash in a RunBrowser function:
Code: Select all
>   libcef.dll!content::ContentMainRunnerImpl::RunBrowser(content::MainFunctionParams main_params, bool start_minimal_browser) Line 1139

But i couldn't find it in the cef master.
But i guess this function might be in the chromium sources ? Well i'don't know.
Just to be clear, i'm using ready-to-wear binaries and downloaded the cef source only to try to see what went on with this crash, but i'm not building it.

So first, is it possible to change the settings on the fly ?
If yes, maybe there's a less brutal way than shutting down/reinitializing ?
Otherwise, any advice on how to achieve this ?

Just in case it's interesting, i've put here 3 pictures of the crash: message, callstack, and locals (there are some NULL in the main_params argument...).
https://imgur.com/a/9GExfVQ

Thanks
Cedric
yag
Newbie
 
Posts: 8
Joined: Sat Jan 07, 2023 5:11 am

Re: Changing cef settings at runtime ?

Postby ndesktop » Fri Mar 31, 2023 8:13 am

I don't think it works that way. There is one CefInitialize AFAIK.
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am

Re: Changing cef settings at runtime ?

Postby magreenblatt » Fri Mar 31, 2023 8:35 am

Why do you want to change the cache_path? You can create a new CefRequestContext with a new cache_path and create a new CefBrowser using that.
magreenblatt
Site Admin
 
Posts: 12384
Joined: Fri May 29, 2009 6:57 pm

Re: Changing cef settings at runtime ?

Postby yag » Fri Mar 31, 2023 9:54 am

Thank you very much to both of you for taking the time to read and answer.

Ah, CefRequestContext ! I was creating my browsers passing them a nullptr and relying on the global context, so i didn't even think about that one :-)
I'll learn to use this one, thanks a lot for the pointer.

As for the why: in my game, players can have different "gaming contexts" (for lack of a better word).
And i would like to completely separate the different contexts, so i can tell to users "when you come back to a previous context, you are assured you'll be *exactly* in the same state as when you left it".
Going so far as separating the browser cache might be a bit of an overkill, but it's simpler for me to manage every context in its own directory.

Of course, nothing mandatory here, i could have lived with only one global cache, but as i'm in the process of discovering the CEF, i didn't cost anything to ask.

Again, thanks a lot
All the best
Cedric
yag
Newbie
 
Posts: 8
Joined: Sat Jan 07, 2023 5:11 am


Return to Support Forum

Who is online

Users browsing this forum: rjxray and 48 guests