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.

Error loading libcef.dll

Post Reply
ForestListener
Posts: 44
Joined: Sun Jul 07, 2019 1:46 pm

Error loading libcef.dll

Post by ForestListener »

Hello.

Sometimes (not always) on application start we've got the error:

Error loading libcef.dll
Error code : 0x00000020

Salvador, It will be very nice if you help me to solve this problem.

Thank you!
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Error loading libcef.dll

Post by salvadordf »

Hi,

That error message is shown when LoadLibraryEx has problems loading libcef.dll

The 0x00000020 error is a ERROR_SHARING_VIOLATION which means :
The process cannot access the file because it is being used by another process.
Some demos hide the main form while they close the browser and you might get that error if you try to run it again too soon.
Perhaps you are experiencing something similar.
ForestListener
Posts: 44
Joined: Sun Jul 07, 2019 1:46 pm

Re: Error loading libcef.dll

Post by ForestListener »

Salvador, thanks a lot!

Yes, i run the application multi-threaded way from a single folder.

So, is there way to turn off the CEF files read blocking? What is the purpose to block files if there is no changes in these files...

Or, if the first way is impossible, can i use a mutex (to allow other copies of the application to wait own loading queue)?

Tell me, please. Where should i use mutex?

Code: Select all

///MutexStart
GlobalCEFApp := TCefApplication.Create;
...
if GlobalCEFApp.StartMainProcess
then
begin
   Application.Initialize;
   ...
end;
///MutexEnd
And/Or

Code: Select all

///MutexStart
Chromium1.CreateBrowser(CEFWindowParent1);
///MutexEnd
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Error loading libcef.dll

Post by salvadordf »

Instead of running several instances of the same application I would create only one application in 64 bits that creates many browsers internally.

Those browsers can share the same cache or they can be totally independent from each other if you use a custom request context.
ForestListener
Posts: 44
Joined: Sun Jul 07, 2019 1:46 pm

Re: Error loading libcef.dll

Post by ForestListener »

We do not want to rebuild whole application. We want to fix this problem by using mutex. But we do not know, when we should set mutex and when release it.

I ask you, please, point the position in the code above.

We have to know where CEF loading local files:
Here GlobalCEFApp := TCefApplication.Create;
or Here GlobalCEFApp.StartMainProcess
or here Chromium1.CreateBrowser(CEFWindowParent1);

The information we ask you for can help us to solve this problem.

If each application will wait others to load, i hope, there will be no problem.

Thank you.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Error loading libcef.dll

Post by salvadordf »

The DLLs are loaded inside GlobalCEFApp.StartMainProcess and GlobalCEFApp.StartSubProcess but you can't put a mutex around it because the subprocesses call those functions and remain executing code inside that function until Chromium decides to close that process. Then the subprocess returns from GlobalCEFApp.StartMainProcess or GlobalCEFApp.StartSubProcess.

Perhaps you can modify TCefApplicationCore.LoadCEFlibrary (uCEFApplicationCore.pas) and acquire a named mutex before the LoadLibraryEx call and release it afterwards.

Let me know if it works.
ForestListener
Posts: 44
Joined: Sun Jul 07, 2019 1:46 pm

Re: Error loading libcef.dll

Post by ForestListener »

Hello.

For some reason I've choose another way to avoid this problem.

Thanks a lot, Salvador!
Post Reply