* * *

Author Topic: fpCef3: cef3lib.pas: set CefResourcesDirPath/CefFrameworkDirPath in FormCreate?  (Read 3474 times)

PaulANormanNZ

  • Jr. Member
  • **
  • Posts: 81
Hi

What are CefResourcesDirPath and  CefFrameworkDirPath (cef3lib.pas) for?

CefLocalesDirPath can/must be set in FormCreate,
 but is it possible to also point to the required DLLs etc through CefResourcesDirPath and or CefFrameworkDirPath or other in a unit's FormCreate?

Or must the resources be in the project directory or path, compulsorily?

I would like to share these between applications, with out the overhead of all of the files needing to be duplicated for each application on a User's device.

I'm developing with fpCEF3-3.3029 and matched resources
on Windows 8.1
Lazarus 1.8.0 r56594 FPC 3.0.4 x86_64-win64-win32/win64.

TIA

Paul

Thaddy

  • Hero Member
  • *****
  • Posts: 6904
IIRC there is an example for chromium somewhere pointed to on this forum.

This topic may also be of interest http://forum.lazarus.freepascal.org/index.php/topic,34519.msg226984.html#msg226984

And the wiki of course http://wiki.freepascal.org/fpCEF3 It worked for me on Windows and Linux-arm.
« Last Edit: December 22, 2017, 06:58:37 am by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

PaulANormanNZ

  • Jr. Member
  • **
  • Posts: 81
Thanks Thaddy,

I've had Chromium running nicely thank you, I was just trying to find out if it was possible to share it's resources (some 460mb? per project  :) ) between different apps on the same machine.

I did a search on the CefResourcesDirPath/CefFrameworkDirPath variables on this Forum but nothing had turned up; and Google only has one result which goes to the GitHub source...

https://www.google.co.nz/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjSpeDjsJ3YAhUD2LwKHQf6A6UQFggrMAA&url=https%3A%2F%2Fgithub.com%2Fdliw%2FfpCEF3%2Fblob%2Fmaster%2Fcef3lib.pas&usg=AOvVaw2q3KRPLaH3-IizqxkmHfkp that is https://github.com/dliw/fpCEF3/blob/master/cef3lib.pas

The GitHub Readme says...

Quote
Resources

Unless CefResourcesDirPath and CefLocalesDirPath is set, CEF expects the resources to be in the same folder as the executable.

Binaries

The setup of the binaries depends on the target operating system:
Windows

Copy all files from either Debug or Release to the folder your .exe will be in.


I wanted to know if CefFrameworkDirPath could point to the binaries outside the app's .exe folder, or what CefFrameworkDirPath actually refers to?

I'm keen to find out if its possible to share the CEF3 Release folder, as the Release directory alone contains 416 MB and it would be good to be able to share them between projects without installing them in Windows .dll (etc) area(s) to keep better and simpler version control.

... so that's why I posted here.

That http://forum.lazarus.freepascal.org/index.php/topic,34519.msg226984.html#msg226984 link is very helpful for many other useful things thanks.

Anyone have any direct experience please with CefResourcesDirPath and particularly: CefFrameworkDirPath?

TIA

Paul
« Last Edit: December 23, 2017, 03:29:48 am by PaulANormanNZ »

Altagur

  • New member
  • *
  • Posts: 10
You have to set this path before the cef load it, so if the cef is on your form, and created design time you have to delete it and create at runtime after you set this two path, or set in  initialization, or the application initialization section, lpr.

I use the two path to redirect to one path for example: c:\proj\cefVer1\
, i didn't try with different path.

I copied all file except chrome_elf.dll, if i copied its throw exception.



PaulANormanNZ

  • Jr. Member
  • **
  • Posts: 81
Dear Altagur,

So just to confirm,

if at run time for each project,  I set both CefResourcesDirPath and CefFrameworkDirPath to one reusable/sharable path, say for example: c:\proj\cefVer1\
 and have everything required in there exceept for chrome_elf.dll,

and always have  chrome_elf.dll in each project's top directory,

I should be alright?

Previously it became a real problem in just trying to run the FPCef3 examples folders :-)

Thanks for that,
Paul
« Last Edit: January 15, 2018, 10:46:27 pm by PaulANormanNZ »

Altagur

  • New member
  • *
  • Posts: 10
Yes, and creation order is very important.

   1.  set both CefResourcesDirPath and CefFrameworkDirPath to one reusable/sharable path
   2.  create the form/unit that use CEF,

for example the .lpr.

 //uses ceflib..
begin
  RequireDerivedFormResource:=True;
  CefResourcesDirPath := 'c:\proj\cefVer1\';
  CefFrameworkDirPath :=  'c:\proj\cefVer1\';
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);  // for example <- this form use the Tchromium;
  Application.Run;
end.   


PaulANormanNZ

  • Jr. Member
  • **
  • Posts: 81
Thanks,

I'm now getting an error:

specified module could not be found - EOSerror OS Code 126

I'm wondering if there is something else as well as chrome_elf.dll that actually needs to be in the project's directory?

Here is my .lpr

Code: [Select]
program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, main,
  { you can add units after this }
  cef3lcl, cef3intf, cef3types, cef3lib, cef3gui;

{$R *.res}

var
  cefPath : string;

begin
     cefPath := 'C:\cef3\win64cef33029\';
  RequireDerivedFormResource:=True;
    CefResourcesDirPath := cefPath;
  CefFrameworkDirPath :=  cefPath;
 // CefLocalesDirPath := cefPath + 'locales\';
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.                 

