Skip to content

Commit

Permalink
fix: RuntimeLogWatcher path on Linux
Browse files Browse the repository at this point in the history
Listen for client exceptions should correctly find the VRChat path on Linux.
  • Loading branch information
FairplexVR committed Sep 9, 2024
1 parent fd57c16 commit e2a92af
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Packages/com.vrchat.UdonSharp/Editor/UdonSharpRuntimeLogWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private class LogFileState

private static Queue<string> _debugOutputQueue = new Queue<string>();
private static Dictionary<long, (string, UdonSharpProgramAsset)> _scriptLookup;

// Log watcher vars
private static FileSystemWatcher _logDirectoryWatcher;
private static object _logModifiedLock = new object();
Expand All @@ -44,20 +44,20 @@ private static bool ShouldListenForVRC()
}

private static bool _didMissingDataError;

private static bool InitializeScriptLookup()
{
if (EditorApplication.isCompiling || EditorApplication.isUpdating)
return false;

if (_logDirectoryWatcher == null && ShouldListenForVRC())
{
AssemblyReloadEvents.beforeAssemblyReload += CleanupLogWatcher;

// Now setup the filesystem watcher
string VRCDataPath = null;

#if UNITY_EDITOR_LINUX
#if UNITY_EDITOR_LINUX
string vrchatAppId = "438100";
string steamConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.steam/steam/steamapps/libraryfolders.vdf";
string steamappsVrchatPath = $"steamapps/compatdata/{vrchatAppId}/pfx/drive_c/users/steamuser/AppData/LocalLow/VRChat/VRChat/";
Expand Down Expand Up @@ -96,10 +96,10 @@ private static bool InitializeScriptLookup()
}
}

#else // UNITY_EDITOR_WIN || UNITY_EDITOR_MAC
#else // UNITY_EDITOR_WIN || UNITY_EDITOR_MAC
string[] splitPath = Application.persistentDataPath.Split('/', '\\');
VRCDataPath = string.Join("\\", splitPath.Take(splitPath.Length - 2)) + "\\VRChat\\VRChat";
#endif
string VRCDataPath = string.Join("\\", splitPath.Take(splitPath.Length - 2)) + "\\VRChat\\VRChat";
#endif

if (Directory.Exists(VRCDataPath))
{
Expand Down Expand Up @@ -200,9 +200,9 @@ private static void OnEditorUpdate()
if (_logDirectoryWatcher != null)
_logDirectoryWatcher.EnableRaisingEvents = shouldListenForVRC;

if (!shouldListenForVRC)
if (!shouldListenForVRC)
return;

if (_lineMatch == null)
_lineMatch = new Regex(MATCH_STR, RegexOptions.Compiled);

Expand All @@ -229,7 +229,7 @@ private static void OnEditorUpdate()
FileInfo fileInfo = new FileInfo(logPath);

string newLogContent;

using (FileStream stream = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (StreamReader reader = new StreamReader(stream))
Expand Down Expand Up @@ -293,9 +293,9 @@ private static void OnEditorUpdate()
}
}

if (modifiedFilesAndContents == null)
if (modifiedFilesAndContents == null)
return;

foreach ((string filePath, string contents) in modifiedFilesAndContents)
{
LogFileState state = _logFileStates[filePath];
Expand Down Expand Up @@ -353,7 +353,7 @@ private static void OnEditorUpdate()
int currentErrorIndex = contents.IndexOf(errorMatchStr, StringComparison.Ordinal);
while (currentErrorIndex != -1)
{
HandleLogError(contents.Substring(currentErrorIndex, contents.Length - currentErrorIndex), $"VRChat client runtime Udon exception detected!", $"{state.playerName ?? "Unknown"}");
HandleLogError(contents.Substring(currentErrorIndex, contents.Length - currentErrorIndex), $"VRChat client runtime Udon exception detected!", $"{ state.playerName ?? "Unknown"}");

currentErrorIndex = contents.IndexOf(errorMatchStr, currentErrorIndex + errorMatchStr.Length, StringComparison.Ordinal);
}
Expand Down Expand Up @@ -480,7 +480,7 @@ private static void HandleLogError(string errorStr, string logPrefix, string pre
Match programCounterMatch = Regex.Match(errorStr, @"Program Counter was at: (?<counter>\d+)");

programCounter = int.Parse(programCounterMatch.Groups["counter"].Value);

Match programTypeMatch = Regex.Match(errorStr, @"Heap Dump:[\n\r\s]+[\d]x[\d]+: (?<programID>[-]?[\d]+)[\n\r\s]+[\d]x[\d]+: (?<programName>[\w]+)");

programID = long.Parse(programTypeMatch.Groups["programID"].Value);
Expand Down

0 comments on commit e2a92af

Please # to comment.