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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

six1
Posts: 7
Joined: Mon Jul 20, 2020 1:09 pm

Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by six1 »

Hi,
i've tried CEF4Delphi/Lazarus. Installation on Lazarus 2.0.10/fpc 3.20 worked like a charm.
System is Debian10/Buster 64Bit.
(also tried on WIN10/64 Bit without any Problems!)

I downloaded cef_binary_84.2.1+g3f2c372+chromium-84.0.4147.89_linux64_minimal
i copied ceflib.so into /usr/lib
setup for CEF:

Code: Select all

procedure CreateGlobalCEFApp;
var
  TempHome, TempBinDir : ustring;
begin
  TempHome     := IncludeTrailingPathDelimiter(extractfilepath(application.ExeName));
  TempBinDir   := TempHome + 'CEF';
  GlobalCEFApp               := TCefApplication.Create;
  GlobalCEFApp.SetCurrentDir := True;
  if DirectoryExists(TempBinDir) then
    begin
      GlobalCEFApp.FrameworkDirPath     := TempBinDir;
      GlobalCEFApp.ResourcesDirPath     := TempBinDir;
      GlobalCEFApp.LocalesDirPath       := TempBinDir+PathDelim+'locales';
      GlobalCEFApp.cache                := TempBinDir+PathDelim+'cache';
      GlobalCEFApp.UserDataPath         := TempBinDir+PathDelim+'UserData';
    end;
  // Add a debug log in the BIN directory
  GlobalCEFApp.LogFile     := 'cef.log';
  GlobalCEFApp.LogSeverity := LOGSEVERITY_DEFAULT;//LOGSEVERITY_VERBOSE;
end;
in project folder there is:
CEF
CEF/locales
CEF/UserData
CEF/cache

copied Data from downloaded lib Release and Resources into folder CEF

Copied Project "SimpleBrowser2" into Projet folder.
Compiling worked without errors. Software starts, didn't show Main Window and closes immediately.
No Errors or warnings.

In Debug Mode i can see, in File CEFApplicationCore.pas line 1028

Code: Select all

function TCefApplicationCore.StartMainProcess : boolean;
begin
  if (FStatus <> asLoading) then
    Result := False
   else
    if not(FSingleProcess) and (length(FBrowserSubprocessPath) > 0) then
      Result := MultiExeProcessing
     else
      Result := SingleExeProcessing;
end;
FStatus is always asLoading and therefore in Projectfile

Code: Select all

  if GlobalCEFApp.StartMainProcess then
    begin
      RequireDerivedFormResource:=True;
      Application.Scaled:=True;
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end;
Form is never created.
Whats to do? :mrgreen:
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by salvadordf »

Hi Michael,

As I commented in the official CEF forum, CEF4Delphi still has issues running on Linux :
https://github.com/salvadordf/CEF4Delphi/issues/255
https://github.com/salvadordf/CEF4Delphi/issues/256

I wish I had time to learn more about Linux programming in order to fix them but right now I'm very busy. :oops:
six1
Posts: 7
Joined: Mon Jul 20, 2020 1:09 pm

Re: Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by six1 »

...one step further salvadordf :mrgreen:

in uCEFMiscFunctions, CheckDLLS Line 1173 :

Code: Select all

      TempList := TStringList.Create;
      TempList.Add(TempDir + CHROMEELF_DLL);
      TempList.Add(TempDir + LIBCEF_DLL);
      {$IFDEF MSWINDOWS}
      TempList.Add(TempDir + 'd3dcompiler_47.dll');
      TempList.Add(TempDir + 'libEGL.dll');
      TempList.Add(TempDir + 'libGLESv2.dll');
      TempList.Add(TempDir + 'swiftshader\libEGL.dll');
      TempList.Add(TempDir + 'swiftshader\libGLESv2.dll');
      {$ENDIF}
      {$IFDEF LINUX}
      TempList.Add(TempDir + 'libEGL.so');
      TempList.Add(TempDir + 'libGLESv2.so');
      TempList.Add(TempDir + 'swiftshader/libEGL.so');
      TempList.Add(TempDir + 'swiftshader/libGLESv2.so');
      {$ENDIF}
      TempList.Add(TempDir + 'icudtl.dat');
