mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 11:40:52 +01:00
commitd4f265c314Author: PJB3005 <pieterjan.briers+git@gmail.com> Date: Sun Sep 14 14:32:44 2025 +0200 Fix incorrect path combine in DirLoader and WritableDirProvider This (and the other couple past commits) reported by Elelzedel. commit7654d38612Author: PJB3005 <pieterjan.briers+git@gmail.com> Date: Sat Sep 13 22:50:51 2025 +0200 Move CEF cache out of data directory Don't want content messing with this... commitcdcc255123Author: PJB3005 <pieterjan.briers+git@gmail.com> Date: Sat Sep 13 19:11:16 2025 +0200 Make Robust.Client.WebView.Cef.Program internal. commit2f56a6a110Author: PJB3005 <pieterjan.briers+git@gmail.com> Date: Sat Sep 13 19:10:46 2025 +0200 Update SpaceWizards.NFluidSynth to 0.2.2 commit16fc48cef2Author: PJB3005 <pieterjan.briers+git@gmail.com> Date: Sat Sep 13 19:09:43 2025 +0200 Hide IWritableDirProvider.RootDir on client This shouldn't be exposed. (cherry picked from commit 2f07159336bc640e41fbbccfdec4133a68c13bdb) (cherry picked from commit d6c3212c74373ed2420cc4be2cf10fcd899c2106) (cherry picked from commit bfa70d7e2ca6758901b680547fcfa9b24e0610b7)
78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Globalization;
|
|
using System.Threading;
|
|
using Xilium.CefGlue;
|
|
|
|
namespace Robust.Client.WebView.Cef
|
|
{
|
|
internal static class Program
|
|
{
|
|
// This was supposed to be the main entry for the subprocess program... It doesn't work.
|
|
public static int Main(string[] args)
|
|
{
|
|
// This is a workaround for this to work on UNIX.
|
|
var argv = args;
|
|
if (CefRuntime.Platform != CefRuntimePlatform.Windows)
|
|
{
|
|
argv = new string[args.Length + 1];
|
|
Array.Copy(args, 0, argv, 1, args.Length);
|
|
argv[0] = "-";
|
|
}
|
|
|
|
var mainArgs = new CefMainArgs(argv);
|
|
|
|
StartWatchThread();
|
|
|
|
// This will block executing until the subprocess is shut down.
|
|
var code = CefRuntime.ExecuteProcess(mainArgs, new RobustCefApp(null), IntPtr.Zero);
|
|
|
|
if (code != 0)
|
|
{
|
|
System.Console.WriteLine($"CEF Subprocess exited unsuccessfully with exit code {code}! Arguments: {string.Join(' ', argv)}");
|
|
}
|
|
|
|
return code;
|
|
}
|
|
|
|
private static void StartWatchThread()
|
|
{
|
|
//
|
|
// CEF has this nasty habit of not shutting down all its processes if the parent crashes.
|
|
// Great!
|
|
//
|
|
// We use a separate thread in each CEF child process to watch the main PID.
|
|
// If it exits, we kill ourselves after a couple seconds.
|
|
//
|
|
|
|
if (Environment.GetEnvironmentVariable("ROBUST_CEF_BROWSER_PROCESS_ID") is not { } parentIdString)
|
|
return;
|
|
|
|
if (Environment.GetEnvironmentVariable("ROBUST_CEF_BROWSER_PROCESS_MODULE") is not { } parentModuleString)
|
|
return;
|
|
|
|
if (!int.TryParse(parentIdString, CultureInfo.InvariantCulture, out var parentId))
|
|
return;
|
|
|
|
var process = Process.GetProcessById(parentId);
|
|
if ((process.MainModule?.FileName ?? "") != parentModuleString)
|
|
{
|
|
process.Dispose();
|
|
return;
|
|
}
|
|
|
|
new Thread(() => WatchThread(process)) { Name = "CEF Watch Thread", IsBackground = true }
|
|
.Start();
|
|
}
|
|
|
|
private static void WatchThread(Process p)
|
|
{
|
|
p.WaitForExit();
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
Environment.Exit(1);
|
|
}
|
|
}
|
|
}
|