/fpCEF3

Chromium Embedded Framework for Free Pascal

Primary LanguagePascal

fpCEF3

Chromium Embedded Framework for Free Pascal

How to get started

Install cef3.lpk into Lazarus. A good starting point is the LCLSimple project, available in the Examples directory.

Important: All examples use build modes. Make sure to select the correct one, otherwise compilation will fail.

Windows

Download CEF3 from here or here and copy all files from either Debug or Release to the folder your .exe is / will be in.

Linux

You need a build of CEF3 with tcmalloc disabled. The official CEF binaries are suitable.

Copy / link libcef.so,
a) to a default library location, eg. /usr/lib(64), /usr/local/lib(64) or
b) somewhere and set LD_LIBRARY_PATH accordingly

Make sure to include cthreads as the first unit in your main program.

General notes

Apart from the files in the Debug or Release folder, CEF needs the files / folders from the Resources folder. Unless you set CefResourcesDirPath and CefLocalesDirPath, CEF expects them to be in the folder your executable is in.
However in any case icudtl.dat must be in the same folder as the CEF library!

macOS

Download the CEF3 framework from here or here and follow the description on the wiki. Please note that most of the hints and notes in this readme don't apply for macOS.

Hints

Don't use --single-process and don't change CefSingleProcess to True.
This will trigger a SIGSEGV in pthread_mutex_lock, which is a bug in either CEF3 or Chromium itself: You can find more details here.

If the browser goes "blank" (e.g. when loading a page), the render process crashed. Most of the time it seems to be related to JavaScript/V8, see Debugging on how to debug the render process.
Please note, that the render process will be automatically restarted on the next page request.

SubProcess

When initialising CEF for the first time (mostly in your main app) a subprocess is started. By default a second instance of the main program is used as the subprocess. The preferred way however is to define an own (minimal) subprocess executable.

You can achieve this in fpCEF3 by setting CefBrowserSubprocessPath to the path of your subprocess executable. In the LCLSimple example this can be done by changing TMainform.FormCreate at the end of main.pas.

A minimal subprocess can be found in /Examples/SubProcess. Note, that the subprocess also needs the CEF3 library and resources in its path, so the easiest way is to put the subprocess executable in the same folder as the main exe.

More details here

Debugging

Sometimes it is useful to debug the subprocesses spawned by cef. On Linux this can be done by adding

--renderer-cmd-prefix='xterm -title renderer -e gdb --args'

to the command line.
Further details can be found here.

FAQ:

Which versions of CEF are supported?

fpCEF3 only supports CEF3, no support for CEF1.
See changelog or release tag for the currently supported version, other versions (older or newer) may work, but are not recommended.

Which platforms are supported?

  • Windows
  • Linux with GTK2 or QT
  • macOS with Cocoa

Is there a documentation for fpCEF?

No, but you can find information in

  • cef3lib.pas / cef3api.pas
  • the sample programs (admittedly very basic ones)
  • the official api docs here
  • the official cefclient example program here

If you feel like contributing some more Pascal examples - please do.

Can I help?

Of course - patches are always welcome :)

Can you help?

To a certain amount - yes.

Links: