Issue #9 open
bchavez
created an issue

Hi there,

I had a few questions:

1) Is this project compatible with Mono / GTK#?
2) If not, are there any blocking issues that would prevent an implementation in GTK? (IE: libcfx.dll requiring a linux/mono build).
3) Any general guidance on how to get a Mono Linux/Mac build working?

Thanks,
Brian

Comments (36)

  1. wborgsm

    A few thoughts:

    • I can already run mono CfxTestBrowser.exe on a windows box provided I define the BrowserSubprocessPath - so the C# stuff seems to work fine with mono, at least with mono for windows.
    • There are a few PInvokes to be made platform independent, mostly LoadLibrary and GetProcAddress - that would be dlopen and friends. And I am not familiar with the workings of DllImport in mono for linux.
    • libcfx.dll - this is pure C and CRT plus some windows stuff, mostly LoadLibrary again. Should be easy to make this platform independent with a few #defines.
    • I don't know much about GTK, but ChromiumFX.dll and libcfx.dll build upon libcef.dll which should take care of those details :). ChromiumWebBrowser.dll needs System.Windows.Forms though.

    All in all, it should not be too hard to make this platform independent. For me, the biggest problem is currently not having a linux box. I wrote this library for a windows only application and don't need a linux version, at least not now. But if people are really interested, I could setup a virtual machine. And if this goes forward, help would be appreciated.

  2. bchavez reporter

    Thanks wborgsm for the info. I'm using a Cross Platform UI toolkit called Eto.Forms (https://github.com/picoe/Eto) and was thinking about possibly writing a ControlHandler for Linux/Mac (GTK) and WinForms to use the underlying ChromiumFx engine. Thank you, your info is helping evaluate what needs to be done to get this to work.

  3. wborgsm

    So far I got an implementation on Ubuntu precise which loads and initializes the native libraries and starts processing the windowless test application, but as soon as it starts rendering, it breaks with an advice "free(): invalid pointer" deep into libcef.so. I really don't know when I will have the time to debug this. Anyway, the code is in the "linux" branch.

  4. wborgsm

    The crash is definitely related to the upstream issue referred in java-cef issue. Reverting to CEF branch 1750 it was possible to build a working windowless prototype on Ubuntu Precise. Further development of the linux branch will have to wait until that issue is resolved.

    The prototype is in the cef-1750 branch, solution linux/CfxLinux.sln.

  5. wborgsm

    If you check out the cef-1750 branch, you will find solution linux/CfxLinux.sln which builds libcfx from the MonoDevelop IDE under Ubuntu Precise (and possibly others). Note that this cross-platform approach is quite outdated since I can't update the branch for the reasons mentioned above.

    Anyway, the libcfx build is quite simple: libcfx.c is the one and only translation unit. It includes all the other c files and the header files. You have to define CFX_LINUX and make sure the compiler can find all the #includes; I think the search paths libcfx/Source, libcfx/Generated and linux/cef should have it all.

    I am waiting for the java-cef issue mentioned above to be resolved before merging the linux stuff into the default branch.

  6. Andrius Bentkus

    I didn't realize that the branch existed, not familiar with the bitbucket UI.

    Are you saying that that branch is functional? That the windowless example is working? What kind of features does it lack?

  7. Andrius Bentkus

    Ok, I just downloaded cef 1750 and put the dynamic libraries in the same directory, but all I get is this exception:

    mono Windowless.exe
    
    Unhandled Exception:
    Chromium.CfxException: Unable to load libcef library /home/bentkus/Projects/mono/chromiumfx/Build/Debug/libcef.so
      at Chromium.CfxApi.Load () [0x00000] in <filename unknown>:0 
      at Chromium.CfxApi.Probe () [0x00000] in <filename unknown>:0 
      at Chromium.CfxRuntime.ExecuteProcess (Chromium.CfxApp application) [0x00000] in <filename unknown>:0 
      at Windowless.Program.Main () [0x00000] in <filename unknown>:0 
    [ERROR] FATAL UNHANDLED EXCEPTION: Chromium.CfxException: Unable to load libcef library /home/bentkus/Projects/mono/chromiumfx/Build/Debug/libcef.so
      at Chromium.CfxApi.Load () [0x00000] in <filename unknown>:0 
      at Chromium.CfxApi.Probe () [0x00000] in <filename unknown>:0 
      at Chromium.CfxRuntime.ExecuteProcess (Chromium.CfxApp application) [0x00000] in <filename unknown>:0 
      at Windowless.Program.Main () [0x00000] in <filename unknown>:0 
    
  8. Andrius Bentkus

    O man, an ldd revealed:

    ldd /home/bentkus/Projects/mono/chromiumfx/Build/Debug/libcef.so
        linux-vdso.so.1 =>  (0x00007fff979ee000)
        libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fcff24ae000)
        libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fcff22a4000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fcff209b000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fcff1e97000)
        libgtk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 (0x00007fcff185b000)
        libgdk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0 (0x00007fcff15a8000)
        libatk-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 (0x00007fcff1386000)
        libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007fcff1179000)
        libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007fcff0f57000)
        libcairo.so.2 => /usr/lib/x86_64-linux-gnu/libcairo.so.2 (0x00007fcff0c4c000)
        libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007fcff09ff000)
        libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fcff075b000)
        libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fcff051f000)
        libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fcff02ce000)
        libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fcfeffc5000)
        libXtst.so.6 => /usr/lib/x86_64-linux-gnu/libXtst.so.6 (0x00007fcfefdbf000)
        libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007fcfefbaf000)
        libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007fcfef9ab000)
        libnss3.so => /usr/lib/x86_64-linux-gnu/libnss3.so (0x00007fcfef671000)
        libnssutil3.so => /usr/lib/x86_64-linux-gnu/libnssutil3.so (0x00007fcfef446000)
        libsmime3.so => /usr/lib/x86_64-linux-gnu/libsmime3.so (0x00007fcfef219000)
        libplc4.so => /usr/lib/x86_64-linux-gnu/libplc4.so (0x00007fcfef014000)
        libnspr4.so => /usr/lib/x86_64-linux-gnu/libnspr4.so (0x00007fcfeedd7000)
        libgconf-2.so.4 => /usr/lib/x86_64-linux-gnu/libgconf-2.so.4 (0x00007fcfeeba7000)
        libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fcfee995000)
        libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007fcfee78f000)
        libasound.so.2 => /usr/lib/x86_64-linux-gnu/libasound.so.2 (0x00007fcfee49e000)
        libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007fcfee29b000)
        libcups.so.2 => /usr/lib/x86_64-linux-gnu/libcups.so.2 (0x00007fcfee027000)
        libgcrypt.so.11 => /lib/x86_64-linux-gnu/libgcrypt.so.11 (0x00007fcfedda6000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fcfedb88000)
        libcap.so.2 => /lib/x86_64-linux-gnu/libcap.so.2 (0x00007fcfed983000)
        libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fcfed758000)
        libudev.so.0 => not found
        libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007fcfed513000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fcfed20e000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcfecf08000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fcfeccf2000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcfec92c000)
        libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fcfec70d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fcff7790000)
        libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007fcfec509000)
        libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007fcfec195000)
        libpangoft2-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007fcfebf80000)
        libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007fcfebd7c000)
        libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007fcfebb72000)
        libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007fcfeb968000)
        libpixman-1.so.0 => /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007fcfeb6be000)
        libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007fcfeb498000)
        libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007fcfeb295000)
        libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007fcfeb08b000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fcfeae72000)
        libthai.so.0 => /usr/lib/x86_64-linux-gnu/libthai.so.0 (0x00007fcfeac69000)
        libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fcfeaa60000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fcfea822000)
        libplds4.so => /usr/lib/x86_64-linux-gnu/libplds4.so (0x00007fcfea61d000)
        libdbus-glib-1.so.2 => /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2 (0x00007fcfea3f6000)
        libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007fcfea1af000)
        libgnutls.so.26 => /usr/lib/x86_64-linux-gnu/libgnutls.so.26 (0x00007fcfe9ef1000)
        libavahi-common.so.3 => /usr/lib/x86_64-linux-gnu/libavahi-common.so.3 (0x00007fcfe9ce5000)
        libavahi-client.so.3 => /usr/lib/x86_64-linux-gnu/libavahi-client.so.3 (0x00007fcfe9ad3000)
        libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fcfe98ce000)
        libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fcfe96c9000)
        libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fcfe94c3000)
        libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fcfe92a0000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fcfe9084000)
        libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007fcfe8e2f000)
        libdatrie.so.1 => /usr/lib/x86_64-linux-gnu/libdatrie.so.1 (0x00007fcfe8c27000)
        libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007fcfe895c000)
        libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007fcfe872d000)
        libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007fcfe8528000)
        libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007fcfe831d000)
        libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007fcfe8109000)
        libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007fcfe7ec6000)
        libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007fcfe7caa000)
        libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007fcfe7aa5000)
    

    It can't find libudev.so.0, I have only 14.04 :(

  9. wborgsm

    Well, I wouldn't say it is functional. As far as I proceeded, the windowless example was kind of working: so far I could load a page and navigate from there. But the RPC layer that connects the render processes to the browser process is missing. The PipeFactory is not implemented for linux. I don't know, maybe the windows implementation with NamedPipeServerStream/NamedPipeClientStream works under mono/linux as well, maybe not.

    Besides that (which was the whole point of making a new c# binding for CEF), it shouldn't lack any features. And getting the pipes to work should be possible as well, it's just that I stopped working on it when I realized that there was an upstream issue preventing me from updating beyond branch 1750. This is far beyond anything I could solve or work around on my own.

  10. Andrius Bentkus

    Yeah, I read your comment about the 2xxx branch throwing exceptions. I just need whatever working version I can get on linux first, so I will take a look at the PipeFactory if the windowless thing runs on 12.04 with the 1750 branch.

    As for that exception, the original author didn't solve it in 6 months, I doubt someone will step up for him.:

  11. wborgsm

    Yeah I forgot: I had to set up 12.04 exactly because of that libudev issue. Search the web for «libudev.so.0 chromium ubuntu» and you'll find a lot of discussion about this. I think this was fixed in newer releases of chromium and CEF, but since I can't update from 1750, that doesn't help for the time being.

  12. Andrius Bentkus

    I got the Windowless example running on 2357.3, though it produces this strange window: http://url.bentkus.eu/n (note that I copied only the content of the window).

    If I click on credits it throws a segmentation fault with:

    $ LD_PRELOAD=/home/bentkus/Projects/mono/chromiumfx/libcef.so mono Windowless.exe 
    [0803/154932:ERROR:browser_main_loop.cc(173)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
    Unknown command line option: '--type=zygote'
    [0803/154934:ERROR:proxy_service_factory.cc(111)] Cannot use V8 Proxy resolver in single process mode.
    [0803/154934:ERROR:gles2_cmd_decoder.cc(11539)] [GroupMarkerNotSet(crbug.com/242999)!:D04E76EE22290000]GL ERROR :GL_INVALID_OPERATION : glTexStorage2DEXT: <- error from previous GL command
    Exception thrown during bootstrapping
    Extension or internal compilation error in native runtime.js at line 2.
    Exception thrown during bootstrapping
    Extension or internal compilation error in native runtime.js at line 2.
    Segmentation fault (core dumped)
    

    I don't really understand why the window pops up, I have to investigate the code first.

  13. Andrius Bentkus

    Ok, I get what you are doing in the windowless example, you create a win32 window, send all the mouse events to libcef and take the drawing buffer from libcef and use it to draw on the window.

  14. wborgsm

    That window is the built-in page for chrome://version/ and the windowless example loads it by default, that's not the problem. But from there, it should bring up the built-in credits page not seg fault when clicking the link.

  15. wborgsm

    Yes basically that's it, it was just a first approach to see something whatsoever at linux. Now since the LD_PRELOAD seems to do the trick, I think I am going to merge the linux solution back into the default branch and go from there as soon as I get some time for it.

    Your help is very appreciated, before trying to port this project I didn't touch linux for years... and back then, I used to run linux servers without a desktop, so I am a bit out of my field here :(

  16. Andrius Bentkus

    The segmentation faults are mainly because "[0803/154934:ERROR:proxy_service_factory.cc(111)] Cannot use V8 Proxy resolver in single process mode.", my own site http://bentkus.eu worked fine, I have to investigate what the V8 Proxy actually does, because it getsx triggered on more complicated sites.

  17. wborgsm

    "single process mode" - I think I had it run in single process (CfxSettings.SingleProcess) mode to avoid the spawning of secondary processes for gpu and renderer. Maybe you can go multiprocess by creating a stub script which does LD_PRELOAD and launches mono and point to that in CfxSettings.BrowserSubprocessPath. The stub will have to pass in all the command line as well.

  18. Andrius Bentkus

    Ok, I have found the error. I used the debug version of natives_blob.bin and snapshot_blob.bin while using the release version of libcef.so. It is working fine now with all websites.

    Stupid me.

    I still find it though seriously freaking strange that it tries to read all the resource files out of /usr/bin/ instead of the local directory where it is executed, i need to copy ffmpegsumo and the bin, pak files to /usr/bin...

  19. wborgsm

    In windows it loads them from the app executable directory by default. Can you change that behavior by explicitly setting CfxSettings.LocalesDirPath and CfxSettings.ResourcesDirPath?

    Note that icudtl.dat is special, it must be where cef looks for executable rather than for resources.

  20. wborgsm

    There is a workable prototype now at revision 37b5c03.

    In order to get this to work, I added a launcher script (linux/windowless) which sets LD_PRELOAD and LD_LIBRARY_PATH and then starts mono.

    Pointing to that launcher in settings.BrowserSubprocessPath enabled multi process execution as well.

    The test app is configured to look up CEF files in cef/Release64 and cef/Resources. Exception: icudtl.dat, snapshot_blob.bin and natives_blob.bin still must be copied to /usr/bin. That is not good and should be fixed. I guess this happens because those files are hard coded to be loaded from the directory where the executable resides, and the executable is /usr/bin/mono.

  21. daveexmachina

    Hi, I followed all these steps and was able to load libraries and assemblies. Now when I try to run "mono Windowless.exe" from shell, I get an error:

    [0902/153211:FATAL:content_main_runner.cc(657)] Check failed: base::allocator::IsAllocatorInitialized(). 
    #0 0x7f386b5348de base::debug::StackTrace::StackTrace()
    #1 0x7f386b548d1b logging::LogMessage::~LogMessage()
    #2 0x7f386e593076 content::ContentMainRunnerImpl::Initialize()
    #3 0x7f386b44268f CefContext::Initialize()
    #4 0x7f386b44248b CefInitialize()
    #5 0x7f386b3e7c56 cef_initialize
    #6 0x7f38604dbbb3 cfx_initialize
    #7 0x00004178f21b <unknown>
    

    How can I solve this?

  22. Germanunkol

    I had this issue yesterday and got rid of it somehow - I believe it was by preloading libcef.so. Have you tried running the "windowless" script instead of the Windowless.exe (assuming you're on Linux?). It preloads the libcef and then starts the Windowless.exe.

  23. daveexmachina

    Ah, thank you very much! I was able to display the page, even though I can't type anything, I can navigate through credits and if I press ctrl+g Google starts. Now for the hard part, have to import on Unity3D

  24. Germanunkol

    I'm trying to do the same, maybe we can join forces :)? I can also compile the Windowless example (on Linux / MonoDevelop) and display the page (I can type, too :)).

    I'm currently stuck on the fact that Unity seems to need the ChromiumFX compiled for Mono / .NET 3.5. On Linux, it seems that I can't have Mono 3.5 and 4.5 installed at the same time. So I tried it on windows, but there, I'm having troubles compiling both with MonoDevelop and with VS (don't remember the exact issues right now and I'm on Linux atm so I can't check).

    I don't want to further hijack this thread, but if you want, feel free to contact me: germanunkol[at]yahoo.com, or we could open a new issue for Unity3D integration?

  25. azraelrabbit

    hello,
    i have make the current default branch working on linux with mono.

    But ChromiumWebBrowser.cs still does not support fcitx / ibus input method, it seems that the CEF framework bug. here: https://bitbucket.org/chromiumembedded/cef/issues/1813/cef-does-not-work-with-imes-on-linux

    And The WindowLess.cs can run correct in linux with mono for now,and input method support normally.

    While modifying part of the code, so that can be compiled with linux with monodevelop 5.10.

    and merged some code from pull request :https://bitbucket.org/chromiumfx/chromiumfx/pull-requests/2/default/diff

    And i created new solution file : ChromiumFX-Mono.sln to support monodevelop. and the origin solution on windows still run normal.

    my fork: https://bitbucket.org/azraelrabbit/chromiumfx

    PS:

    1. i just run correct in linux mint 17/18 x64 and ubuntu 16.04 x64 , other linux distributions are not tested.

    2. to compile in linux ,you must be use monodevelop 5.10,not 6.x or above, because since 6.x the monodevelop does not support c/c++ projects.

    3. sorry for my english is not very good.

    For Chinese:

    我从Default 分支 Fork (https://bitbucket.org/azraelrabbit/chromiumfx) 最新的代码,

    合并了部分代码从 pull request : https://bitbucket.org/chromiumfx/chromiumfx/pull-requests/2/default/diff

    修改部分平台适配代码,目前能正常运行在 linux下,并且可通过monodevelop 编译.

    但ChromiumWebBrowser.cs目前不支持任何输入法,测试过了fcitx.貌似是 CEF 源框架的bug,参见: https://bitbucket.org/chromiumembedded/cef/issues/1813/cef-does-not-work-with-imes-on-linux

    另外 WindowLess.cs 调整部分代码后,也可正常运行在 linux 和mono 环境下,输入法支持也正常.

    为了从monodevelop 打开解决方案,我创建了新的解决方案: ChromiumFx-Mono.sln, 不会影响原解决方案在windows下的编译和使用.

    PS:

    1. 我只在 linux mint 17/18 x64 和 Ubuntu 16.04 x64 下测试通过,其他 linux 发行版未测试.

    2. 在Linux 下,只能使用 monodevelop 5.10 打开并编译libcfx 工程,因为从 6.x 起,monodevelop 不再支持 c/c++工程的打开和编译.

  26. Log in to comment