is wrong for Linux, because there is no CHROMEELF_DLL (only Windows). Must be:

Code: Select all

      TempList := TStringList.Create;
      TempList.Add(TempDir + LIBCEF_DLL);
      {$IFDEF MSWINDOWS}
      TempList.Add(TempDir + CHROMEELF_DLL);
      TempList.Add(TempDir + 'd3dcompiler_47.dll');
      TempList.Add(TempDir + 'libEGL.dll');
      TempList.Add(TempDir + 'libGLESv2.dll');
      TempList.Add(TempDir + 'swiftshader\libEGL.dll');
      TempList.Add(TempDir + 'swiftshader\libGLESv2.dll');
      {$ENDIF}
      {$IFDEF LINUX}
      TempList.Add(TempDir + 'libEGL.so');
      TempList.Add(TempDir + 'libGLESv2.so');
      TempList.Add(TempDir + 'swiftshader/libEGL.so');
      TempList.Add(TempDir + 'swiftshader/libGLESv2.so');
      {$ENDIF}
      TempList.Add(TempDir + 'icudtl.dat');
Now uSimpleBrowser2 Demo chrases at further stage:
Startet Program in Shell gives thsi result:

Code: Select all

./SimpleBrowser2
[0720/160659.827341:INFO:cpu_info.cc(53)] Available number of cores: 6
[0720/160659.827469:VERBOSE1:zygote_main_linux.cc(217)] ZygoteMain: initializing 0 fork delegates
[0720/160659.828320:INFO:cpu_info.cc(53)] Available number of cores: 6
[0720/160659.828441:VERBOSE1:zygote_main_linux.cc(217)] ZygoteMain: initializing 0 fork delegates
[0720/160659.847764:VERBOSE1:pref_proxy_config_tracker_impl.cc(185)] 0x7f76d0076270: set chrome proxy config service to 0x7f76d00285d0
[0720/160659.850797:VERBOSE1:webrtc_internals.cc(119)] Could not get the download directory.
[xcb] Unknown sequence number while processing reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
SimpleBrowser2: ../../src/xcb_io.c:643: _XReply: Zusicherung »!xcb_xlib_threads_sequence_lost« nicht erfüllt.
Abgebrochen
Could not get the download directory. ???

uses cthreads is in Project so i don't know to handle "... XInitThreads has not been called"
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by salvadordf »

Thanks for all the information and fixes !!! :D

I'll try to make some time to take a look at all this. Perhaps tomorrow, idk.
six1
Posts: 7
Joined: Mon Jul 20, 2020 1:09 pm

Re: Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by six1 »

next:
i got a widivine error...

install widivine:
#get
wget https://dl.google.com/linux/direct/goog ... _amd64.deb
#install in same folder
dpkg -x google-chrome-stable_current_amd64.deb .

next copied all from [folder where widivine was extracted]/opt/google/chrome/ to my /CEF Folder

Widivine Error is gone
six1
Posts: 7
Joined: Mon Jul 20, 2020 1:09 pm

Re: Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by six1 »

I tried to play with configuaration under debian10 x86_64

it's crashing in uCEFChromiumcore.pas Line 1991

Code: Select all

function TChromiumCore.CreateBrowserHost(      aWindowInfo : PCefWindowInfo;
                                         const aURL        : ustring;
                                         const aSettings   : PCefBrowserSettings;
                                         const aExtraInfo  : ICefDictionaryValue;
                                         const aContext    : ICefRequestContext): boolean;
var
  TempURL : TCefString;
begin
  TempURL := CefString(aURL);
  Result  := cef_browser_host_create_browser(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aExtraInfo), CefGetData(aContext)) <> 0;
end;    
Breakpoint on "Result :=..." one Step ahead Result:=true one Step further: crash.
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by salvadordf »

