Giter VIP home page Giter VIP logo

cefglue's Introduction

CefGlue

.NET binding for The Chromium Embedded Framework (CEF).

CefGlue lets you embed Chromium in .NET apps. It is a .NET wrapper control around the Chromium Embedded Framework (CEF). It can be used from C# or any other CLR language and provides both Avalonia and WPF web browser control implementations.

Here's a table for supported architectures, frameworks and operating systems:

OS x64 ARM64 WPF Avalonia
Windows ✔️ ✔️ ✔️ ✔️
macOS ✔️ ✔️ ✔️
Linux ✔️ 🔘 ✔️

✔️ Supported ❌ Not supported 🔘 Works with issues.

See LINUX.md for more information about issues and tested distribution list.

Currently only x64 and ARM64 architectures are supported.

Releases

Stable binaries are released on NuGet, and contain everything you need to embed Chromium in your .NET/CLR application.

  • CefGlue.Avalonia
  • CefGlue.Avalonia.ARM64
  • CefGlue.Common
  • CefGlue.Common.ARM64
  • CefGlue.WPF
  • CefGlue.WPF.ARM64

Documentation

See the Avalonia sample or WPF sample projects for example web browsers built with CefGlue. They demo some of the available features.

cefglue's People

Contributors

adeewu avatar alvesmiguel1 avatar azeno avatar bananarush avatar brunocunhasilva avatar cangosta avatar carlosmiei avatar dmitry-azaraev avatar etruong42 avatar fmgracias avatar haltroy avatar heldergoncalves92 avatar igor-ruivo avatar j-d-t avatar jmano avatar joaompneves avatar mattwill09 avatar mmv avatar mpm-os avatar nielsad avatar os-filipecampos avatar osesantos avatar pablomarc avatar pedrolemasantos avatar plemasantos avatar tbragaf avatar tobiasviehweger avatar vivokas20 avatar walterlv avatar wiks00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cefglue's Issues

App Crash on Windows with Avalonia 11 preview6 version

Hello @joaompneves,

after integrating CefGlue into an Avalonia 11 Preview6 xplat app, on macOS everything works like expected. Unfortunately on the main target platform Windows 10 the App crashes without saying a word (in the debugger as well as in release mode) - it's just gone.

I'm pretty sure that this has to do with CefGlue, because if I comment out ONLY theBrowserView I created with CefGlue, everything works like expected.

Since the App I'm working on is not open source, I'll try to provide a minimal example to reproduce the bug in the next days. Until then, here is the BrowserView Control code.

May be important, that two of the controls may be loading at the same time...

Are you able to test on Windows?

<!-- BrowserView.axaml -->
<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:browser="clr-namespace:MyApp.Controls.Browser"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="MyApp.Controls.Browser.BrowserView"
             x:DataType="browser:BrowserView"
             >
    <Decorator x:Name="BrowserWrapper" IsVisible="{Binding IsBrowserVisible}"/>
</UserControl>
// BrowserView.axaml.cs

using System;
using System.Windows.Input;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Xilium.CefGlue.Avalonia;
using Xilium.CefGlue.Common.Events;

namespace MyApp.Controls.Browser;


public partial class BrowserView : UserControl, IDisposable
{
    public static readonly StyledProperty<ICommand?> UrlChangedCommandProperty =
        AvaloniaProperty.Register<BrowserView, ICommand?>(nameof(UrlChangedCommand), enableDataValidation: true);


    public ICommand? UrlChangedCommand
    {
        get => GetValue(UrlChangedCommandProperty);
        set => SetValue(UrlChangedCommandProperty, value);
    }


    public static Func<AvaloniaCefBrowser>? CreateBrowser = null;

    private AvaloniaCefBrowser? _browser;

    public bool IsBrowserVisible => !_isLoading && string.IsNullOrEmpty(Message);

    public string Message { get; set; } = "";

    private bool _isLoading;

    public static readonly StyledProperty<string>
        UrlProperty = // todo remove static keyword to allow multiple instances?
            AvaloniaProperty.Register<BrowserView, string>(
                nameof(Url),
                defaultValue: "about:blank");

    public string Url
    {
        get => GetValue(UrlProperty);
        set => SetValue(UrlProperty, value);
    }

    public BrowserView()
    {
        InitializeComponent();
    }



    protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
    {
        base.OnPropertyChanged(change);
        if (change.Property == UrlProperty && _browser != null /* && _browser.Address != Url*/)
        {
            if (_browser.Address == Url)
            {
                _browser.Reload();
            }
            else
            {
                _browser.Address = Url;
            }
        }
    }

    private void InitializeComponent()
    {
        AvaloniaXamlLoader.Load(this);
        var browserWrapper = this.FindControl<Decorator>("BrowserWrapper");

        if (browserWrapper == null)
        {
            return;
        }

        Console.WriteLine("Initialize BrowserView: " + Url);

        _browser = new AvaloniaCefBrowser();
        _browser.Address = Url;
        _browser.LoadStart += OnBrowserLoadStart;
        _browser.LoadEnd += OnBrowserLoadEnd;
        
        _browser.LoadError += OnBrowserLoadError;
        _browser.TitleChanged += OnTitleChanged;
        browserWrapper.Child = _browser;
    }

    private void OnBrowserLoadStart(object sender, LoadStartEventArgs e)
    {
        if (e.Frame.Browser.IsPopup || !e.Frame.IsMain)
        {
            return;
        }

        _isLoading = true;
        Message = "";
    }

    private void OnBrowserLoadError(object sender, LoadErrorEventArgs e)
    {
        _isLoading = false;
        Message = $"Could not load {e.FailedUrl}: {e.ErrorText} ({e.ErrorCode})";
    }

