Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Use Chromium from exe and dll parallel

Post Reply
Albus

Use Chromium from exe and dll parallel

Post 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?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Use Chromium from exe and dll parallel

Post 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
Albus

Re: Use Chromium from exe and dll parallel

Post 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?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Use Chromium from exe and dll parallel

Post 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
sarek
Posts: 1
Joined: Tue May 19, 2020 2:02 pm

Re: Use Chromium from exe and dll parallel

Post 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.
Post Reply