Page 1 of 1

Use Chromium from exe and dll parallel

Posted: Wed May 13, 2020 9:09 am
by Albus
Hi, we have an exceptional situation. We try to use Chromium both in an EXE and in a DLL that is loaded from this EXE. It works, if both (EXE and DLL) loads each a different copy of the CEF DLLs. But if both implementations try to use the same copy of the CEF DLLs, Chromium only works in the EXE. In the DLL, the property GlobalCEFApp.GlobalContextInitialized is never set to TRUE. Is there any possibility that we can make this work?

Re: Use Chromium from exe and dll parallel

Posted: Thu May 14, 2020 9:52 am
by salvadordf
Hi,

I've never tried that and I'm not sure if that's possible.

Read the answer in this link for more details :
https://stackoverflow.com/questions/161 ... m-from-dll

Re: Use Chromium from exe and dll parallel

Posted: Thu May 14, 2020 12:34 pm
by Albus
Thank you for the link. But the StackOverflow answer only tells that it is not possible to use the exact same GloabCefApp from the EXE in the DLL. For our case, it is ok that both have their own instance to GlobalCefApp. It works if both (EXE and DLL) use a different copy of the DLLs. The problem with using the same copy of the DLLs might be that the main entry point of the CEF DLL (not of chromium but the DLL itself) is only called the first time (loaded in the EXE) and not the second time (loaded in the DLL). Out theory is now that in this main entry point of the CEF DLL, some code is executed that initializes something. If this is the case, is there an option to call this code manually?

Re: Use Chromium from exe and dll parallel

Posted: Thu May 14, 2020 12:50 pm
by salvadordf
CEF can only be initialized once per process. This is a CEF feature and I though it wasn't possible to avoid but I see now that using different CEF binaries in a DLL might be a workaround.

All the raw CEF API is available in uCEFLibFunctions.pas if you want to do some tests. The main functions to initialize CEF are cef_execute_process and cef_initialize.

This Wiki explains how to use them :
https://bitbucket.org/chromiumembedded/ ... alUsage.md

Re: Use Chromium from exe and dll parallel

Posted: Tue May 19, 2020 2:06 pm
by sarek
Hi.

It seems MustCreateBrowserProcessHandler works for this. Its a property of TCefApplication.
If i set it to FALSE in the DLL then the initialization works on both. Provided it is initialied in the EXE before.