    private void OnBrowserLoadEnd(object sender, LoadEndEventArgs e)
    {
        _isLoading = false;
        if (_browser != null && Url != _browser.Address)
        {
            if (UrlChangedCommand?.CanExecute(_browser.Address) ?? false)
            {
                UrlChangedCommand?.Execute(_browser.Address);
            }
        }
    }

    private void OnTitleChanged(object sender, string title)
    {
        _isLoading = false;
    }

    public void Dispose()
    {
        _browser?.Dispose();
    }
}

Make UnderlyingBrowser public

Unless I'm missing something, there's currently no way how to read page source and text other than executing JS to get that data. From what I can tell, this could be done directly via main frame from UnderlyingBrowser property, which is currently marked as protected.

Can this be made public so we can get access to more page data functionality if we need it? Or is there some other way to get page frame?

Crash in CefGlue.Demo.WPF

Running a debug build of CefGlue.Demo.WPF from a CEFGlue clone crashes with an access violation in libcef.dll in the CefUIThread.

It is using .NET8 on Windows 10

This may have something to do with something I observed in another project: the Xilium.CefGlue.BrowserProcess is not started.

However, in that case Xilium.CefGlue.BrowserProcess was not even in the generated output. When I copied Xilium.CefGlue.BrowserProcess manually it had a result similar to the one in CefGlue.Demo.WPF.

the browser in the program displays a blank page without triggering the LoadStart event.

I use CefGlue.Avalonia in Debian 10. the AvaloniaCefBrowser in the program displays a blank page without triggering the LoadStart event.

this is CefGlue code :

internal sealed class ActionTask : CefTask
{
private Action _action;
public ActionTask(Action action)
{
_action = action;
}

    protected override void Execute()
    {
        _action();
        _action = null;
    }

    public static void Run(Action action, CefThreadId threadId = CefThreadId.UI)
    {
        CefRuntime.PostTask(threadId, new ActionTask(action));
    }
}

I found that:
CefRuntime.PostTask(threadId, new ActionTask(action))
the code was executed and returned true, but the code in the Action was not executed.

Documentation for the extra .targets

Do I need any kind of special setup for extra properties defined in samples like

<CFBundleName>Xilium.CefGlue.Demo.Avalonia</CFBundleName> <!-- Also defines .app file name -->
<CFBundleDisplayName>CefGlueDemoAvalonia</CFBundleDisplayName>

They seem to be used by custom .targets. Do I need to set them using NuGet? What are their effects?

Chrome runtime support

Im using custom cefsharp to create several native chrome ui windows and recently there was a question of switching to a cross-platform solution, avalonia + cefglue with ChromeRuntime = true - always crashes on cef initialization without any log, also tried to update to 126v - nothing changed. Is there any plans to update CEF to the latest version(chrome bootstrap etc)? Thanks

CEF binaries with proprietary codecs (video support)

Can i use CEF with codecs? I was compiling last 117 cef. But it's version not match with CefGlue version. Last version is 117.2.5.0 but this library use 117.2.4.0 and i can't replace libcef.dll in my project, it's just crashes. Is there any way to enable codecs? I need to play a video

Avalonia Control Rendering Issue(s)

AvaloniaCefBrowser is currently not rendering in way that allows for it to be treated like other controls. It is always showing above other Controls (not respecting ZIndex) and will render in full outside the bounds that the control occupies.

An example of this issue is having a Grid with a header row and a ScrollViewer in a separate row. When this ScrollViewer is moved to a position where the AvaloniaCefBrowser should be out of view or cut due to the bounds on the grid row, it instead shows over the header row. This is not the case for other controls.

A straightforward way to demonstrate this issue is to overlay a panel/border on top of the AvaloniaCefBrowser. It will always be hidden by the AvaloniaCefBrowser. The only way I have found to render a control on top of an AvaloniaCefBrower is to use a flyout/popout.

Another way to demonstrate this issue is to wrap the AvaloniaCefBrowser with a Border with ClipToBounds set to true and reduce the size of the border to less than the control, or to introduce a corner radius that would cut parts of the corners. These changes will not impact the AvaloniaCefBrowser as they would any other control.

This issue currently limits use of the AvaloniaCefBrowser to being static position within a window.

Another issue, which may be related is that when scrolling a view with an AvaloniaCefBrowser, it doesn't move in sync with other controls. Interestingly it moves ahead of other controls.

I'm going to take a look through the repo to better understand this, but wanted to flag it first incase others can provide comments/guidance.

  • OSX (ARM64)
  • Avalonia 11.0.0 & 11.0.2
  • CefGlue.Avalonia 106.5249.19-avalonia11

Avalonia 11.0.6 in macos input

Unable to enter text on macos x64 after setting WindowlessRenderingEnabled to true. Switching to the Chinese input method at the same time will cause the program to crash.
CefGlue.Avalonia version:117.5938.2-avalonia11
image

CefGlue.Common nuget package: NLog dependency

The CefGlue.Common 106.5249.21 nuget package has a dependency on NLog.

But CefGlue.Common does not seem to be using NLog. As far as i can tell by inspecting the source and build files, any NLog-related code is gated by an HAS_NLOG symbol that however appears to be undefined. Which is also supported by my observation that Visual Studio's IntelliSense does not offer the Xilium.CefGlue.Common.Helpers.Logger.ILogInitializer and Xilium.CefGlue.Common.Helpers.Logger.NLogLogger types in a project using the CefGlue.Common 106.5249.21 nuget package.

This and the comment in:

// NLog dependency was removed.
#if HAS_NLOG

strongly suggests that the NLog dependency of the CefGlue.Common nuget package is in error.