The demos crash even when I don't create any browser. Just initializing CEF would crash the app. :oops:

There's something wrong in the CEF initialization and I would need a lot of time to learn what's necessary to develop Lazarus applications in Linux.

I would also have to compare what fpCef was doing to work in Linux and compare it with other CEF wrappers that support that OS.
However, the last fpCef update had issues in Linux if I remember correctly.
six1
Posts: 7
Joined: Mon Jul 20, 2020 1:09 pm

Re: Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by six1 »

i'm investigating :lol:
when i declare GlobalCEFApp.SingleProcess:=true;
SimpleBrowser2 app is opening 3 windows
same 3 windows opening if i set to false.

In Windows i saw 5 Processes with false setting and with true setting only 2 processes.

an you're right, error is in GlobalCEFApp.StartMainProcess


latest version of fpcef is working fine under linux for me.

uCEFApplicationCore Line 1159
Result := cef_execute_process(@TempArgs, aApp.Wrap, FWindowsSandboxInfo);
is starting 2 processes of app... so with main there are 3... thats not ok i think
six1
Posts: 7
Joined: Mon Jul 20, 2020 1:09 pm

Re: Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by six1 »

Proccesses are startet
Image11.jpg
Info from cef.log

Code: Select all

[0723/105149.954854:INFO:cpu_info.cc(53)] Available number of cores: 4
[0723/105149.955140:VERBOSE1:zygote_main_linux.cc(217)] ZygoteMain: initializing 0 fork delegates
[0723/105150.000963:INFO:cpu_info.cc(53)] Available number of cores: 4
[0723/105150.001214:VERBOSE1:zygote_main_linux.cc(217)] ZygoteMain: initializing 0 fork delegates
[0723/105150.009868:VERBOSE1:pref_proxy_config_tracker_impl.cc(185)] 0x7fd1dc071c80: set chrome proxy config service to 0x7fd1dc026dd0
[0723/105150.014113:VERBOSE1:webrtc_internals.cc(119)] Could not get the download directory.
[0100/000000.150233:INFO:child_thread_impl.cc(847)] ChildThreadImpl::EnsureConnected()
Info from starting SimpleBrowser on Shell

Code: Select all

[0723/105149.954854:INFO:cpu_info.cc(53)] Available number of cores: 4
[0723/105149.955140:VERBOSE1:zygote_main_linux.cc(217)] ZygoteMain: initializing 0 fork delegates
[0723/105150.000963:INFO:cpu_info.cc(53)] Available number of cores: 4
[0723/105150.001214:VERBOSE1:zygote_main_linux.cc(217)] ZygoteMain: initializing 0 fork delegates
[0723/105150.009868:VERBOSE1:pref_proxy_config_tracker_impl.cc(185)] 0x7fd1dc071c80: set chrome proxy config service to 0x7fd1dc026dd0
[0723/105150.014113:VERBOSE1:webrtc_internals.cc(119)] Could not get the download directory.
[xcb] Unknown sequence number while processing reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
SimpleBrowser2: ../../src/xcb_io.c:643: _XReply: Zusicherung »!xcb_xlib_threads_sequence_lost« nicht erfüllt.
Abgebrochen
Is it possible, that Processes startet from GlobalCEFApp.StartMainProcess are not threading able?
Maybe they have to include XInitThreads ?

I didn't understand many things in cef4delphi and it will take a long time to understand many things...
You do not have the required permissions to view the files attached to this post.
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problems CEF4Dlphi -> Lazarus -> Debian10 x86_64

Post by salvadordf »

Download the official CEF Sample Application for Linux from Spotify :
http://opensource.spotify.com/cefbuilds ... nt.tar.bz2

It will also create several processes and you can compare them to these tests.

Unfortunately I don't know what XInitThreads does. Same happens with other suggestions made by other people in the GitHub issues about Linux. I really need to learn more about Lazarus. :oops:

All CEF processes create threads and send process messages between them so I guess that all of them should be configured accordingly.
Post Reply