The Crystal Programming Language Forum

CEF (Chromium Embedded Framework) with crystal?

Hi everyone,

Does anyone have any experience in CEF embedding for a Crystal app ?
In such case, is it possible to build merge the app and the UI down to a single executable ?

Well I must admit this first contact with the crystal community is not what I expected.
If anyone less opinionated have any information about Crystal + CEF I would be happy to hear about it.

Thanks!

One bad apple is not representative of the community. Sorry that had to be your first interaction.

Unfortunately, I’m not too familiar with that project.

2 Likes

Hi @amigrave. I don’t have knowledge of CEF. The most similar thing I envisioned so far is an Electron-ish framework where the server could run a native binary.

If CEF offers some solution to be used in C, then that usually mean that should be doable in Crystal, after some work.

If you have experience with CEF and a bit of C, I bet there can be some initial feedback to make a proof of concept of that if you want.

I’ve experimented with doing a webview wrapper in Crystal. Really any similar solution would be pretty cool.

1 Like

Cool to who? Who will use Chromium with Crystal?

There’s not much difference to using JS, other than the fact that the Crystal would be compiled and much faster.

CEF is written in C++. So by your logic, you are saying it’ll be faster than Crystal after it gets converted?

Le facepalm

No one is talking about converting CEF to Crystal, they’re talking about writing a wrapper for it in Crystal.

1 Like

Not about CEF, Alizarin is a project which lets you make Linux GUI applications using WebkitGTK2+. More than a binding, it proposes a high-level API for easily organizing your code instead of making you messed up with plain C’s binding functions. This library also allows writing JavaScript extensions using Crystal.

1 Like

Thanks @TheEEs, it’s interesting indeed!
I had a look to your markdown editor and it seems Alizarin have the features I need.
I’m not particularly bound to CEF but my requirements are:

  • cross platform (needed)
  • being able to create a single binary containing all the assets (preferably)

If I understand properly Alizarin is not cross platform so unfortunately I can’t use it but thank you for pointing out this project !

1 Like

@amigrave I appreciate your feedback !

Before creating this project, my first choice was CEF. I had to change my mind because:

  • CEF itself is huge (more than 500Mb), packaging and shipping an CEF-based app in a single executable will not be a comfortable experience.

  • Also CEF is developed in C++, that means if you want to have full access to it’s APIs in Crystal, you’ll have to write your own a down-grade version of the library in C. It’ll not be an easy task, too.

  • Although CEF has its own C API, implementing refCounting with that was really a nightmare :crazy_face:

Take a look at Webview. I think it should be the best choice for now.

BTW Crystal binding to Webview are available at Crystal Webview :grinning:

@TheEEs Thanks for pointing webview to me !

@naqvis Thanks for advertising your binding, I will check it right away