Crash on initialize

I've been trying to use this project, but I kept getting a crash during initialization. I decided to try the CefGlue.Demo.Avalonia project, only to get the exact same error:

[0621/161205.002:WARNING:resource_util.cc(94)] Please customize CefSettings.root_cache_path for your application. Use of the default value may lead to unintended process singleton behavior.
[0621/161205.003:WARNING:resource_bundle.cc(464)] locale_file_path.empty() for locale 
[0621/161205.003:ERROR:alloy_main_delegate.cc(716)] Could not load locale pak for en-US
[0621/161205.007:WARNING:resource_bundle.cc(1199)] locale resources are not loaded

This occurs with a freshly cloned version of the current repository with no changes.
This is on Windows 11, dotnet core 8.0.

Cannot pass Command Line Arguments to CEF Initialize

I need to give an command line argument to CEF, but it is currently not possible to do that in the Program initialize.

CefRuntimeLoader.cs: 66
CefRuntime.Initialize(new CefMainArgs(new string[0]), settings, new BrowserCefApp(customSchemes, flags, browserProcessHandler), IntPtr.Zero);
Here an empty array gets passed, where command line arguments are normally passed through.

avalonia 11.0.4

When using this on avalonia 11.0.4 I have this problem :
System.IO.FileNotFoundException: 'Could not load file or assembly "Avalonia.Visuals, Version=0.10.17.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b". The specified file could not be found.'

Relationship between Xilium.CefGlue and OutSystems.CefGlue

Since both Xilium.CefGlue and OutSystems.CefGlue appear to be actively maintained repositories with a common history, I'm curious if there's a stated difference between the two. What was Xilium not able to offer that lead to OutSystems forking, and what is Xilium trying to maintain that OutSystems does not? Having just scratched the surface of the repos, it seems like OutSystems is favouring newer technologies while Xilium is trying to maintain support for existing consumers.

My particular interest in this is because I've recently been tasked with uplifting an internal application using an old Xilium.CefGlue version. I'm wondering whether I should keep using Xilium (appealing with WinForms support and potentially easier .NET 4.5 targetting), or switch to OutSystems (though I would need to put in work to make it compatible with our application).

Sorry to drag you over here @dmitry-azaraev, but I'd be grateful for any input from the Xilium side of things too.

Offscreen rendering trouble

For off-screen rendering I use CefClient with custom CefRenderHandler.
But after upgrade from CefGlue.Common from 91.4472.29 to 106.5249.7 Xilium.CefGlue.BrowserProcess.exe start crashing.
After some investigation i found that trouble in CrashPipeNameKey
If this variable not provided - browser process is crashing.
Unfortunately, the CreateBrowser API did not require this before, and you can guess what went wrong only after cloning the repository and replacing the nuget-provided files with a self-compiled one, which is not the first thing to do.
So for workaround need to replace
CefBrowserHost.CreateBrowser(cefWindowInfo, this, cefBrowserSettings, url);
with
const string CrashPipeNameKey = "CrashPipeName";'
using (var extraInfo = CefDictionaryValue.Create())
{
// send the name of the crash (side) pipe to the render process
var crashServerPipeName = Guid.NewGuid().ToString();
extraInfo.SetString(CrashPipeNameKey, crashServerPipeName);
CefBrowserHost.CreateBrowser(cefWindowInfo, this, cefBrowserSettings, url, extraInfo, RequestContext);
}

video not playing from local html file

video is not playing from opened html file with video tag and src from the same local directory. only white screen is displayed but works with images.

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:vlc="clr-namespace:LibVLCSharp.Avalonia;assembly=LibVLCSharp.Avalonia"
        xmlns:webview="clr-namespace:WebViewControl;assembly=WebViewControl.Avalonia"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="testAdsUI.MainWindow"
        WindowStartupLocation="Manual"
        Title="testAdsUI">
    <DockPanel Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
      <webview:WebView x:Name="webview" Address="{Binding CurrentAddress}"  />
    </DockPanel>
</Window>
<!DOCTYPE html> 
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="video-container">
<video 
src="4114185-hd_1920_1080_25fps.mp4"        
	  autoplay="true"
      muted="muted"
      width="100%"
      height="100%"
      style="object-fit: contain;" > 
</video>
</div>
</body>
</html> 

Avalonia adorner

Hello, the browser part of my application is blocking the avalonia adorner. How can I display the avalonia adorner on top of the browser?
Avalonia version: 10.22

cef.redist.x64

I use cef.redist.x64 to 116.0.15
Xilium.CefGlue.CefVersionMismatchException: 'CEF runtime version mismatch: loaded version API hash "1091d9b7f17abbbf86cbbf50db7106a2bad98ab5", but supported "95bf7fa1356070be95b7a6fee958355c6619fb63" (106.0.26+ge105400+chromium-106.0.5249.91).'

how i can fix it ?

This browser or app may not be secure

When I run the demo and go to google's calendar and try to log in it won't work.

Any idea how to trick google into trusting this browser?

Couldn't sign you in

This browser or app may not be secure. Learn more
Try using a different browser. If you're already using a
supported browser, you can try again to sign in.

image

Publishing new version of cef.redist.linux.x64?

I've been experimenting with the Linux PR (a good learning process on the challenges of .NET Core) and merged in the latest changes from main to my local branch, but I found that there isn't a NuGet package of cef.redist.linux.x64 for version 120.2.4. Any chance you could publish one to NuGet?

I also noticed that there was a missing file (libvulkan.so.1) that is included in the cef binary releases but not in the NuGet package -- if that file is not present, the cefsample app won't run on the same Linux system where I'm trying to use the CefGlue.Demo.Avalonia app (unsuccessfully so far -- made some progress, but still not enough to actually get the app to fully load).

