Merge overlays, move overlay to separate process (#44)

* refactor: merge two overlay offScreenBrowser into one

* Electron support for shared overlay

* Separate overlay into its own process

* fix: invalid overlay texture size

* Handle duplicate processes

* Remove logging

---------

Co-authored-by: pa <maplenagisa@gmail.com>
Co-authored-by: rs189 <35667100+rs189@users.noreply.github.com>
This commit is contained in:
Natsumi
2026-01-12 11:31:10 +13:00
committed by Natsumi
parent 9135adf6d1
commit d2fd205476
41 changed files with 1122 additions and 2108 deletions

View File

@@ -23,7 +23,10 @@ namespace VRCX
internal void Init()
{
var isOverlay = StartupArgs.LaunchArguments.IsOverlay;
var userDataDir = Path.Join(Program.AppDataDirectory, "userdata");
if (isOverlay)
userDataDir = Path.Join(Program.AppDataDirectory, "overlay/userdata");
// delete userdata if Cef version has been downgraded, fixes VRCX not opening after a downgrade
CheckCefVersion(userDataDir);
@@ -39,6 +42,8 @@ namespace VRCX
BrowserSubprocessPath = Environment.ProcessPath,
BackgroundColor = 0xFF0A0A0A
};
if (isOverlay)
cefSettings.LogFile = Path.Join(Program.AppDataDirectory, "overlay/logs/cef.log");
cefSettings.RegisterScheme(new CefCustomScheme
{
@@ -58,7 +63,7 @@ namespace VRCX
cefSettings.CefCommandLineArgs.Add("disable-pdf-extension");
cefSettings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required";
cefSettings.CefCommandLineArgs.Add("disable-web-security");
cefSettings.CefCommandLineArgs.Add("disk-cache-size", "2147483647");
// cefSettings.CefCommandLineArgs.Add("disk-cache-size", "2147483647");
cefSettings.CefCommandLineArgs.Add("unsafely-disable-devtools-self-xss-warnings");
cefSettings.CefCommandLineArgs.Add("do-not-de-elevate"); // fix program failing to start when running as admin
@@ -78,9 +83,13 @@ namespace VRCX
// Discover network targets, Configure...
// Add Remote Target: localhost:8089
logger.Info("Debug mode enabled");
cefSettings.RemoteDebuggingPort = 8089;
cefSettings.RemoteDebuggingPort = !isOverlay ? 8089 : 8090;
cefSettings.CefCommandLineArgs["remote-allow-origins"] = "*";
}
// load extensions in debug mode
if (Program.LaunchDebug && !isOverlay)
{
var extensionsPath = Path.Join(Program.AppDataDirectory, "extensions");
Directory.CreateDirectory(extensionsPath);
@@ -111,10 +120,11 @@ namespace VRCX
}
}
CefSharpSettings.ShutdownOnExit = false;
CefSharpSettings.ShutdownOnExit = true;
CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
CefSharpSettings.ConcurrentTaskExecution = true;
if (Cef.Initialize(cefSettings, false) == false)
if (!Cef.Initialize(cefSettings, false))
{
logger.Error("Cef failed to initialize");
throw new Exception("Cef.Initialize()");

View File

@@ -15,11 +15,5 @@ namespace VRCX
repository.Register("Discord", Discord.Instance);
repository.Register("AssetBundleManager", AssetBundleManager.Instance);
}
public static void ApplyVrJavascriptBindings(IJavascriptObjectRepository repository)
{
repository.NameConverter = null;
repository.Register("AppApiVr", AppApiVr.Instance);
}
}
}