Skip to content

Commit

Permalink
update to CEF 3.1650
Browse files Browse the repository at this point in the history
more cleanup & fixes
  • Loading branch information
dliw committed Jun 5, 2014
1 parent eed38a6 commit 6f20c20
Show file tree
Hide file tree
Showing 18 changed files with 1,715 additions and 937 deletions.
8 changes: 7 additions & 1 deletion Component/cef3.lpk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<Name Value="CEF3"/>
Expand All @@ -21,6 +21,9 @@
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
</Checks>
<Optimizations>
<OptimizationLevel Value="2"/>
</Optimizations>
</CodeGeneration>
<Other>
<CompilerMessages>
Expand Down Expand Up @@ -88,5 +91,8 @@
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<CustomOptions Items="ExternHelp" Version="2">
<_ExternHelp Items="Count"/>
</CustomOptions>
</Package>
</CONFIG>
243 changes: 147 additions & 96 deletions Component/cef3lcl.pas

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Examples/GT2Minimal/minimal.lpi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
Expand Down Expand Up @@ -30,7 +30,6 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
<environment>
<UserOverrides Count="1">
Expand Down
37 changes: 19 additions & 18 deletions Examples/GT2Minimal/minimal.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{$MODE objfpc}{$H+}

Uses
{$IFDEF UNIX}{$IFDEF UseCThreads}cthreads,{$ENDIF}{$ENDIF}
Classes, Glib2, Gdk2, Gtk2,
{$IFDEF UNIX}cthreads,{$ENDIF}
Classes, sysutils, Glib2, Gtk2,
cef3types, cef3lib, cef3api, cef3ref, cef3own;

Var
Expand Down Expand Up @@ -32,7 +32,7 @@ procedure Release(var base : TCefBase);
base.release(@base);
end;

function idle(widget: PGtkWidget): gboolean; cdecl;
function idle(Widget: PGtkWidget): gboolean; cdecl;
begin
cef_do_message_loop_work;

Expand All @@ -41,16 +41,7 @@ function idle(widget: PGtkWidget): gboolean; cdecl;

procedure destroy(Widget: PGtkWidget; Data: gpointer); cdecl;
begin
Host := Browser^.get_host(Browser);
Host^.parent_window_will_close(Host);

Release(Host^.base);
Release(Browser^.base);

gtk_main_quit;
cef_shutdown;

Client.Free;
end;

procedure bclicked(widget : PGtkWidget; data : gpointer); cdecl;
Expand All @@ -59,7 +50,7 @@ procedure bclicked(widget : PGtkWidget; data : gpointer); cdecl;
begin
WriteLn('Reloading...');

Dest := CefString('http://www.google.de');
Dest := CefString('http://youtube.de');
Frame := Browser^.get_main_frame(Browser);
Frame^.load_url(Frame, @Dest);

Expand All @@ -75,12 +66,12 @@ procedure bclicked(widget : PGtkWidget; data : gpointer); cdecl;
ExitCode := cef_execute_process(@MainArgs, nil);
If ExitCode >= 0 then Halt(ExitCode);

Settings.multi_threaded_message_loop := false;
Settings.single_process := true;
Settings.multi_threaded_message_loop := False;
Settings.single_process := False;
Settings.context_safety_implementation := 0;
Settings.log_severity := LOGSEVERITY_VERBOSE;
Settings.log_severity := LOGSEVERITY_INFO;
Settings.uncaught_exception_stack_size := 20;
Settings.release_dcheck_enabled := true;
Settings.release_dcheck_enabled := TRUE;

cef_initialize(@MainArgs, @Settings, nil);

Expand All @@ -103,12 +94,22 @@ procedure bclicked(widget : PGtkWidget; data : gpointer); cdecl;
Client := TCefClientOwn.Create;

URL := CefString('');
Browser := cef_browser_host_create_browser_sync(@info, Client.Wrap, @URL, @BrowserSettings);
Browser := cef_browser_host_create_browser_sync(@info, Client.Wrap, @URL, @BrowserSettings, nil);

g_signal_connect(G_OBJECT(window), 'destroy', G_CALLBACK(@Destroy), nil);
g_idle_add_full(G_PRIORITY_HIGH_IDLE,TGSourceFunc(@idle), Window, nil);

gtk_widget_show_all(Window);

// main loop
gtk_main;

// cleanup
Host := Browser^.get_host(Browser);
Host^.close_browser(Host, 1);

Release(Host^.base);
Release(Browser^.base);

