From 5a16cf8d6d12d46acbbbf1270257733ea2677474 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Tue, 21 Oct 2025 16:22:42 +1100 Subject: [PATCH] Fix random bugs --- Dotnet/AppApi/Cef/AppApiVrCef.cs | 2 +- Dotnet/AppApi/Cef/GameHandler.cs | 2 +- Dotnet/Cef/CefCustomDragHandler.cs | 2 +- Dotnet/Cef/MainForm.cs | 2 +- Dotnet/IPC/IPCClient.cs | 6 +++--- Dotnet/IPC/IPCServer.cs | 7 ++++--- Dotnet/LogWatcher.cs | 2 +- src/stores/vrcx.js | 2 +- src/views/Settings/components/Tabs/AdvancedTab.vue | 2 ++ 9 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Dotnet/AppApi/Cef/AppApiVrCef.cs b/Dotnet/AppApi/Cef/AppApiVrCef.cs index f9adf935..04524ec5 100644 --- a/Dotnet/AppApi/Cef/AppApiVrCef.cs +++ b/Dotnet/AppApi/Cef/AppApiVrCef.cs @@ -21,7 +21,7 @@ namespace VRCX public override void VrInit() { if (MainForm.Instance?.Browser != null && !MainForm.Instance.Browser.IsLoading && MainForm.Instance.Browser.CanExecuteJavascriptInMainFrame) - MainForm.Instance.Browser.ExecuteScriptAsync("$pinia.vr.vrInit", ""); + MainForm.Instance.Browser.ExecuteScriptAsync("window?.$pinia.vr.vrInit"); } public override void ToggleSystemMonitor(bool enabled) diff --git a/Dotnet/AppApi/Cef/GameHandler.cs b/Dotnet/AppApi/Cef/GameHandler.cs index 79694946..c6e74165 100644 --- a/Dotnet/AppApi/Cef/GameHandler.cs +++ b/Dotnet/AppApi/Cef/GameHandler.cs @@ -36,7 +36,7 @@ namespace VRCX // TODO: fix this throwing an exception for being called before the browser is ready. somehow it gets past the checks if (MainForm.Instance?.Browser != null && !MainForm.Instance.Browser.IsLoading && MainForm.Instance.Browser.CanExecuteJavascriptInMainFrame) - MainForm.Instance.Browser.ExecuteScriptAsync("$pinia.game.updateIsGameRunning", isGameRunning, isSteamVRRunning, isHmdAfk); + MainForm.Instance.Browser.ExecuteScriptAsync("window?.$pinia.game.updateIsGameRunning", isGameRunning, isSteamVRRunning, isHmdAfk); } public override bool IsGameRunning() diff --git a/Dotnet/Cef/CefCustomDragHandler.cs b/Dotnet/Cef/CefCustomDragHandler.cs index d1b78b5a..30283009 100644 --- a/Dotnet/Cef/CefCustomDragHandler.cs +++ b/Dotnet/Cef/CefCustomDragHandler.cs @@ -26,7 +26,7 @@ namespace VRCX } if (MainForm.Instance?.Browser != null && !MainForm.Instance.Browser.IsLoading && MainForm.Instance.Browser.CanExecuteJavascriptInMainFrame) - MainForm.Instance.Browser.ExecuteScriptAsync("$pinia.vrcx.dragEnterCef", file); + MainForm.Instance.Browser.ExecuteScriptAsync("window?.$pinia.vrcx.dragEnterCef", file); dragData.Dispose(); return false; diff --git a/Dotnet/Cef/MainForm.cs b/Dotnet/Cef/MainForm.cs index 57568b57..ac7a8d6f 100644 --- a/Dotnet/Cef/MainForm.cs +++ b/Dotnet/Cef/MainForm.cs @@ -86,7 +86,7 @@ namespace VRCX Browser.GotFocus += (_, _) => { if (Browser != null && !Browser.IsLoading && Browser.CanExecuteJavascriptInMainFrame) - Browser.ExecuteScriptAsync("$pinia.vrcStatus.onBrowserFocus()"); + Browser.ExecuteScriptAsync("window?.$pinia.vrcStatus.onBrowserFocus"); }; JavascriptBindings.ApplyAppJavascriptBindings(Browser.JavascriptObjectRepository); diff --git a/Dotnet/IPC/IPCClient.cs b/Dotnet/IPC/IPCClient.cs index 0fb1e879..e7e101f9 100644 --- a/Dotnet/IPC/IPCClient.cs +++ b/Dotnet/IPC/IPCClient.cs @@ -60,7 +60,7 @@ namespace VRCX } catch { - IPCServer.Clients.Remove(this); + IPCServer.Clients.TryRemove(this, out _); } } @@ -72,7 +72,7 @@ namespace VRCX if (bytesRead <= 0) { - IPCServer.Clients.Remove(this); + IPCServer.Clients.TryRemove(this, out _); _ipcServer.Close(); return; } @@ -90,7 +90,7 @@ namespace VRCX #if !LINUX if (MainForm.Instance?.Browser != null && !MainForm.Instance.Browser.IsLoading && MainForm.Instance.Browser.CanExecuteJavascriptInMainFrame) - MainForm.Instance.Browser.ExecuteScriptAsync("$pinia.vrcx.ipcEvent", packet); + MainForm.Instance.Browser.ExecuteScriptAsync("window?.$pinia.vrcx.ipcEvent", packet); #endif } diff --git a/Dotnet/IPC/IPCServer.cs b/Dotnet/IPC/IPCServer.cs index e6c98b2a..f3df56cf 100644 --- a/Dotnet/IPC/IPCServer.cs +++ b/Dotnet/IPC/IPCServer.cs @@ -5,6 +5,7 @@ // For a copy, see . using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO.Pipes; using System.Threading.Tasks; @@ -14,7 +15,7 @@ namespace VRCX public class IPCServer { public static readonly IPCServer Instance; - public static readonly List Clients = new List(); + public static readonly ConcurrentDictionary Clients = new(); static IPCServer() { @@ -30,7 +31,7 @@ namespace VRCX { foreach (var client in Clients) { - client?.Send(ipcPacket); + client.Key?.Send(ipcPacket); } } @@ -64,7 +65,7 @@ namespace VRCX } var ipcClient = new IPCClient(ipcServer); - Clients.Add(ipcClient); + Clients.TryAdd(ipcClient, 0); ipcClient.BeginRead(); CreateIPCServer(); } diff --git a/Dotnet/LogWatcher.cs b/Dotnet/LogWatcher.cs index 505ab634..88245bec 100644 --- a/Dotnet/LogWatcher.cs +++ b/Dotnet/LogWatcher.cs @@ -297,7 +297,7 @@ namespace VRCX m_LogQueue.Enqueue(logLine); #else if (MainForm.Instance != null && MainForm.Instance.Browser != null) - MainForm.Instance.Browser.ExecuteScriptAsync("$pinia.gameLog.addGameLogEvent", logLine); + MainForm.Instance.Browser.ExecuteScriptAsync("window?.$pinia.gameLog.addGameLogEvent", logLine); #endif } diff --git a/src/stores/vrcx.js b/src/stores/vrcx.js index 5f52b43d..5a727756 100644 --- a/src/stores/vrcx.js +++ b/src/stores/vrcx.js @@ -422,7 +422,7 @@ export const useVrcxStore = defineStore('Vrcx', () => { console.log(`IPC invalid JSON, ${json}`); return; } - + switch (data.type) { case 'OnEvent': if (!gameStore.isGameRunning) { diff --git a/src/views/Settings/components/Tabs/AdvancedTab.vue b/src/views/Settings/components/Tabs/AdvancedTab.vue index d10d7a8b..cbcd5eed 100644 --- a/src/views/Settings/components/Tabs/AdvancedTab.vue +++ b/src/views/Settings/components/Tabs/AdvancedTab.vue @@ -367,6 +367,7 @@ useAuthStore, useAvatarProviderStore, useAvatarStore, + useGameLogStore, useGroupStore, useInstanceStore, useLaunchStore, @@ -395,6 +396,7 @@ const { showLaunchOptions } = useLaunchStore(); const { enablePrimaryPasswordChange } = useAuthStore(); const { showConsole, clearVRCXCache, showRegistryBackupDialog } = useVrcxStore(); + const { disableGameLogDialog } = useGameLogStore(); const { cachedUsers } = useUserStore(); const { cachedWorlds } = useWorldStore();