Child window doesn't load correctly

Hi there,

When trying to login to twitter via apple account, the browser opens a child window to process the authentication. But in the Avalonia demo example, the child window doesn't load the url. See the attached screencast below:

Kapture 2024-04-04 at 18 23 58

Is this a known issue?

Migration path to Avalonia 11

Hey there,

I tried to build a Project with Avalonia 11 but unfortunately it did not work, because there are still dependencies requiring Avalonia Styles 0.10.x.

I would really appreciate a migration path to Avalonia 11 - and am willing to help, unfortunately I don't know what would be the migration path and which files I need to change to make the project compatible.

This issue may be releated to OutSystems/WebView#303, but I think this is the right project to report this.

Thank you!

CefGlue.WPF build problem

When building a project using CefGlue.WPF, the CefGlueBrowserProcess directory is not created in the output directory.

Are there any plans to upgrade the Chromium build 91.0.4472.77 ?

Hi.
As far as I can see, the current implementation uses Chromium build 91.0.4472.77 .
Our product uses ChromiumFX (CEF 3.3440 / Chromium 68.0.3440) and due to some vulnerabilities in that Chromium version, we have to upgrade to 98.0.4758 or higher.

Are there any plans to upgrade, in CefGlue, the Chromium build from 91.0.4472.77 to 98.0.4758 or higher?

Thank you. Kind regards.

Is there documentation of what the features are and the API?

Is there documentation of what the features are and the API? The documentation seems to be just a couple of samples which means someone has to know Avalonia or WFP and dig in the code. Does the code use every feature and API?
I would have preferred to see real documentation.

Problems opening a dialog which contains the CefBrowser

I'm currently trying to replace CefNet with CefGlue. What did I do?

  1. I made a Test-App to get a proper implementation of CefGlue inside a brand new Avalonia-App.
    This can be found here: https://github.com/AlexanderDotH/WebViewTest

The Test-App works fine.

  1. Now I implemented it into my Main-App:
    https://github.com/AlexanderDotH/OpenLyricsClient/blob/2881a90b34b7cb9a4c6ea5e71d47f6c7041fcb3d/OpenLyricsClient/External/CefNet/View/CefAuthWindow.axaml.cs#L37

Now when I try to open the Window with the exact same logic I get the following Exception:

System.InvalidOperationException: Unable to create child window for native control host. Application manifest with supported OS list might be required.
at Avalonia.Win32.Win32NativeControlHost.DumbWindow..ctor(Boolean layered, Nullable1 parent) in /_/src/Windows/Avalonia.Win32/Win32NativeControlHost.cs:line 99 at Avalonia.Win32.Win32NativeControlHost.CreateNewAttachment(Func2 create) in //src/Windows/Avalonia.Win32/Win32NativeControlHost.cs:line 35
at Avalonia.Controls.NativeControlHost.UpdateHost() in /
/src/Avalonia.Controls/NativeControlHost.cs:line 95
at Avalonia.Controls.NativeControlHost.OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) in //src/Avalonia.Controls/NativeControlHost.cs:line 35
at Avalonia.Visual.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e) in /
/src/Avalonia.Visuals/Visual.cs:line 403
at Avalonia.Layout.Layoutable.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e) in //src/Avalonia.Layout/Layoutable.cs:line 743
at Avalonia.Input.InputElement.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e) in /
/src/Avalonia.Input/InputElement.cs:line 509
at Avalonia.Controls.Control.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e) in //src/Avalonia.Controls/Control.cs:line 174
at Avalonia.Visual.SetVisualParent(Visual value) in /
/src/Avalonia.Visuals/Visual.cs:line 604
at Avalonia.Visual.SetVisualParent(IList children, Visual parent) in //src/Avalonia.Visuals/Visual.cs:line 642
at Avalonia.Visual.VisualChildrenChanged(Object sender, NotifyCollectionChangedEventArgs e) in /
/src/Avalonia.Visuals/Visual.cs:line 622
at Avalonia.Collections.AvaloniaList1.NotifyAdd(T item, Int32 index) in /_/src/Avalonia.Base/Collections/AvaloniaList.cs:line 687 at Avalonia.Collections.AvaloniaList1.Add(T item) in //src/Avalonia.Base/Collections/AvaloniaList.cs:line 205
at Xilium.CefGlue.Avalonia.Platform.AvaloniaControl.SetContent(Control content)
at Xilium.CefGlue.Avalonia.Platform.AvaloniaControl.b__18_0()
at Avalonia.Threading.JobRunner.Job.Avalonia.Threading.JobRunner.IJob.Run() in /
/src/Avalonia.Base/Threading/JobRunner.cs:line 181
at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) in //src/Avalonia.Base/Threading/JobRunner.cs:line 37
at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in /
/src/Windows/Avalonia.Win32/Win32Platform.cs:line 263
at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) in //src/Windows/Avalonia.Win32/Win32Platform.cs:line 210
at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in /
/src/Avalonia.Base/Threading/Dispatcher.cs:line 65
at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in //src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 120
at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /
/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 209
at OpenLyricsClient.Program.Main(String[] args) in C:\Users\alexander.heuschkel\RiderProjects\OpenLyricsClient\OpenLyricsClient\Program.cs:line 24

What did I do trying to fix it?

  1. Opened the Window directly without the fancy backend logic. Same Issue
  2. Created an entire new Window which contains the same logic as the Test-App. Same Issue
  3. Checked the Program.cs which was nearly the same as the Test-App. Found nothing noticable.
  4. Invoked the creation of the window to the dispatcher by using Dispatcher.UiThread.invoke. Same Issue.
  5. Changed the .net version from 6.0 to 7.0 like in the Test-App. Same Issue

I actually don't know how to fix it. I reached the point where I entirely remove the webview-feature from my program.

Doesn't work as expected with Apple M* chip

Hello, the browser part of my application works properly on my MacOS computer with Intel chip and Windows operating system, but unfortunately, with the Apple M1 chip, I receive an runtime exception like the one below:

2023-09-21 16:37:30.804 +03:00 [ERR] Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Xilium.CefGlue.Avalonia, Version=106.5249.19.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

File name: 'Xilium.CefGlue.Avalonia, Version=106.5249.19.0, Culture=neutral, PublicKeyToken=null'
   at MyApp.UI.Views.MainArea.Browser.BrowserView..ctor()
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
   --- End of inner exception stack trace ---
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
   at MyApp.UI.Services.ViewCreationService.CreateViewByViewModelType(IServiceProvider serviceProvider, Type viewModelType, Object viewModel) in /MyAppPath/src/MyApp.UI.Views/Services/ViewCreationService.cs:line 46
   at MyApp.UI.Services.ViewCreationService.CreateViewByViewModelType(IServiceProvider serviceProvider, Type viewModelType, Action`1 configureViewModel) in /MyAppPath/src/MyApp.UI.Views/Services/ViewCreationService.cs:line 21
   at MyApp.UI.ViewModels.MainArea.BrowserViewModel.OpenWebPageInNewTab(String url, String name) in /MyAppPath/src/MyApp.UI.ViewModels/UI/ViewModels/MainArea/BrowserViewModel.cs:line 164
   at MyApp.UI.ViewModels.MainArea.BrowserViewModel.CreateEmptyTab() in /MyAppPath/src/MyApp.UI.ViewModels/UI/ViewModels/MainArea/BrowserViewModel.cs:line 133
   at ReactiveUI.ReactiveCommand.<>c__DisplayClass0_0.<Create>b__1(IObserver`1 observer) in /_/src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs:line 105
   at System.Reactive.Linq.QueryLanguage.CreateWithDisposableObservable`1.SubscribeCore(IObserver`1 observer)
   at System.Reactive.ObservableBase`1.Subscribe(IObserver`1 observer)

If I use the CefGlue.Avalonia.ARM64 package, I get a build error like the one below:


2023-09-19 20:18:49.726 +03:00 [ERR] Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeInitializationException: The type initializer for 'Xilium.CefGlue.Avalonia.AvaloniaCefBrowser' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'libcef' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: 
dlopen(/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/libcef.dylib, 0x0001): tried: '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/libcef.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/libcef.dylib' (no such file), '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/libcef.dylib' (no such file)
dlopen(/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/libcef.dylib, 0x0001): tried: '/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/libcef.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/libcef.dylib' (no such file), '/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/libcef.dylib' (no such file)
dlopen(/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/libcef.dylib, 0x0001): tried: '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/libcef.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/libcef.dylib' (no such file), '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/libcef.dylib' (no such file)
dlopen(libcef.dylib, 0x0001): tried: 'libcef.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcef.dylib' (no such file), '/usr/lib/libcef.dylib' (no such file, not in dyld cache), 'libcef.dylib' (no such file), '/usr/local/lib/libcef.dylib' (no such file), '/usr/lib/libcef.dylib' (no such file, not in dyld cache)
dlopen(/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/liblibcef.dylib, 0x0001): tried: '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/liblibcef.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/liblibcef.dylib' (no such file), '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/liblibcef.dylib' (no such file)
dlopen(/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/liblibcef.dylib, 0x0001): tried: '/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/liblibcef.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/liblibcef.dylib' (no such file), '/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/liblibcef.dylib' (no such file)
dlopen(/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/liblibcef.dylib, 0x0001): tried: '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/liblibcef.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/liblibcef.dylib' (no such file), '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/liblibcef.dylib' (no such file)
dlopen(liblibcef.dylib, 0x0001): tried: 'liblibcef.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSliblibcef.dylib' (no such file), '/usr/lib/liblibcef.dylib' (no such file, not in dyld cache), 'liblibcef.dylib' (no such file), '/usr/local/lib/liblibcef.dylib' (no such file), '/usr/lib/liblibcef.dylib' (no such file, not in dyld cache)
dlopen(/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/libcef, 0x0001): tried: '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/libcef' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/libcef' (no such file), '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/libcef' (no such file)
dlopen(/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/libcef, 0x0001): tried: '/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/libcef' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/libcef' (no such file), '/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/libcef' (no such file)
dlopen(/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/libcef, 0x0001): tried: '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/libcef' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/libcef' (no such file), '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/libcef' (no such file)
dlopen(libcef, 0x0001): tried: 'libcef' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcef' (no such file), '/usr/lib/libcef' (no such file, not in dyld cache), 'libcef' (no such file), '/usr/local/lib/libcef' (no such file), '/usr/lib/libcef' (no such file, not in dyld cache)
dlopen(/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/liblibcef, 0x0001): tried: '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/liblibcef' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/liblibcef' (no such file), '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/runtimes/osx/native/liblibcef' (no such file)
dlopen(/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/liblibcef, 0x0001): tried: '/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/liblibcef' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/liblibcef' (no such file), '/Users/berkan/.dotnet/shared/Microsoft.NETCore.App/7.0.7/liblibcef' (no such file)
dlopen(/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/liblibcef, 0x0001): tried: '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/liblibcef' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/liblibcef' (no such file), '/MyAppPath/src/MyApp.UI.Host/bin/Debug/net7.0/liblibcef' (no such file)
dlopen(liblibcef, 0x0001): tried: 'liblibcef' (no such file), '/System/Volumes/Preboot/Cryptexes/OSliblibcef' (no such file), '/usr/lib/liblibcef' (no such file, not in dyld cache), 'liblibcef' (no such file), '/usr/local/lib/liblibcef' (no such file), '/usr/lib/liblibcef' (no such file, not in dyld cache)




Avolonia Version: 11.0.0
CefGlue.Avalonia$(CefGluePackageSuffix) Version: 106.5249.19-avalonia11

~ $ dotnet --info
.NET SDK:
 Version:   7.0.400
 Commit:    73bf45718d

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.4
 OS Platform: Darwin
 RID:         osx.13-arm64
 Base Path:   /usr/local/share/dotnet/sdk/7.0.400/

Host:
  Version:      7.0.10
  Architecture: arm64
  Commit:       a6dbb800a4

.NET SDKs installed:
  6.0.413 [/usr/local/share/dotnet/sdk]
  7.0.400 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.21 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.21 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/usr/local/share/dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Avalonia upgrade to v11

MenuBase MenuClosed -> Closed System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'Void Avalonia.Controls.MenuBase.add_MenuClosed(System.EventHandler`1<Avalonia.Interactivity.RoutedEventArgs>)'.
Source=Xilium.CefGlue.Avalonia
StackTrace:
在 Xilium.CefGlue.Avalonia.Platform.AvaloniaControl.<>c__DisplayClass15_0.b__0()
在 Avalonia.Threading.DispatcherOperation.InvokeCore()
在 Avalonia.Threading.DispatcherOperation.Execute()
在 Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
在 Avalonia.Threading.Dispatcher.ExecuteJobsCore()
在 Avalonia.Threading.Dispatcher.Signaled()
在 Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
在 Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
在 Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken)
在 Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
在 Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
在 Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
在 Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
在 Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode)
在 avaTest.Program.Main(String[] args) 在 D:\Virtual Machines\Shared\avaTestNonCef\Program.cs 中: 第 16 行

Avalonia v11 Error

Hey!

I've been trying to update my Avalonia App to v11 and along with that also the CefGlue package. But when I do so I got an error:
Could not load file or assembly 'Avalonia.Visuals, Version=0.10.17.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b.

But when I try the example from over here, it works fine. But this example is built on Avalonia 11.0.0-preview6. May that be an issue, as v11 is officially released now?

Thanks a lot for the answers!

Question: Building the correct `libcef.dll` file

I'm working on a C# CEF wrapper for unity and am wondering what the steps are to generate libcef.dll. The steps currently point to CEF's automatic build tool but I have found that to not generate libcef.dll. Since it looks like this project uses the setup that I want I was wondering how this project does it.

Any information would be great, I appreciate your time.

Massive Edit: I should have specified that this is specific to MacOS. I suppose my question would then be more specific to, is it possible to build CefGlue on MacOS, and if so how do you acquire the needed libcef.dll.

CefRuntime.ExecuteProcess & Multi-Process doesn't seem to work properly on Linux

I've only been using libcef and CefGlue for a few days. If there's any mistake, please point out.
The problem which will be mentioned below can be solved by running in single process mode, but apparently it's not the recommended way. So, I hope this issue can be fixed.

Here's the full code.

using Xilium.CefGlue;

internal static class Program
{
    private static void Main(string[] args)
    {
        var myApp = new MyApp();
        var mainArgs = new CefMainArgs(args);
        var exitCode = CefRuntime.ExecuteProcess(mainArgs, myApp, 0);

        if (exitCode >= 0)
        {
            Environment.Exit(exitCode);
        }

        var settings = new CefSettings()
        {
            Locale = "en-US",
            WindowlessRenderingEnabled = true,
            NoSandbox = true,
            MultiThreadedMessageLoop = false,
            ExternalMessagePump = false,
            UserDataPath = $"{Path.GetFullPath(".")}{Path.DirectorySeparatorChar}userData",
            LocalesDirPath = $"{Path.GetFullPath(".")}{Path.DirectorySeparatorChar}locales",
            ResourcesDirPath = $"{Path.GetFullPath(".")}",
        };

        CefRuntime.Initialize(mainArgs, settings, myApp, 0);

        var windowInfo = CefWindowInfo.Create();
        windowInfo.SetAsWindowless(0, false);

        var client = new MyClient();
        var browserSettings = new CefBrowserSettings()
        {
            WindowlessFrameRate = 60,
        };

        CefBrowserHost.CreateBrowser(windowInfo, client, browserSettings, "https://testufo.com");
        CefRuntime.RunMessageLoop();
        CefRuntime.Shutdown();
    }
}

internal class MyApp : CefApp
{
    protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
    {
        Array.ForEach(commandLine.GetArgv(), Console.WriteLine);
        Console.WriteLine();
        // Append the switches to the main process only
        if (!string.IsNullOrEmpty(processType))
            return;

        commandLine.AppendSwitch("disable-gpu");
        commandLine.AppendSwitch("disable-gpu-compositing");
        commandLine.AppendSwitch("enable-begin-frame-scheduling");
        commandLine.AppendSwitch("disable-surfaces");
        commandLine.AppendSwitch("no-zygote");
        commandLine.AppendSwitch("no-sandbox");
        commandLine.AppendSwitch("disable-setuid-sandbox");
        // Solves the problem but not recommended
        // commandLine.AppendSwitch("single-process");
    }
}

internal class MyClient : CefClient
{
    private readonly CefRenderHandler myRenderHandler = new MyRenderHandler();

    protected override CefLoadHandler? GetLoadHandler()
    {
        return base.GetLoadHandler();
    }