cef_shutdown;
end.
20 changes: 10 additions & 10 deletions Examples/LCLSimple/main.lfm
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
object Mainform: TMainform
Left = 415
Height = 382
Top = 211
Width = 628
Height = 475
Top = 118
Width = 762
Caption = 'Browser -'
ClientHeight = 382
ClientWidth = 628
ClientHeight = 475
ClientWidth = 762
OnCreate = FormCreate
LCLVersion = '1.0.12.0'
LCLVersion = '1.2.2.0'
object Chromium: TChromium
AnchorSideLeft.Control = Owner
AnchorSideTop.Side = asrBottom
Expand All @@ -16,9 +16,9 @@ object Mainform: TMainform
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 334
Height = 427
Top = 48
Width = 628
Width = 762
Anchors = [akTop, akLeft, akRight, akBottom]
DefaultUrl = 'www.google.de'
TabOrder = 0
Expand All @@ -29,7 +29,7 @@ object Mainform: TMainform
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 544
Left = 678
Height = 25
Top = 10
Width = 79
Expand Down Expand Up @@ -60,7 +60,7 @@ object Mainform: TMainform
Left = 38
Height = 25
Top = 10
Width = 501
Width = 635
Anchors = [akTop, akLeft, akRight]
AutoSize = False
BorderSpacing.Left = 5
Expand Down
9 changes: 4 additions & 5 deletions Examples/LCLSimple/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ TMainform = class(TForm)
procedure BGoClick(Sender : TObject);
procedure ChromiumLoadEnd(Sender : TObject; const Browser : ICefBrowser;
const Frame : ICefFrame; httpStatusCode : Integer);
procedure ChromiumTitleChange(Sender : TObject;
const Browser : ICefBrowser; const title : ustring);
procedure EUrlKeyDown(Sender : TObject; var Key : Word;
Shift : TShiftState);
procedure ChromiumTitleChange(Sender : TObject; const Browser : ICefBrowser;
const title : ustring);
procedure EUrlKeyDown(Sender : TObject; var Key : Word; Shift : TShiftState);
procedure FormCreate(Sender : TObject);
private
{ private declarations }
Expand Down Expand Up @@ -63,7 +62,7 @@ procedure TMainform.EUrlKeyDown(Sender : TObject; var Key : Word; Shift : TShift

procedure TMainform.FormCreate(Sender : TObject);
begin
{$INFO Uncomment to use a subprocess}
{$INFO subprocess is set here, comment to use main program as subprocess}
CefBrowserSubprocessPath := '.' + PathDelim + 'subprocess'{$IFDEF WINDOWS}+'.exe'{$ENDIF};
end;

Expand Down
15 changes: 8 additions & 7 deletions Examples/LCLSimple/simple.lpi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
Expand All @@ -23,7 +23,7 @@
<Item1 Name="Linux" Default="True"/>
<Item2 Name="Win32">
<MacroValues Count="1">
<Macro1 Name="LCLWidgetType" Value="win32"/>
<Macro2 Name="LCLWidgetType" Value="win32"/>
</MacroValues>
<CompilerOptions>
<Version Value="11"/>
Expand Down Expand Up @@ -62,12 +62,11 @@
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
<LCLWidgetType Value="win32"/>
</CompilerOptions>
</Item2>
<Item3 Name="Win64">
<MacroValues Count="1">
<Macro1 Name="LCLWidgetType" Value="win32"/>
<Macro2 Name="LCLWidgetType" Value="win32"/>
</MacroValues>
<CompilerOptions>
<Version Value="11"/>
Expand Down Expand Up @@ -106,9 +105,12 @@
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
<LCLWidgetType Value="win32"/>
</CompilerOptions>
</Item3>
<SharedMatrixOptions Count="2">
<Item1 ID="661871476567" Modes="Linux" Type="IDEMacro" MacroName="LCLWidgetType" Value="gtk2"/>
<Item2 ID="279904151772" Modes="Win32,Win64" Type="IDEMacro" MacroName="LCLWidgetType" Value="win32"/>
</SharedMatrixOptions>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
Expand All @@ -118,7 +120,6 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
<environment>
<UserOverrides Count="1">
Expand Down Expand Up @@ -170,6 +171,7 @@
<IOChecks Value="True"/>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
<TargetCPU Value="x86_64"/>
<TargetOS Value="linux"/>
Expand All @@ -187,7 +189,6 @@
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
<LCLWidgetType Value="gtk2"/>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
Expand Down
4 changes: 2 additions & 2 deletions Examples/LCLSimple/simple.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
{$MODE objfpc}{$H+}

Uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
{$IFDEF UNIX}
cthreads,
{$ENDIF}{$ENDIF}
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Main;

Expand Down
Binary file removed Examples/SubProcess/subprocess
Binary file not shown.
2 changes: 1 addition & 1 deletion Examples/WinMinimal/minimal.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function CefWndProc(Wnd: HWND; message: UINT; wParam: Integer; lParam: Integer):
info.Height := rect.bottom - rect.top;
FillChar(setting, sizeof(setting), 0);
setting.size := SizeOf(setting);
CefBrowserHostCreateSync(@info, handl, navigateto, @setting);
CefBrowserHostCreateSync(@info, handl, navigateto, @setting, nil);
SetTimer(Wnd, 1, 100, nil);
result := 0;
end;
Expand Down
54 changes: 38 additions & 16 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ fpCEF3
Chromium Embedded Framework for Free Pascal

## How to get started on
#### [Windows]
### Windows
Download CEF3 from [here][1] and copy all .dll files from either `Debug` or `Release` to the directory your .exe is / will be in.

Install `cef3.lpk` into Lazarus

Look into the examples

#### [Linux]
### Linux
Download CEF3 from [here][1] and copy / link _libcef.so_ (and maybe _libffmpegsumo.so_),
a) to a default library location, eg. `/usr/lib(64)`, `/usr/local/lib(64)` __OR__
b) somewhere and set `LD_LIBRARY_PATH` accordingly
Expand All @@ -20,14 +20,29 @@ Install `cef3.lpk` into Lazarus