My project directory looks like this now

Code: [Select]
backup
chrome_elf.dll
debug.log
lib
main.lfm
main.pas
project1.exe
project1.ico
project1.lpi
project1.lpr
project1.lps
project1.res

And here is my C:\cef3\win64cef33029 directory...

Code: [Select]
cef.pak
cef_100_percent.pak
cef_200_percent.pak
cef_extensions.pak
cef_sandbox.lib
d3dcompiler_43.dll
d3dcompiler_47.dll
devtools_resources.pak
icudtl.dat
libcef.dll
libcef.lib
libEGL.dll
libGLESv2.dll
locales
natives_blob.bin
snapshot_blob.bin
widevinecdmadapter.dll

Am I missing anything that you have?
Or do I actually need something else in the Project's directory additional to chrome_elf.dll ?

TIA
Paul

Altagur

  • New member
  • *
  • Posts: 10
Finally i have working modell.

Sorry for my inaccuracy, i'm work with Delphi, and Lazarus is just hobby.

I had to do changes on cef3api.pas

After implementation you see this:

implementation
....
const
  CefLibrary: String =
    {$IFDEF WINDOWS}'libcef.dll'{$ENDIF}
    {$IFDEF LINUX}'libcef.so'{$ENDIF}
    {$IFDEF DARWIN}'Chromium Embedded Framework'{$ENDIF};       

You have to copy and paste before implementation

const
  CefLibrary: String =
    {$IFDEF WINDOWS}'libcef.dll'{$ENDIF}
    {$IFDEF LINUX}'libcef.so'{$ENDIF}
    {$IFDEF DARWIN}'Chromium Embedded Framework'{$ENDIF};   
.....
implementation   

After that:
  .lpr:

  CefFrameworkDirPath :=  cefPath;
  CefLibrary := cefpath + 'libcef.dll';

And its work for me.





PaulANormanNZ

  • Jr. Member
  • **
  • Posts: 81
Thanks Altagur, this is awesome!

We can live with 543kb of chrome_elf.dll having to be in each project directory, though I am wondering if there is a setting somewhere for that as well..?

Do we recommend to the fpCef3 developers on their Git Wiki, making that scope change to cef3api.pas?

I am wondering a little about Const being dynamic? Appears to be allowed for us to redefine CefLibrary in our .lpr, but is that strictly right? And could we run into problems if FP were tightened up? Should Const in cef3api.pas  be made a Var declaration?

And at the end of it all perhaps once things are settled, maybe getting a posting up on the Lazarus wiki for fpCef3? Perhaps others would really benefit if they have more than one application relying on fpCef3 - the disk space savings are potentially enormous it seems.

Thanks again,
Paul

Altagur

  • New member
  • *
  • Posts: 10
Thanks Altagur, this is awesome! You’re welcome.


We can live with 543kb of chrome_elf.dll having to be in each project directory, though I am wondering if there is a setting somewhere for that as well..?

I didn't find it, because i'm think its in the *cef*.dll, somewhere.. if search cef source files we can find it, but its c++ and if we found it then we have to rebuild it, and build up the whole environment i think its take too long time.
I know the Spotify use cef, but they also copy all cef files into the same directory.

Do we recommend to the fpCef3 developers on their Git Wiki, making that scope change to cef3api.pas?
I am wondering a little about Const being dynamic? Appears to be allowed for us to redefine CefLibrary in our .lpr, but is that strictly right? And could we run into problems if FP were tightened up? Should Const in cef3api.pas  be made a Var declaration?

Yes of course. You are right. The Const is not the right way, the Delphi ceflib.pas also looks like:

var
  CefLibrary: string = {$IFDEF MSWINDOWS}'libcef.dll'{$ELSE}'libcef.dylib'{$ENDIF};



(And after all sorry for my English)
« Last Edit: January 16, 2018, 02:55:15 pm by Altagur »

PaulANormanNZ

  • Jr. Member
  • **
  • Posts: 81
Ok Altagur,

I've started an issue on the fpCEF3 github site, which gives the steps we are looking at, which others could possibly actually follow at present:

https://github.com/dliw/fpCEF3/issues/65

Have a look if you want in case it needs amending  ::)

Paul

Altagur

  • New member
  • *
  • Posts: 10
It's perfect, thanks for mentioning me!  :D

Have a good day!
« Last Edit: January 17, 2018, 11:18:40 am by Altagur »

SymbolicFrank

  • Sr. Member
  • ****
  • Posts: 394
If you use dll's (Windows), it is not possible to specify a path to the dll. There is a sequence of locations where Windows will try to find your dll. And if you have two different dll's with the same name, only the first one found is used. Roughly it's:

1. Executable dir
2. System32

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx

PaulANormanNZ

  • Jr. Member
  • **
  • Posts: 81
Thnaks SymbolicFrank,

What you are saying is generally true and good advice.

However in both fpCEF3 and the CEF3 project itself, the designers have incorporated direct mechanisms to make things happen - and thankfully all is now working well, have a look if you want at:

https://github.com/dliw/fpCEF3/issues/65

Cheers,
Paul

SymbolicFrank

  • Sr. Member
  • ****
  • Posts: 394
Hi Paul,

I know how it works, I did a project where I used multiple browsers: one for the authentication and one for each client. The authentication an client had to be separate. (Many WEB-API's require that you do things in a browser.) I had to redo part of fpCEF3 and the CEF3 configuration as well.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus