Files
RobustToolbox/Robust.Client.WebView/Cef/RobustCefApp.cs
PJB3005 1fea48fbf4 Don't disable GPU compositing in CEF
Workaround no longer needed with message pump fixed. I think.
2025-12-28 02:16:23 +01:00

72 lines
2.6 KiB
C#

using System;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Xilium.CefGlue;
namespace Robust.Client.WebView.Cef
{
internal sealed class RobustCefApp : CefApp
{
private readonly ISawmill? _sawmill;
private readonly BrowserProcessHandler _browserProcessHandler = new();
private readonly RenderProcessHandler _renderProcessHandler = new();
public RobustCefApp(ISawmill? sawmill)
{
_sawmill = sawmill;
}
protected override CefBrowserProcessHandler GetBrowserProcessHandler()
{
return _browserProcessHandler;
}
protected override CefRenderProcessHandler GetRenderProcessHandler()
{
return _renderProcessHandler;
}
protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
{
// Disable zygote on Linux.
commandLine.AppendSwitch("--no-zygote");
// Work around https://github.com/chromiumembedded/cef/issues/3213
// Desktop GL force makes Chromium not try to load its own ANGLE/Swiftshader so load paths aren't problematic.
// UPDATE: That bug got fixed and now this workaround breaks CEF.
// Keeping all this comment history in case I ever wanan remember what the `--use-gl` flag is.
//if (OperatingSystem.IsLinux())
// commandLine.AppendSwitch("--use-gl", "desktop");
// commandLine.AppendSwitch("--single-process");
//commandLine.AppendSwitch("--disable-gpu");
//commandLine.AppendSwitch("--disable-gpu-compositing");
//commandLine.AppendSwitch("--in-process-gpu");
commandLine.AppendSwitch("--off-screen-rendering-enabled");
commandLine.AppendSwitch("disable-threaded-scrolling", "1");
commandLine.AppendSwitch("disable-features", "TouchpadAndWheelScrollLatching,AsyncWheelEvents");
_sawmill?.Debug($"CEF command line: {commandLine}");
}
protected override void OnRegisterCustomSchemes(CefSchemeRegistrar registrar)
{
// NOTE: KEEP IN SYNC WITH RUST CODE!
registrar.AddCustomScheme("res", CefSchemeOptions.Secure | CefSchemeOptions.Standard);
registrar.AddCustomScheme("usr", CefSchemeOptions.Secure | CefSchemeOptions.Standard);
}
private sealed class BrowserProcessHandler : CefBrowserProcessHandler
{
}
// TODO CEF: Research - Is this even needed?
private sealed class RenderProcessHandler : CefRenderProcessHandler
{
}
}
}