Look into the examples

##### Notes
Don't use `--single-process` or change `CefSingleProcess` to `True`. This will trigger a SIGSEGV in pthread_mutex_lock. It's a bug in either CEF3 or Chromium itself: You can find more details [here][4]
#### Notes
Important: make sure you have `cthreads` as the first unit in your main program.

~~Make sure to switch **off** any runtime checks in the project settings:~~
While `-Ci` `-Cr` and `-Co` seem to be ok, it still is better to switch off `-Ct` and `-CR`.
Nevertheless, if crashes occur too often, runtime test should be turned off as a first step.
Also libcef.so needs the resources (folder `locales` and `cef.pak`, you can find them in the CEF package) in the directory your executable is in.

## 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][4]

If crashes occur too often, you might try to turn off runtime checks in the project settings (mainly `-Ct` and `-CR`).

If you're using openSUSE (maybe some other distros, too) and your program crashes immidiately after being started, you could try to execute
```shell
echo 1073741824 > /proc/sys/kernel/shmmax
```
and see if the crash goes away.
That is a known bug in Chromium, which still isn't fixed.

If the browser goes "blank" (e.g. when loading a page), the render process crashed.
Most ot 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.

Also libcef.so needs the resources (folder `locales` and `cef.pak`, you can find them in the CEF package) in the directory where your executable is.

### 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.
Expand All @@ -36,17 +51,25 @@ The preferred way however is to define an own (minimal) subprocess executable.
You can achive 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`. It should work for any use case.
A minimal subprocess can be found in `/Examples/SubProcess`. It should work for any use case.
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][5]

### Debugging
Sometimes it is useful to debug the subprocesses spawned by cef. On Linux this can be done by adding
```shell
--renderer-cmd-prefix='xterm -title renderer -e gdb --args'
```
to the command line.
Further details can be found [here][6].


## FAQ:
### Which versions of CEF are supported?

fpCEF3 only supports CEF3, *no* support for CEF1.
Version 3.1547.1412 (and newer) should work.
fpCEF3 only supports CEF3, *no* support for CEF1.
Version 3.1650 (and newer) should work.

### Which platforms are supported?

Expand All @@ -56,10 +79,8 @@ Version 3.1547.1412 (and newer) should work.
The plain header should be ready for Mac (maybe with small changes), but the component needs to be adopted.

### How stable is fpCEF?
That's hard to say.
On Windows things look good, I didn't have a single crash so far while browsing big websites and running several browser benchmarks.
On Linux there are still crashes, but it seems that they occur less often. Unfortunately CEF3 itself seems to have some serious bugs on its Linux part.

Overall it looks good now, especially the Windows part.
Unfortunately there seem to be bugs in Chromium / CEF3 itself as far as Linux is concerned.

### Is there a documentation for fpCEF?
No, but you can find information in
Expand Down Expand Up @@ -95,4 +116,5 @@ To a certain amount - yes, but don't expect too much.
[2]:http://magpcss.org/ceforum/apidocs3/
[3]:http://code.google.com/p/chromiumembedded/source/browse/#svn%2Ftrunk%2Fcef3%2Ftests%2Fcefclient
[4]:https://code.google.com/p/chromiumembedded/issues/detail?id=976
[5]:https://code.google.com/p/chromiumembedded/wiki/Architecture#CEF3
[5]:https://code.google.com/p/chromiumembedded/wiki/Architecture#CEF3
[6]:https://code.google.com/p/chromium/wiki/LinuxDebugging
Loading

0 comments on commit 6f20c20

Please sign in to comment.