    protected override CefRenderHandler? GetRenderHandler()
    {
        return myRenderHandler;
    }

    protected override CefAudioHandler? GetAudioHandler()
    {
        return base.GetAudioHandler();
    }
}

internal class MyRenderHandler : CefRenderHandler
{
    const int width = 1280;
    const int height = 720;

    public MyRenderHandler()
    {
        Console.WriteLine("Initialized!");
    }

    protected override CefAccessibilityHandler GetAccessibilityHandler()
    {
        throw new NotImplementedException();
    }

    protected override bool GetScreenInfo(CefBrowser browser, CefScreenInfo screenInfo)
    {
        return true;
    }

    protected override void GetViewRect(CefBrowser browser, out CefRectangle rect)
    {
        rect = new CefRectangle(0, 0, width, height);
    }

    protected override void OnAcceleratedPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, nint sharedHandle)
    {
        throw new NotImplementedException();
    }

    protected override void OnImeCompositionRangeChanged(CefBrowser browser, CefRange selectedRange, CefRectangle[] characterBounds)
    {
        throw new NotImplementedException();
    }

    protected override void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, nint buffer, int width, int height)
    {
        Console.WriteLine("onPaint called");
    }

    protected override void OnPopupSize(CefBrowser browser, CefRectangle rect)
    {
        throw new NotImplementedException();
    }

    protected override void OnScrollOffsetChanged(CefBrowser browser, double x, double y)
    {
        throw new NotImplementedException();
    }
}

The code is a little messy, but it serves the purpose.
The demo program basically initializes libcef in OSR mode and visits https://testufo.com. Later it prints out the given command line arguments, adds some command line arguments, triggers onPaint in MyRenderHandler and spams the console with "onPaint called" message.
And it did work flawlessly, at least on Windows.
But when I ran it on Ubuntu 22.04, the program spammed the console with bunch of command line arguments instead.


--no-sandbox
--lang=en-US
--log-file=/home/google/Desktop/cef/debug.log
--resources-dir-path=/home/google/Desktop/cef
--locales-dir-path=/home/google/Desktop/cef/locales
--disable-features=BackForwardCache

Initialized!
--type=gpu-process
--no-sandbox
--locales-dir-path=/home/google/Desktop/cef/locales
--resources-dir-path=/home/google/Desktop/cef
--lang=en-US
--user-data-dir=/home/google/Desktop/cef/userData
--gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA==
--use-gl=angle
--use-angle=swiftshader-webgl
--log-file=/home/google/Desktop/cef/debug.log
--shared-files
--field-trial-handle=0,i,14014740667592638725,13604786558041850983,131072
--disable-features=BackForwardCache
--no-sandbox
--lang=en-US
--resources-dir-path=/home/google/Desktop/cef
--locales-dir-path=/home/google/Desktop/cef/locales
--disable-features=BackForwardCache,BackForwardCache

--type=utility
--utility-sub-type=network.mojom.NetworkService
--lang=en-US
--service-sandbox-type=none
--no-sandbox
--locales-dir-path=/home/google/Desktop/cef/locales
--resources-dir-path=/home/google/Desktop/cef
--lang=en-US
--user-data-dir=/home/google/Desktop/cef/userData
--log-file=/home/google/Desktop/cef/debug.log
--shared-files=v8_context_snapshot_data:100
--field-trial-handle=0,i,14014740667592638725,13604786558041850983,131072
--disable-features=BackForwardCache
--no-sandbox
--lang=en-US
--resources-dir-path=/home/google/Desktop/cef
--locales-dir-path=/home/google/Desktop/cef/locales
--disable-features=BackForwardCache,BackForwardCache

--type=renderer
--locales-dir-path=/home/google/Desktop/cef/locales
--resources-dir-path=/home/google/Desktop/cef
--user-data-dir=/home/google/Desktop/cef/userData
--no-sandbox
--log-file=/home/google/Desktop/cef/debug.log
--no-zygote
--disable-gpu-compositing
--lang=en-US
--num-raster-threads=4
--enable-main-frame-before-activation
--renderer-client-id=4
--time-ticks-at-unix-epoch=-1691198068908968
--launch-time-ticks=18423119669
--shared-files=v8_context_snapshot_data:100
--field-trial-handle=0,i,14014740667592638725,13604786558041850983,131072
--disable-features=BackForwardCache
--no-sandbox
--lang=en-US
--resources-dir-path=/home/google/Desktop/cef
--locales-dir-path=/home/google/Desktop/cef/locales
--disable-features=BackForwardCache,BackForwardCache

--type=renderer
--locales-dir-path=/home/google/Desktop/cef/locales
--resources-dir-path=/home/google/Desktop/cef
--user-data-dir=/home/google/Desktop/cef/userData
--first-renderer-process
--no-sandbox
--log-file=/home/google/Desktop/cef/debug.log
--no-zygote
--disable-gpu-compositing
--lang=en-US
--num-raster-threads=4
--enable-main-frame-before-activation
--renderer-client-id=5
--time-ticks-at-unix-epoch=-1691198068908968
--launch-time-ticks=18423118340
--shared-files=v8_context_snapshot_data:100
--field-trial-handle=0,i,14014740667592638725,13604786558041850983,131072
--disable-features=BackForwardCache
--no-sandbox
--lang=en-US
--resources-dir-path=/home/google/Desktop/cef
--locales-dir-path=/home/google/Desktop/cef/locales
--disable-features=BackForwardCache,BackForwardCache

