From fc49deba710ebe8f9b818e6164afa32e6ed610c6 Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Mon, 7 Oct 2024 02:24:16 -0700 Subject: [PATCH] chore: make task outputs more legible --- .vscode/launch.json | 21 ++++++ Assets/Rivet/Editor/Task.cs | 10 +-- Assets/Rivet/Editor/TaskManager.cs | 28 +++++++- Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml | 2 +- .../Editor/UI/Dock/Tabs/DevelopController.cs | 19 +++++ .../Rivet/Editor/UI/Dock/Tabs/Settings.uxml | 2 +- Assets/Rivet/Editor/Util/Builder.cs | 2 + Packages/manifest.json | 6 +- Packages/packages-lock.json | 72 +++++++++---------- scripts/build_dev.ts | 30 ++++---- scripts/run_dev.ts | 6 +- 11 files changed, 139 insertions(+), 59 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index da60e25..dffbd5b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,6 +5,27 @@ "name": "Attach to Unity", "type": "vstuc", "request": "attach" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug Unity Editor", + "program": "/Applications/Unity/Hub/Editor/2022.3.38f1/Unity.app/Contents/MacOS/Unity", + "args": [ + "-projectPath", + "${workspaceFolder}", + "-logfile", + "/tmp/unity-log.txt" + ], + "cwd": "${workspaceFolder}", + "env": {}, + "stopOnEntry": false, + "initCommands": [ + "settings set target.inline-breakpoint-strategy always" + ], + "postRunCommands": [ + "process handle -p true -s false -n false SIGXCPU SIGPIPE" + ] } ] } \ No newline at end of file diff --git a/Assets/Rivet/Editor/Task.cs b/Assets/Rivet/Editor/Task.cs index 0d4fa02..22599fa 100644 --- a/Assets/Rivet/Editor/Task.cs +++ b/Assets/Rivet/Editor/Task.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; using UnityEditor; +using Unity.VisualScripting.YamlDotNet.Serialization.ObjectGraphVisitors; namespace Rivet.Editor { @@ -11,10 +12,10 @@ public class RivetTask : IDisposable public enum LogType { STDOUT, STDERR } // Events - public event Action TaskLog; - public event Action TaskOk; - public event Action TaskError; - public event Action TaskOutput; + public event Action? TaskLog; + public event Action? TaskOk; + public event Action? TaskError; + public event Action? TaskOutput; // Config private string _name; @@ -90,6 +91,7 @@ private void HandleOnOutputEvent(string eventJson) private void OnLogEvent(string log) { + RivetLogger.Log($"TaskLog is null: {TaskLog == null}"); TaskLog?.Invoke(log, LogType.STDOUT); } diff --git a/Assets/Rivet/Editor/TaskManager.cs b/Assets/Rivet/Editor/TaskManager.cs index 46ef917..61ceef3 100644 --- a/Assets/Rivet/Editor/TaskManager.cs +++ b/Assets/Rivet/Editor/TaskManager.cs @@ -192,7 +192,33 @@ private void OnTaskLog(string message, RivetTask.LogType type) RivetTask.LogType.STDERR => LogType.STDERR, _ => LogType.META }; - AddLogLine(message, logType); + + // Strip [stdout] and [stderr] prefixes + message = StripLogPrefix(message); + + // Filter out Unity stack traces + if (!IsUnityStackTrace(message)) + { + AddLogLine(message, logType); + } + } + + private string StripLogPrefix(string message) + { + if (message.StartsWith("[stdout] ")) + { + return message.Substring(9); + } + else if (message.StartsWith("[stderr] ")) + { + return message.Substring(9); + } + return message; + } + + private bool IsUnityStackTrace(string message) + { + return (message.Contains(" (at ") && message.EndsWith(")")) || message.StartsWith("UnityEngine."); } public void AddLogLine(string message, LogType type) diff --git a/Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml b/Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml index 18c611a..b332cc5 100644 --- a/Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml +++ b/Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml @@ -17,7 +17,7 @@ - + diff --git a/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs b/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs index 50f2118..f5a1fd7 100644 --- a/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs +++ b/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs @@ -101,7 +101,13 @@ void InitUI() _lgsRestart.RegisterCallback(ev => { OnLocalGameServerStart(); }); _lgsShowLogs.RegisterCallback(ev => GameServerWindow.ShowGameServer()); + _playTypeDropdown.RegisterValueChangedCallback(ev => UpdatePlayerCountVisibility()); + _buildDeployButton.RegisterCallback(ev => OnBuildAndDeploy()); + + + // Initial visibility update + UpdatePlayerCountVisibility(); } public void OnBootstrap() @@ -171,6 +177,13 @@ private void OnLocalGameServerStart() { Builder.BuildAndRunMultipleDevPlayers(_playerCount.value); } + + // Open game server logs if needed + if (canPlayServer) { + if (!EditorWindow.HasOpenInstances()) { + GameServerWindow.ShowGameServer(); + } + } } private void OnBuildAndDeploy() @@ -215,5 +228,11 @@ private void OnBuildAndDeploy() ["modules"] = deployModules, }); } + + private void UpdatePlayerCountVisibility() + { + bool showPlayerCount = _playTypeDropdown.index == 0 || _playTypeDropdown.index == 1; + _playerCount.style.display = showPlayerCount ? DisplayStyle.Flex : DisplayStyle.None; + } } } \ No newline at end of file diff --git a/Assets/Rivet/Editor/UI/Dock/Tabs/Settings.uxml b/Assets/Rivet/Editor/UI/Dock/Tabs/Settings.uxml index a66a2e2..7bd36d4 100644 --- a/Assets/Rivet/Editor/UI/Dock/Tabs/Settings.uxml +++ b/Assets/Rivet/Editor/UI/Dock/Tabs/Settings.uxml @@ -5,7 +5,7 @@ - + diff --git a/Assets/Rivet/Editor/Util/Builder.cs b/Assets/Rivet/Editor/Util/Builder.cs index c89d418..10f776d 100644 --- a/Assets/Rivet/Editor/Util/Builder.cs +++ b/Assets/Rivet/Editor/Util/Builder.cs @@ -154,6 +154,8 @@ public static string BuildDevDedicatedServer() subtarget = (int)StandaloneBuildSubtarget.Server }; + return FindServerExecutablePath(buildPlayerOptions.locationPathName, buildPlayerOptions.target); + // Build the server RivetLogger.Log("Building dedicated server..."); var report = BuildPipeline.BuildPlayer(buildPlayerOptions); diff --git a/Packages/manifest.json b/Packages/manifest.json index a1ada2b..d2227bb 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -5,7 +5,7 @@ "com.unity.ads": "4.4.2", "com.unity.ai.navigation": "1.1.5", "com.unity.analytics": "3.8.1", - "com.unity.collab-proxy": "2.4.3", + "com.unity.collab-proxy": "2.5.1", "com.unity.feature.2d": "2.0.1", "com.unity.ide.rider": "3.0.31", "com.unity.ide.visualstudio": "2.0.22", @@ -13,13 +13,13 @@ "com.unity.nuget.newtonsoft-json": "3.2.1", "com.unity.purchasing": "4.11.0", "com.unity.test-framework": "1.1.33", - "com.unity.textmeshpro": "3.0.6", + "com.unity.textmeshpro": "3.0.7", "com.unity.timeline": "1.7.6", "com.unity.toolchain.macos-arm64-linux-x86_64": "2.0.0", "com.unity.ugui": "1.0.0", "com.unity.vectorgraphics": "2.0.0-preview.24", "com.unity.visualscripting": "1.9.4", - "com.unity.xr.legacyinputhelpers": "2.1.10", + "com.unity.xr.legacyinputhelpers": "2.1.11", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 8a91377..06c2f5a 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -1,11 +1,11 @@ { "dependencies": { "com.unity.2d.animation": { - "version": "9.1.1", + "version": "9.1.2", "depth": 1, "source": "registry", "dependencies": { - "com.unity.2d.common": "8.0.2", + "com.unity.2d.common": "8.0.3", "com.unity.2d.sprite": "1.0.0", "com.unity.collections": "1.1.0", "com.unity.modules.animation": "1.0.0", @@ -14,27 +14,27 @@ "url": "https://packages.unity.com" }, "com.unity.2d.aseprite": { - "version": "1.1.4", + "version": "1.1.6", "depth": 1, "source": "registry", "dependencies": { - "com.unity.2d.sprite": "1.0.0", "com.unity.2d.common": "6.0.6", + "com.unity.2d.sprite": "1.0.0", "com.unity.mathematics": "1.2.6", "com.unity.modules.animation": "1.0.0" }, "url": "https://packages.unity.com" }, "com.unity.2d.common": { - "version": "8.0.2", + "version": "8.0.3", "depth": 2, "source": "registry", "dependencies": { + "com.unity.burst": "1.7.3", "com.unity.2d.sprite": "1.0.0", "com.unity.mathematics": "1.1.0", - "com.unity.modules.uielements": "1.0.0", "com.unity.modules.animation": "1.0.0", - "com.unity.burst": "1.7.3" + "com.unity.modules.uielements": "1.0.0" }, "url": "https://packages.unity.com" }, @@ -50,9 +50,9 @@ "depth": 1, "source": "registry", "dependencies": { - "com.unity.2d.animation": "9.1.1", "com.unity.2d.common": "8.0.2", - "com.unity.2d.sprite": "1.0.0" + "com.unity.2d.sprite": "1.0.0", + "com.unity.2d.animation": "9.1.1" }, "url": "https://packages.unity.com" }, @@ -63,12 +63,12 @@ "dependencies": {} }, "com.unity.2d.spriteshape": { - "version": "9.0.3", + "version": "9.0.4", "depth": 1, "source": "registry", "dependencies": { + "com.unity.2d.common": "8.0.3", "com.unity.mathematics": "1.1.0", - "com.unity.2d.common": "8.0.2", "com.unity.modules.physics2d": "1.0.0" }, "url": "https://packages.unity.com" @@ -87,9 +87,9 @@ "depth": 1, "source": "registry", "dependencies": { - "com.unity.modules.tilemap": "1.0.0", - "com.unity.2d.tilemap": "1.0.0", "com.unity.ugui": "1.0.0", + "com.unity.2d.tilemap": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0" }, "url": "https://packages.unity.com" @@ -117,13 +117,13 @@ "depth": 0, "source": "registry", "dependencies": { - "com.unity.services.analytics": "1.0.4", - "com.unity.ugui": "1.0.0" + "com.unity.ugui": "1.0.0", + "com.unity.services.analytics": "1.0.4" }, "url": "https://packages.unity.com" }, "com.unity.burst": { - "version": "1.8.16", + "version": "1.8.18", "depth": 3, "source": "registry", "dependencies": { @@ -133,7 +133,7 @@ "url": "https://packages.unity.com" }, "com.unity.collab-proxy": { - "version": "2.4.3", + "version": "2.5.1", "depth": 0, "source": "registry", "dependencies": {}, @@ -161,14 +161,14 @@ "depth": 0, "source": "builtin", "dependencies": { - "com.unity.2d.animation": "9.1.1", + "com.unity.2d.animation": "9.1.2", "com.unity.2d.pixel-perfect": "5.0.3", "com.unity.2d.psdimporter": "8.0.5", "com.unity.2d.sprite": "1.0.0", - "com.unity.2d.spriteshape": "9.0.3", + "com.unity.2d.spriteshape": "9.0.4", "com.unity.2d.tilemap": "1.0.0", "com.unity.2d.tilemap.extras": "3.1.2", - "com.unity.2d.aseprite": "1.1.4" + "com.unity.2d.aseprite": "1.1.6" } }, "com.unity.ide.rider": { @@ -216,10 +216,10 @@ "source": "registry", "dependencies": { "com.unity.ugui": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.services.core": "1.8.2", "com.unity.modules.androidjni": "1.0.0", - "com.unity.services.core": "1.8.2" + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" }, "url": "https://packages.unity.com" }, @@ -229,8 +229,8 @@ "source": "registry", "dependencies": { "com.unity.ugui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.services.core": "1.10.1" + "com.unity.services.core": "1.10.1", + "com.unity.modules.jsonserialize": "1.0.0" }, "url": "https://packages.unity.com" }, @@ -239,9 +239,9 @@ "depth": 1, "source": "registry", "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.androidjni": "1.0.0", "com.unity.nuget.newtonsoft-json": "3.2.1", - "com.unity.modules.androidjni": "1.0.0" + "com.unity.modules.unitywebrequest": "1.0.0" }, "url": "https://packages.unity.com" }, @@ -273,7 +273,7 @@ "url": "https://packages.unity.com" }, "com.unity.textmeshpro": { - "version": "3.0.6", + "version": "3.0.7", "depth": 0, "source": "registry", "dependencies": { @@ -286,9 +286,9 @@ "depth": 0, "source": "registry", "dependencies": { + "com.unity.modules.audio": "1.0.0", "com.unity.modules.director": "1.0.0", "com.unity.modules.animation": "1.0.0", - "com.unity.modules.audio": "1.0.0", "com.unity.modules.particlesystem": "1.0.0" }, "url": "https://packages.unity.com" @@ -317,17 +317,17 @@ "depth": 0, "source": "registry", "dependencies": { - "com.unity.2d.sprite": "1.0.0", "com.unity.ugui": "1.0.0", - "com.unity.modules.animation": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0", + "com.unity.2d.sprite": "1.0.0", + "com.unity.modules.ui": "1.0.0", "com.unity.modules.physics": "1.0.0", + "com.unity.modules.animation": "1.0.0", "com.unity.modules.physics2d": "1.0.0", - "com.unity.modules.ui": "1.0.0", "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.unitywebrequesttexture": "1.0.0", - "com.unity.modules.unitywebrequestwww": "1.0.0" + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0" }, "url": "https://packages.unity.com" }, @@ -342,7 +342,7 @@ "url": "https://packages.unity.com" }, "com.unity.xr.legacyinputhelpers": { - "version": "2.1.10", + "version": "2.1.11", "depth": 0, "source": "registry", "dependencies": { diff --git a/scripts/build_dev.ts b/scripts/build_dev.ts index 29e6065..e52c9cf 100755 --- a/scripts/build_dev.ts +++ b/scripts/build_dev.ts @@ -21,24 +21,30 @@ const target = { }`, }; -async function runCommand(cmd: string[], cwd?: string): Promise { - const command = new Deno.Command(cmd[0], { - args: cmd.slice(1), - cwd, - stdout: "inherit", - stderr: "inherit", - }); - const { code } = await command.output(); - if (code !== 0) throw new Error(`Command failed: ${cmd.join(" ")}`); -} - async function copyFile(src: string, dest: string): Promise { await ensureDir(dirname(dest)); await Deno.copyFile(src, dest); } // Build client -await runCommand(["cargo", "build", "--package", "rivet-toolchain-ffi"], toolchainRepoPath); +// const buildCommand = new Deno.Command("cargo", { +// args: ["+nightly", "build", "--package", "rivet-toolchain-ffi"], +// env: { +// "DYLD_INSERT_LIBRARIES": "/Users/nathan/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc-nightly_rt.asan.dylib", +// "RUSTFLAGS": "-Zsanitizer=address" +// }, +// cwd: toolchainRepoPath, +// stdout: "inherit", +// stderr: "inherit", +// }); +const buildCommand = new Deno.Command("cargo", { + args: ["build", "--package", "rivet-toolchain-ffi"], + cwd: toolchainRepoPath, + stdout: "inherit", + stderr: "inherit", +}); +const { code } = await buildCommand.output(); +if (code !== 0) throw new Error("Command failed: cargo build --package rivet-toolchain-ffi"); // Copy FFI library const ffiSrc = join( diff --git a/scripts/run_dev.ts b/scripts/run_dev.ts index aecb513..26b2353 100755 --- a/scripts/run_dev.ts +++ b/scripts/run_dev.ts @@ -64,4 +64,8 @@ if (!status.success) { Deno.exit(status.code); } -// lldb -o 'process launch -- -projectPath /Users/nathan/rivet/plugin-unity -logfile -' /Applications/Unity/Hub/Editor/2022.3.38f1/Unity.app/Contents/MacOS/Unity +// lldb -o 'process launch -- -projectPath /Users/nathan/rivet/plugin-unity -logfile /tmp/unity-log.txt' /Applications/Unity/Hub/Editor/2022.3.38f1/Unity.app/Contents/MacOS/Unity +// +// export MallocStackLogging=1 +// export MallocScribble=1 +// leaks --atExit --list --groupByType -- /Applications/Unity/Hub/Editor/2022.3.38f1/Unity.app/Contents/MacOS/Unity -projectPath /Users/nathan/rivet/plugin-unity -logfile /tmp/unity-log.txt