How to have the minimum size possible Chromium Embedded Framework dlls
Solution 1
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.
Solution 2
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 dll
s 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.
Related videos on Youtube
Gad D Lord
I am a software developer coding in: Dart, Flutter, JavaScript, Delphi, PowerShell, C#, Python. I run a microISV company mtg.studio Ltd. which is focused on Magic: the Gathering card game tools. https://www.mtgstudio.com http://www.makedeck.com
Updated on June 04, 2022Comments
-
Gad D Lord over 1 year
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.
-
Maestro over 9 yearsHow much space did you gain without these libraries?
-
Steffen Binas over 9 years@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.
-
Gad D Lord over 8 yearsEventually 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 over 8 yearsRemoved 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.