Initialized!
Initialized!
Initialized!
Initialized!
--type=gpu-process
--no-sandbox
--use-angle=swiftshader-webgl
--locales-dir-path=/home/google/Desktop/cef/locales
--resources-dir-path=/home/google/Desktop/cef
--lang=en-US
--user-data-dir=/home/google/Desktop/cef/userData
--gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA==
--use-gl=angle
--use-angle=swiftshader-webgl
--log-file=/home/google/Desktop/cef/debug.log
--shared-files
--field-trial-handle=0,i,2207804637224223773,17526720498829213866,131072
--disable-features=BackForwardCache
--no-sandbox
--lang=en-US
--resources-dir-path=/home/google/Desktop/cef
--locales-dir-path=/home/google/Desktop/cef/locales
--disable-features=BackForwardCache,BackForwardCache

--type=gpu-process
--no-sandbox
--locales-dir-path=/home/google/Desktop/cef/locales
--resources-dir-path=/home/google/Desktop/cef
--lang=en-US
--user-data-dir=/home/google/Desktop/cef/userData
--gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA==
--use-gl=angle
--use-angle=swiftshader-webgl
--log-file=/home/google/Desktop/cef/debug.log
--shared-files
--field-trial-handle=0,i,6075439658209197302,17739411482228066076,131072
--disable-features=BackForwardCache
--no-sandbox
--lang=en-US
--resources-dir-path=/home/google/Desktop/cef
--locales-dir-path=/home/google/Desktop/cef/locales
--disable-features=BackForwardCache,BackForwardCache

--type=utility
--utility-sub-type=network.mojom.NetworkService
--lang=en-US
--service-sandbox-type=none
--no-sandbox
--locales-dir-path=/home/google/Desktop/cef/locales
--resources-dir-path=/home/google/Desktop/cef
--lang=en-US
--user-data-dir=/home/google/Desktop/cef/userData
--log-file=/home/google/Desktop/cef/debug.log
--shared-files=v8_context_snapshot_data:100
--field-trial-handle=0,i,6075439658209197302,17739411482228066076,131072
--disable-features=BackForwardCache
--no-sandbox
--lang=en-US
--resources-dir-path=/home/google/Desktop/cef
--locales-dir-path=/home/google/Desktop/cef/locales
--disable-features=BackForwardCache,BackForwardCache

--type=gpu-process
--no-sandbox
--locales-dir-path=/home/google/Desktop/cef/locales
--resources-dir-path=/home/google/Desktop/cef
--lang=en-US
--user-data-dir=/home/google/Desktop/cef/userData
--gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA==
--use-gl=angle
--use-angle=swiftshader-webgl
--log-file=/home/google/Desktop/cef/debug.log
--shared-files
--field-trial-handle=0,i,2605854638024410994,9227336841900173362,131072
--disable-features=BackForwardCache
--no-sandbox
--lang=en-US
--resources-dir-path=/home/google/Desktop/cef
--locales-dir-path=/home/google/Desktop/cef/locales
--disable-features=BackForwardCache,BackForwardCache

The log went on and on, and the program drained all the memory and crashed X-Server faster than I closed the terminal window.
It is obvious that the sub-processes didn't launched correctly.

To make it clearer, I'll specify the BrowserSubprocessPath explicitly.

var settings = new CefSettings()
{
    Locale = "en-US",
    WindowlessRenderingEnabled = true,
    NoSandbox = true,
    MultiThreadedMessageLoop = false,
    ExternalMessagePump = false,
    UserDataPath = $"{Path.GetFullPath(".")}{Path.DirectorySeparatorChar}userData",
    // Linux
    LocalesDirPath = $"{Path.GetFullPath(".")}{Path.DirectorySeparatorChar}locales",
    ResourcesDirPath = $"{Path.GetFullPath(".")}",
    // Specify the BrowserSubprocessPath explicitly
    BrowserSubprocessPath = $"{Path.GetFullPath(".")}{Path.DirectorySeparatorChar}CefHelper.exe",
};

CefHelper.exe is the "helper" program, and here's the code.

using Xilium.CefGlue;

internal class Program
{
    private static void Main(string[] args)
    {
        var mainArgs = new CefMainArgs(args);
        var exitCode = CefRuntime.ExecuteProcess(mainArgs, null, 0);

        if (exitCode >= 0)
            Environment.Exit(exitCode);
    }
}

Just the bare minimum code in order to launch the subprocesses required by libcef.
I compiled it and copied to the root directory.
Firstly, I ran the main program on Windows. And again, everything worked fine.
Then I changed CefHelper.exe to CefHelper, and copied both of them to the Ubuntu machine.
Surprisingly, the GUI environment didn't crash. But the main program spammed the console with another kind of error message.

[0805/144236.701339:ERROR:network_service_instance_impl.cc(499)] Network service crashed, restarting service.

Finally, I decided to dig out the official cpp demo cefsimple and made a few changes.

#include <iostream>
#include "tests/cefsimple/simple_app.h"
#include "include/cef_command_line.h"

using namespace std;

int main(int argc, char* argv[]) {
  cout << "Launches sub-processes only." << endl;

  CefMainArgs main_args(argc, argv);
  int exit_code = CefExecuteProcess(main_args, nullptr, nullptr);

  if (exit_code >= 0) {
    return exit_code;
  }
}

Still the bare minimum cpp code in order to launch the subprocesses.
Then I compiled the cpp version of CefHelper.exe and started the main program.
Boom, the program worked like a charm, it spammed the console with "onPaint" message.


Since my program could run on Windows with/without any helper program or run on Linux with the cpp version of the helper program, I would assume that there might be some problems with CefGlue's ExecuteProcess, especially on Linux platform.

I'm expecting to get this potential bug fixed (or maybe I did something wrong) and I'm willing to collaborate.
I'm not a native English speaker, so if there's any grammar mistake or typo, please forgive me.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.