Use Chromium from exe and dll parallel

Post Reply
Albus
Posts: 45
Joined: Thu Aug 31, 2017 1:22 pm
Location: Germany

Use Chromium from exe and dll parallel

Post by Albus » Wed May 13, 2020 9:09 am

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: 2337
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Use Chromium from exe and dll parallel

Post by salvadordf » Thu May 14, 2020 9:52 am

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/16145264/access-vcl-form-from-dll

Albus
Posts: 45
Joined: Thu Aug 31, 2017 1:22 pm
Location: Germany

Re: Use Chromium from exe and dll parallel

Post by Albus » Thu May 14, 2020 12:34 pm

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: 2337
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Use Chromium from exe and dll parallel

Post by salvadordf » Thu May 14, 2020 12:50 pm

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/cef/wiki/GeneralUsage.md

sarek
Posts: 1
Joined: Tue May 19, 2020 2:02 pm

Re: Use Chromium from exe and dll parallel

Post by sarek » Tue May 19, 2020 2:06 pm

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