13

Chromium Embedded Framework (http://code.google.com/p/delphichromiumembedded/) is good. I use it to display static HTML, JS and CSS generated from Delphi code only.

But I find it too big.

I need:

  • I need HTML support
  • I need JavaScript support.
  • I need CSS support.
  • I need Unicode support.
  • I need OnNavigate event.

Don't need:

  • I don't need D3D, GDI+, GLES support.
  • I don't need ability to load a web page. LoadString is enough for me.
  • I don't need Locales
  • I don't need Caching
  • I don't need Developer Tools

How I can achieve to have the needed features by having the minimum possible deployment package?

Currently CEF has 40 MB of dlls.

Luboš Turek
  • 5,179
  • 6
  • 39
  • 47
Gad D Lord
  • 6,130
  • 10
  • 50
  • 98
  • Why not use TWebBrowser if you want a small deploy payload – David Heffernan Nov 22 '11 at 08:00
  • @DavidHeffernan - TWebBrowser used to be a moving target, and often they changed things during Windows updates. It was my number one cause for support issues. Do you know how it is nowadays? – Leonardo Herrera Nov 22 '11 at 18:09
  • @LeonardoHerrera Not really an expert. I think so long as you keep it very simple there's no probs and modern IE is more stable and standards compliant. – David Heffernan Nov 22 '11 at 18:27
  • I already use TWebBrowser and I am dissatisfied with its flicker issues (http://stackoverflow.com/questions/6529166/how-do-i-stop-twebbrowser-from-flickering/6529257#6529257) – Gad D Lord Nov 22 '11 at 22:36
  • I personally think this is a valid concern, Even with current technology, there still cases where size is a concern, and we definitely need something to replace WebBrowser2 (windows active x stuff) or similar stuff that basically a drop-in replacemnt to instantly bless all desktop ui with modern browser features. –  Feb 07 '12 at 08:54

2 Answers2

10

About reducing the CEF library size itself, it will need a full rebuilt, and some debugging phase. A lot of time spent, perhaps not worth it - 40 MB is small, according to today's computer power and network bandwidth. I would rather rely on the "official" release of CEF to stay tuned with the latest versions of the browser.

If your issue is about deployment package size and single executable/no install feature, you may consider embedd the dlls inside the exe.

The trick I've used is that the .dll files are stored as zip inside the main .exe, then uncompressed on a private temporary folder on the hard drive (you may want to use the same folder, but it won't work in C:\Program Files due to the Vista/Seven UAC, and your user may wonder where all those files comes frome - that is the reason why I use a private folder).

From the user point of view, there is just one executable file to run. All .dll files are compressed within, and you can also add some non-binary resources to the files (which is not possible with exe/dll compactors). An hidden folder is created and used to load the libraries (which must be loaded with LoadLibrary(), not statically linked), and decompression will be done only once (therefore it will be faster than using an exe/dll compressor).

I've used it for instance to embedded the hunspell.dll library and the English dictionary to our SynProject tool. Code looks like the following:

constructor THunSpell.Create(DictionaryName: string='');
var Temp, HunSpell, Aff, Dic: TFileName;
    i: integer;
begin
  if DictionaryName='' then
    DictionaryName := 'en_US';
  Temp := GetSynopseCommonAppDataPath;
  HunSpell := Temp+'hunspell.dll';
  with TZipRead.Create(HInstance,'Zip','ZIP') do
  try
    Aff := DictionaryName+'.aff';
    if not FileExists(Temp+Aff) then
      StringToFile(Temp+Aff,UnZip(NameToIndex(Aff)));
    Dic := DictionaryName+'.dic';
    if not FileExists(Temp+Dic) then
      StringToFile(Temp+Dic,UnZip(NameToIndex(Dic)));
    if not FileExists(HunSpell) then
      StringToFile(HunSpell,UnZip(NameToIndex('hunspell.dll')));
  finally
    Free;
  end;
  fHunLib := SafeLoadLibrary(HunSpell);
  if fHunLib=0 then
    exit;
  if not LoadEntryPoints then begin
    FreeLibrary(fHunLib);
    fHunLib := 0;
    exit;
  end;
  fDictionaryName := DictionaryName;
  fHunHandle := Hunspell_create(pointer(Temp+Aff),pointer(Temp+Dic));
  if fHunHandle=nil then
    exit;
   (....)
end;

See this link about details and source code.

You may consider using some low-level hack like BTMemoryModule, but you won't have any possible compression.

Community
  • 1
  • 1
Arnaud Bouchez
  • 40,947
  • 3
  • 66
  • 152
  • +1 nice! BTMemoryModule is another thingy with which I would not go... but the resource embedding is a good option! –  Nov 22 '11 at 07:25
  • I use InnoSetup with Lampel-Ziv-Markov compression so dll compression mostly won't be needed. My concerns are mostly of curiosity if possible to use some MACROS (conditional compilation symbols, defines, etc.) to build it myself as a more lean version (like we can do for SQLite for example). – Gad D Lord Nov 22 '11 at 22:41
  • @GadDLord As I wrote in the first part of my post, I would not go in that direction: Chrome is a fine but complex piece of software, and trying to make you own dll [is possible](http://code.google.com/p/chromiumembedded/wiki/ChromiumUpdate) but complex, and there is no such #define to be set to make it lighter, AFAIK from the project source code. You'll have to hack the project source code yourself, and I'm pretty sure it will be a time waste and root of numerous bugs (unless you are a CEF expert). – Arnaud Bouchez Nov 23 '11 at 06:18
3

Depending on the needed features you can just leave out some of the files/DLLs. I tried and could leave out these:

  • avcodec-53.dll
  • avcodec-54.dll
  • avformat-53.dll
  • avformat-54.dll
  • avutil-51.dll
  • ffmpegsumo.dll
  • libEGL.dll
  • libGLESv2.dll
  • cef.pak
  • chrome.pak
  • devtools_resources.pak

I think you'll loose video playback capability and some UI which is not shown if you simple use it to display a website embedded in your application.

Steffen Binas
  • 1,373
  • 16
  • 29
  • How much space did you gain without these libraries? – Muis Apr 08 '14 at 10:17
  • @Muis These files are uncompressed about 11.9 MB, but ZIP compressed only 4 MB...so that is what you gain when distributing your application with an installer. – Steffen Binas Apr 09 '14 at 07:09
  • Eventually I followed your approach and managed to remove avcodec-53.dll, avformat-53.dll, avutil-51.dll, chrome.pak, libEGL.dll, libGLESv2.dll - 4.4 MB saved. That is like 14% of my installer. Great stuff. – Gad D Lord Mar 28 '15 at 21:30
  • Removed also d3dcompiler_43.dll, d3dx9_43.dll - 8.32 MB saved in total. Turned out that the minimum installation with Unicode support is libbcef.dll, icudt.dll and Localed folder - 29.4 MB. – Gad D Lord Mar 28 '15 at 21:48