From 3524c095674a59dd307d6d99e533d792611b6854 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:19:04 +0000 Subject: [PATCH 01/19] Bump NUnit from 4.0.1 to 4.1.0 in /src Bumps [NUnit](https://github.com/nunit/nunit) from 4.0.1 to 4.1.0. - [Release notes](https://github.com/nunit/nunit/releases) - [Changelog](https://github.com/nunit/nunit/blob/master/CHANGES.md) - [Commits](https://github.com/nunit/nunit/compare/v4.0.1...4.1.0) --- updated-dependencies: - dependency-name: NUnit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../VoltstroStudios.UnityWebBrowser.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj b/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj index 58b35303..153413ca 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj +++ b/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj @@ -9,7 +9,7 @@ - + all From 8cc4002423d74555a9e261ede23ae4b094c8479f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:19:30 +0000 Subject: [PATCH 02/19] Bump coverlet.collector from 6.0.0 to 6.0.1 in /src Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.0...v6.0.1) --- updated-dependencies: - dependency-name: coverlet.collector dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../VoltstroStudios.UnityWebBrowser.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj b/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj index 58b35303..e28ca36d 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj +++ b/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj @@ -11,7 +11,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From d0d6f3d9193d7c48a3c57941711ac8c115a6b0a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:52:18 +0000 Subject: [PATCH 03/19] Bump vite from 5.1.3 to 5.1.4 in /src/UnityWebBrowser.Pages Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.3 to 5.1.4. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v5.1.4/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/UnityWebBrowser.Pages/package.json | 2 +- src/UnityWebBrowser.Pages/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UnityWebBrowser.Pages/package.json b/src/UnityWebBrowser.Pages/package.json index 3ad00519..6a41686f 100644 --- a/src/UnityWebBrowser.Pages/package.json +++ b/src/UnityWebBrowser.Pages/package.json @@ -11,7 +11,7 @@ "devDependencies": { "@types/node": "^20.4.8", "typescript": "^5.1.6", - "vite": "^5.0.12", + "vite": "^5.1.4", "vite-plugin-html": "^3.2.0", "vite-plugin-singlefile": "^1.0.0" } diff --git a/src/UnityWebBrowser.Pages/yarn.lock b/src/UnityWebBrowser.Pages/yarn.lock index a18f7edb..dda25906 100644 --- a/src/UnityWebBrowser.Pages/yarn.lock +++ b/src/UnityWebBrowser.Pages/yarn.lock @@ -842,10 +842,10 @@ vite-plugin-singlefile@^1.0.0: dependencies: micromatch "^4.0.5" -vite@^5.0.12: - version "5.1.3" - resolved "https://registry.yarnpkg.com/vite/-/vite-5.1.3.tgz#dd072653a80225702265550a4700561740dfde55" - integrity sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew== +vite@^5.1.4: + version "5.1.4" + resolved "https://registry.yarnpkg.com/vite/-/vite-5.1.4.tgz#14e9d3e7a6e488f36284ef13cebe149f060bcfb6" + integrity sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg== dependencies: esbuild "^0.19.3" postcss "^8.4.35" From 17e5d978302b7ba94be61948b15667339f408186 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:52:27 +0000 Subject: [PATCH 04/19] Bump vite-plugin-singlefile in /src/UnityWebBrowser.Pages Bumps [vite-plugin-singlefile](https://github.com/richardtallent/vite-plugin-singlefile) from 1.0.0 to 2.0.0. - [Changelog](https://github.com/richardtallent/vite-plugin-singlefile/blob/main/CHANGELOG.md) - [Commits](https://github.com/richardtallent/vite-plugin-singlefile/commits) --- updated-dependencies: - dependency-name: vite-plugin-singlefile dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- src/UnityWebBrowser.Pages/package.json | 2 +- src/UnityWebBrowser.Pages/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UnityWebBrowser.Pages/package.json b/src/UnityWebBrowser.Pages/package.json index 3ad00519..07648ddc 100644 --- a/src/UnityWebBrowser.Pages/package.json +++ b/src/UnityWebBrowser.Pages/package.json @@ -13,6 +13,6 @@ "typescript": "^5.1.6", "vite": "^5.0.12", "vite-plugin-html": "^3.2.0", - "vite-plugin-singlefile": "^1.0.0" + "vite-plugin-singlefile": "^2.0.0" } } diff --git a/src/UnityWebBrowser.Pages/yarn.lock b/src/UnityWebBrowser.Pages/yarn.lock index a18f7edb..31500375 100644 --- a/src/UnityWebBrowser.Pages/yarn.lock +++ b/src/UnityWebBrowser.Pages/yarn.lock @@ -835,10 +835,10 @@ vite-plugin-html@^3.2.0: node-html-parser "^5.3.3" pathe "^0.2.0" -vite-plugin-singlefile@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/vite-plugin-singlefile/-/vite-plugin-singlefile-1.0.0.tgz#e69032ff6539f691b29ca80b06293c609a2158dc" - integrity sha512-iVAxl0t7gndQrznI4kI14hqAGxhVL7FQndeTdvTIH5/CbwpR2asgD3XSTsd7iWC83YTCmwAmsHIQvKdIdnHu7w== +vite-plugin-singlefile@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/vite-plugin-singlefile/-/vite-plugin-singlefile-2.0.0.tgz#b25a8cdb90def1c602d63f795f10d321abb0e7d0" + integrity sha512-0ADuhM0nLSTJAm/KhRLCHiAIhlmR70MajcLfJlIflbsPj02sKEQErzsiPhuSg/jt1nKBi7oLmuX718tYI2Fjdg== dependencies: micromatch "^4.0.5" From 688a90a3d033309229a3132133aef1e195f22f36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:52:37 +0000 Subject: [PATCH 05/19] Bump @types/node from 20.11.19 to 20.11.24 in /src/UnityWebBrowser.Pages Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.11.19 to 20.11.24. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/UnityWebBrowser.Pages/package.json | 2 +- src/UnityWebBrowser.Pages/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UnityWebBrowser.Pages/package.json b/src/UnityWebBrowser.Pages/package.json index 3ad00519..cb99f982 100644 --- a/src/UnityWebBrowser.Pages/package.json +++ b/src/UnityWebBrowser.Pages/package.json @@ -9,7 +9,7 @@ "preview": "vite preview" }, "devDependencies": { - "@types/node": "^20.4.8", + "@types/node": "^20.11.24", "typescript": "^5.1.6", "vite": "^5.0.12", "vite-plugin-html": "^3.2.0", diff --git a/src/UnityWebBrowser.Pages/yarn.lock b/src/UnityWebBrowser.Pages/yarn.lock index a18f7edb..46d60492 100644 --- a/src/UnityWebBrowser.Pages/yarn.lock +++ b/src/UnityWebBrowser.Pages/yarn.lock @@ -256,10 +256,10 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== -"@types/node@^20.4.8": - version "20.11.19" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.19.tgz#b466de054e9cb5b3831bee38938de64ac7f81195" - integrity sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ== +"@types/node@^20.11.24": + version "20.11.24" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.24.tgz#cc207511104694e84e9fb17f9a0c4c42d4517792" + integrity sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long== dependencies: undici-types "~5.26.4" From 847063d6fa9d1f4d595077806525d8da67670155 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Sat, 16 Mar 2024 22:07:19 +1000 Subject: [PATCH 06/19] Linux set process to kill it self when parent process dies --- .../Core/EngineEntryPoint.cs | 11 +++++++++ .../Native/Linux/SysPrctl.cs | 23 +++++++++++++++++++ ...udios.UnityWebBrowser.Engine.Shared.csproj | 3 +++ 3 files changed, 37 insertions(+) create mode 100644 src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Native/Linux/SysPrctl.cs diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs index e5a189f9..ece4537d 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs @@ -17,6 +17,10 @@ using VoltstroStudios.UnityWebBrowser.Engine.Shared.Popups; using VoltstroStudios.UnityWebBrowser.Engine.Shared.ReadWriters; +#if LINUX +using VoltstroStudios.UnityWebBrowser.Engine.Shared.Native.Linux; +#endif + namespace VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; /// @@ -69,6 +73,13 @@ internal abstract class EngineEntryPoint : IDisposable /// public int Main(string[] args) { + #if LINUX + //On Linux, tell this child process to kill it self when it's parent process dies + //Option: 1 -> PR_SET_PDEATHSIG (include/uapi/linux/prctl.h) + //Arg2: 9 -> SIGKILL (arch/x86/include/uapi/asm/signal.h) + SysPrctl.prctl(1, 9); + #endif + //We got a lot of arguments //Url to start with diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Native/Linux/SysPrctl.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Native/Linux/SysPrctl.cs new file mode 100644 index 00000000..c086a750 --- /dev/null +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Native/Linux/SysPrctl.cs @@ -0,0 +1,23 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +namespace VoltstroStudios.UnityWebBrowser.Engine.Shared.Native.Linux; + +[SupportedOSPlatform("Linux")] +internal static class SysPrctl +{ + /// + /// Operations on a process or thread + /// https://www.man7.org/linux/man-pages/man2/prctl.2.html + /// + /// + /// + /// + [DllImport("libc")] + public static extern int prctl(int option, ulong arg2); +} \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/VoltstroStudios.UnityWebBrowser.Engine.Shared.csproj b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/VoltstroStudios.UnityWebBrowser.Engine.Shared.csproj index 1c570a7e..445dffd1 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/VoltstroStudios.UnityWebBrowser.Engine.Shared.csproj +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/VoltstroStudios.UnityWebBrowser.Engine.Shared.csproj @@ -1,5 +1,6 @@ + @@ -31,4 +32,6 @@ + + From b0220427c2ca52697b21c0aeaead7ac5949754e7 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Sat, 16 Mar 2024 22:10:17 +1000 Subject: [PATCH 07/19] Upgrade Unity project to 2021.3.36f1 --- .../ProjectSettings/ProjectVersion.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt b/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt index 39a629e9..26d0e2da 100644 --- a/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt +++ b/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.35f1 -m_EditorVersionWithRevision: 2021.3.35f1 (157b46ce122a) +m_EditorVersion: 2021.3.36f1 +m_EditorVersionWithRevision: 2021.3.36f1 (7a0645017be0) From 6b00a68d53c32fee0d2ffd23fceb3bf65d2777e3 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Sat, 16 Mar 2024 22:15:41 +1000 Subject: [PATCH 08/19] Improve StartListening on both engine and core to catch binding errors --- .../Core/WebBrowserCommunicationsManager.cs | 16 +++++++++- .../Core/EngineEntryPoint.cs | 29 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs index d4453fe6..80d13f16 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs @@ -201,7 +201,21 @@ public void Connect() public void Listen() { - ipcHost.StartListeningAsync().ConfigureAwait(false); + UniTask.RunOnThreadPool(async () => + { + + try + { + ipcHost.StartListening(); + } + catch (Exception) + { + await using (UniTask.ReturnToMainThread()) + { + throw; + } + } + }); } private void ExecuteOnUnity(Action action, [CallerMemberName] string memberName = "") diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs index ece4537d..655c9551 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs @@ -7,6 +7,7 @@ using System.CommandLine; using System.IO; using System.Threading; +using System.Threading.Tasks; using VoltstroStudios.UnityWebBrowser.Shared; using VoltstroStudios.UnityWebBrowser.Shared.Communications; using VoltstroStudios.UnityWebBrowser.Shared.Core; @@ -232,18 +233,23 @@ internal void SetupIpc(IEngineControls engineControls, LaunchArguments arguments { try { + Logger.Debug($"{Logger.BaseLoggingTag}: SetupIcp."); + ICommunicationLayer communicationLayer; if (arguments.CommunicationLayerPath == null) { //Use TCP Logger.Debug($"{Logger.BaseLoggingTag}: No communication layer provided, using default TCP..."); communicationLayer = new TCPCommunicationLayer(); + Logger.Debug($"{Logger.BaseLoggingTag}: Created default TCP communication layer."); } else { communicationLayer = CommunicationLayerLoader.GetCommunicationLayerFromAssembly( arguments.CommunicationLayerPath.FullName); } + + Logger.Debug($"{Logger.BaseLoggingTag}: Created communication layer of type '{communicationLayer.GetType().FullName}'..."); try { @@ -256,22 +262,43 @@ internal void SetupIpc(IEngineControls engineControls, LaunchArguments arguments ShutdownAndExitWithError(); return; } + + Logger.Debug($"{Logger.BaseLoggingTag}: Created host and client from communication layer."); //Add type readers EngineReadWritersManager.AddTypeReadWriters(ipcHost.TypeReaderWriterManager); ipcHost.AddService(typeof(IEngineControls), engineControls); ipcHost.AddService(typeof(IPopupClientControls), PopupManager); - ipcHost.StartListeningAsync().ConfigureAwait(false); + Logger.Debug($"{Logger.BaseLoggingTag}: Installed services on host."); + + Task.Run(() => + { + try + { + ipcHost.StartListening(); + } + catch (Exception ex) + { + Logger.Error(ex, $"{Logger.BaseLoggingTag}: An error occured listening on host!"); + ShutdownAndExitWithError(); + } + }); + + Logger.Debug($"{Logger.BaseLoggingTag}: Host has started listening."); EngineReadWritersManager.AddTypeReadWriters(ipcClient.TypeReaderWriterManager); ipcClient.AddService(typeof(IClientControls)); ipcClient.AddService(typeof(IPopupEngineControls)); + + Logger.Debug($"{Logger.BaseLoggingTag}: Installed services on client."); //Connect the engine (us) back to Unity try { ipcClient.Connect(); + Logger.Debug($"{Logger.BaseLoggingTag}: Client has connected back to Unity."); + ClientControlsActions.SetIpcClient(ipcClient); PopupManager.SetIpcClient(ipcClient); } From f1f61b100eabddba3596b5b64df687ffd8081ba9 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Sun, 17 Mar 2024 13:45:23 +1000 Subject: [PATCH 09/19] Move engine process management to separate class Windows uses "Job Objects" to manage child processes --- .../Runtime/Core/Engines/EngineProcess.cs | 53 ++++++ .../Core/Engines/EngineProcess.cs.meta | 3 + .../Runtime/Core/Engines/Process.meta | 3 + .../Runtime/Core/Engines/Process/IProcess.cs | 21 +++ .../Core/Engines/Process/IProcess.cs.meta | 3 + .../Core/Engines/Process/WindowProcess.cs | 165 ++++++++++++++++++ .../Engines/Process/WindowProcess.cs.meta | 3 + .../Runtime/Core/WebBrowserClient.cs | 12 +- 8 files changed, 258 insertions(+), 5 deletions(-) create mode 100644 src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs create mode 100644 src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs.meta create mode 100644 src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process.meta create mode 100644 src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/IProcess.cs create mode 100644 src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/IProcess.cs.meta create mode 100644 src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs create mode 100644 src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs.meta diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs new file mode 100644 index 00000000..e4cb18c0 --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs @@ -0,0 +1,53 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using System; +using System.Diagnostics; +using VoltstroStudios.UnityWebBrowser.Core.Engines.Process; +using VoltstroStudios.UnityWebBrowser.Helper; +using VoltstroStudios.UnityWebBrowser.Logging; + +namespace VoltstroStudios.UnityWebBrowser.Core.Engines +{ + internal sealed class EngineProcess : IDisposable + { + private readonly IProcess processHandle; + private readonly Engine engine; + private readonly IWebBrowserLogger logger; + + public EngineProcess(Engine engine, IWebBrowserLogger logger) + { + processHandle = new WindowProcess(); + + this.engine = engine; + this.logger = logger; + } + + public bool HasExited => processHandle.HasExited; + + public int ExitCode => processHandle.ExitCode; + + public void StartProcess(string arguments, DataReceivedEventHandler onLogEvent, DataReceivedEventHandler onErrorLogEvent) + { + string engineFullProcessPath = WebBrowserUtils.GetBrowserEngineProcessPath(engine); + string engineDirectory = WebBrowserUtils.GetBrowserEnginePath(engine); + + logger.Debug($"Process Path: '{engineFullProcessPath}'\nWorking: '{engineDirectory}'"); + logger.Debug($"Arguments: '{arguments}'"); + + processHandle.StartProcess(engineFullProcessPath, engineDirectory, arguments, onLogEvent, onErrorLogEvent); + } + + public void KillProcess() + { + processHandle.KillProcess(); + } + + public void Dispose() + { + processHandle.Dispose(); + } + } +} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs.meta b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs.meta new file mode 100644 index 00000000..8b0dbb2d --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f2e81fb75c844780b3c94017f7f950ed +timeCreated: 1710591696 \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process.meta b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process.meta new file mode 100644 index 00000000..5a39982d --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8591b53ed5974efa8b245658ff172eb6 +timeCreated: 1710591731 \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/IProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/IProcess.cs new file mode 100644 index 00000000..ebbc6300 --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/IProcess.cs @@ -0,0 +1,21 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using System; +using System.Diagnostics; + +namespace VoltstroStudios.UnityWebBrowser.Core.Engines.Process +{ + internal interface IProcess : IDisposable + { + public void StartProcess(string executable, string workingDir, string arguments, DataReceivedEventHandler onLogEvent, DataReceivedEventHandler onErrorLogEvent); + + public void KillProcess(); + + public bool HasExited { get; } + + public int ExitCode { get; } + } +} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/IProcess.cs.meta b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/IProcess.cs.meta new file mode 100644 index 00000000..41e0ccca --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/IProcess.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9b70068bc1654874b98712207c280d40 +timeCreated: 1710591751 \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs new file mode 100644 index 00000000..c2997c83 --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs @@ -0,0 +1,165 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace VoltstroStudios.UnityWebBrowser.Core.Engines.Process +{ + internal sealed class WindowProcess : IProcess + { + private readonly System.Diagnostics.Process process; + private readonly IntPtr jobHandle; + + public WindowProcess() + { + //Job handle code from SO + //https://stackoverflow.com/questions/3342941/kill-child-process-when-parent-process-is-killed + string jobName = "UWBChildProcesses" + System.Diagnostics.Process.GetCurrentProcess().Id; + jobHandle = CreateJobObject(IntPtr.Zero, jobName); + + JOBOBJECT_BASIC_LIMIT_INFORMATION info = new() + { + // This is the key flag. When our process is killed, Windows will automatically + // close the job handle, and when that happens, we want the child processes to + // be killed, too. + LimitFlags = JOBOBJECTLIMIT.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE + }; + + JOBOBJECT_EXTENDED_LIMIT_INFORMATION extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION + { + BasicLimitInformation = info + }; + + int length = Marshal.SizeOf(typeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION)); + IntPtr extendedInfoPtr = Marshal.AllocHGlobal(length); + try + { + Marshal.StructureToPtr(extendedInfo, extendedInfoPtr, false); + + if (!SetInformationJobObject(jobHandle, JobObjectInfoType.ExtendedLimitInformation, + extendedInfoPtr, (uint)length)) + { + throw new Win32Exception(); + } + } + finally + { + Marshal.FreeHGlobal(extendedInfoPtr); + } + + process = new System.Diagnostics.Process(); + } + + public void StartProcess(string executable, string workingDir, string arguments, DataReceivedEventHandler onLogEvent, DataReceivedEventHandler onErrorLogEvent) + { + ProcessStartInfo startInfo = new(executable, arguments) + { + CreateNoWindow = true, + UseShellExecute = false, + RedirectStandardOutput = true, + RedirectStandardError = true, + WorkingDirectory = workingDir + }; + + process.StartInfo = startInfo; + process.OutputDataReceived += onLogEvent; + process.ErrorDataReceived += onErrorLogEvent; + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + + //Assign this process to the job handle + bool success = AssignProcessToJobObject(jobHandle, process.Handle); + if (!success && !process.HasExited) + throw new Win32Exception(); + } + + public void KillProcess() + { + TerminateJobObject(jobHandle, 0); + } + + public bool HasExited => process.HasExited; + public int ExitCode => process.ExitCode; + + public void Dispose() + { + process.Dispose(); + } + + #region WIN32 Native + + [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + private static extern IntPtr CreateJobObject(IntPtr lpJobAttributes, string name); + + [DllImport("kernel32.dll")] + private static extern bool SetInformationJobObject(IntPtr job, JobObjectInfoType infoType, + IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength); + + [DllImport("kernel32.dll", SetLastError = true)] + private static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process); + + [DllImport("kernel32.dll", SetLastError = true)] + private static extern bool TerminateJobObject(IntPtr job, uint exitCode); + + public enum JobObjectInfoType + { + AssociateCompletionPortInformation = 7, + BasicLimitInformation = 2, + BasicUIRestrictions = 4, + EndOfJobTimeInformation = 6, + ExtendedLimitInformation = 9, + SecurityLimitInformation = 5, + GroupInformation = 11 + } + + [StructLayout(LayoutKind.Sequential)] + public struct JOBOBJECT_BASIC_LIMIT_INFORMATION + { + public Int64 PerProcessUserTimeLimit; + public Int64 PerJobUserTimeLimit; + public JOBOBJECTLIMIT LimitFlags; + public UIntPtr MinimumWorkingSetSize; + public UIntPtr MaximumWorkingSetSize; + public UInt32 ActiveProcessLimit; + public Int64 Affinity; + public UInt32 PriorityClass; + public UInt32 SchedulingClass; + } + + [Flags] + public enum JOBOBJECTLIMIT : uint + { + JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x2000 + } + + [StructLayout(LayoutKind.Sequential)] + public struct IO_COUNTERS + { + public UInt64 ReadOperationCount; + public UInt64 WriteOperationCount; + public UInt64 OtherOperationCount; + public UInt64 ReadTransferCount; + public UInt64 WriteTransferCount; + public UInt64 OtherTransferCount; + } + + [StructLayout(LayoutKind.Sequential)] + public struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION + { + public JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation; + public IO_COUNTERS IoInfo; + public UIntPtr ProcessMemoryLimit; + public UIntPtr JobMemoryLimit; + public UIntPtr PeakProcessMemoryUsed; + public UIntPtr PeakJobMemoryUsed; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs.meta b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs.meta new file mode 100644 index 00000000..0cdeb5ae --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cd292e9a15ed4d0988b40ce3ebc5c79a +timeCreated: 1710591740 \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs index f4712627..2bd1449a 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs @@ -255,7 +255,7 @@ public IWebBrowserLogger Logger #endregion - private Process engineProcess; + private EngineProcess engineProcess; private WebBrowserCommunicationsManager communicationsManager; private CancellationTokenSource cancellationSource; @@ -409,9 +409,10 @@ private UniTask StartEngineProcess(string engineProcessArguments) { try { + //TODO: Move process log handler to engine process class processLogHandler = new ProcessLogHandler(this); - engineProcess = WebBrowserUtils.CreateEngineProcess(logger, engine, engineProcessArguments, - processLogHandler.HandleOutputProcessLog, processLogHandler.HandleErrorProcessLog); + engineProcess = new EngineProcess(engine, logger); + engineProcess.StartProcess(engineProcessArguments, processLogHandler.HandleOutputProcessLog, processLogHandler.HandleErrorProcessLog); } catch (Exception ex) { @@ -1098,8 +1099,9 @@ private void ReleaseResources() //Kill the process if we haven't already if (engineProcess != null) { - engineProcess.KillTree(); - + if (!engineProcess.HasExited) + engineProcess.KillProcess(); + engineProcess.Dispose(); engineProcess = null; } From 4b5d353446a36cb1e5c40f2f7bf4ede69ca2ab8b Mon Sep 17 00:00:00 2001 From: Voltstro Date: Sun, 17 Mar 2024 16:48:56 +1000 Subject: [PATCH 10/19] Shutdown UWB on domain reload --- .../Runtime/Core/WebBrowserClient.cs | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs index 2bd1449a..39ed41db 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs @@ -176,6 +176,11 @@ public Resolution Resolution /// The UWB engine has signaled that it is ready /// public bool ReadySignalReceived { get; internal set; } + + /// + /// Has UWB initialized + /// + public bool HasInitialized { get; internal set; } /// /// Internal FPS of pixels communication between Unity and the Engine @@ -384,9 +389,14 @@ internal void Init() //Setup communication manager communicationsManager = new WebBrowserCommunicationsManager(this); communicationsManager.Listen(); - - cancellationSource = new CancellationTokenSource(); - + +#if UNITY_EDITOR + //Install reload events handler + UnityEditor.AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload; +#endif + + //Mark has initialized and invoke event + HasInitialized = true; try { OnClientInitialized?.Invoke(); @@ -395,6 +405,8 @@ internal void Init() { logger.Error($"Error invoking OnClientInitialized! {ex}"); } + + cancellationSource = new CancellationTokenSource(); //Start the engine process UniTask.Create(() => @@ -1033,6 +1045,17 @@ internal void InvokeJsMethod(ExecuteJsMethod executeJsMethod) #region Destroying +#if UNITY_EDITOR + private void OnBeforeAssemblyReload() + { + if (HasInitialized) + { + logger.Warn("UWB is shutting down due to incoming domain reload. UWB does not support domain reloading while running."); + Dispose(); + } + } +#endif + #if !UNITY_EDITOR ~WebBrowserClient() { From ad4cdf2c1cd60332638910868d99f9c00626e316 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Sun, 17 Mar 2024 16:53:18 +1000 Subject: [PATCH 11/19] Better prevention of null reference errors in input handler --- .../Runtime/Core/RawImageUwbClientInputHandler.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/RawImageUwbClientInputHandler.cs b/src/Packages/UnityWebBrowser/Runtime/Core/RawImageUwbClientInputHandler.cs index 4c0f65bf..4b65fb01 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/RawImageUwbClientInputHandler.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/RawImageUwbClientInputHandler.cs @@ -45,6 +45,9 @@ public void OnPointerDown(PointerEventData eventData) { if (disableMouseInputs) return; + + if (browserClient is { IsConnected: false }) + return; MouseClickType clickType = eventData.button switch { @@ -75,6 +78,9 @@ public void OnPointerUp(PointerEventData eventData) { if (disableMouseInputs) return; + + if (browserClient is { IsConnected: false }) + return; MouseClickType clickType = eventData.button switch { @@ -99,6 +105,9 @@ protected override void OnStart() private void OnClientInput(bool focused) { + if (browserClient is { IsConnected: false }) + return; + if (focused) { if (!GetMousePosition(out Vector2 pos)) return; From 1fd7c59f94e87e1cd2202c9bb10b6a67654acaf9 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Sun, 17 Mar 2024 17:06:38 +1000 Subject: [PATCH 12/19] Linux process implementation --- .../Runtime/Core/Engines/EngineProcess.cs | 29 +++- .../Core/Engines/Process/LinuxProcess.cs | 126 ++++++++++++++++++ .../Core/Engines/Process/LinuxProcess.cs.meta | 3 + .../Core/Engines/Process/WindowProcess.cs | 6 +- 4 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs create mode 100644 src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs.meta diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs index e4cb18c0..9c3f89b3 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs @@ -11,25 +11,49 @@ namespace VoltstroStudios.UnityWebBrowser.Core.Engines { + /// + /// Handler for the engine process + /// internal sealed class EngineProcess : IDisposable { private readonly IProcess processHandle; private readonly Engine engine; private readonly IWebBrowserLogger logger; + /// + /// Creates a new instance + /// + /// + /// public EngineProcess(Engine engine, IWebBrowserLogger logger) { +#if UNITY_STANDALONE_WIN processHandle = new WindowProcess(); +#elif UNITY_STANDALONE_LINUX + processHandle = new LinuxProcess(); +#endif this.engine = engine; this.logger = logger; } + /// + /// Has the process exited? + /// public bool HasExited => processHandle.HasExited; + /// + /// What was the exit code of the process + /// public int ExitCode => processHandle.ExitCode; - public void StartProcess(string arguments, DataReceivedEventHandler onLogEvent, DataReceivedEventHandler onErrorLogEvent) + /// + /// Starts the engine process + /// + /// + /// + /// + public void StartProcess(string arguments, DataReceivedEventHandler onLogEvent, DataReceivedEventHandler onErrorLogEvent) { string engineFullProcessPath = WebBrowserUtils.GetBrowserEngineProcessPath(engine); string engineDirectory = WebBrowserUtils.GetBrowserEnginePath(engine); @@ -40,6 +64,9 @@ public void StartProcess(string arguments, DataReceivedEventHandler onLogEvent, processHandle.StartProcess(engineFullProcessPath, engineDirectory, arguments, onLogEvent, onErrorLogEvent); } + /// + /// Kills the engine process + /// public void KillProcess() { processHandle.KillProcess(); diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs new file mode 100644 index 00000000..9d4ec3e7 --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs @@ -0,0 +1,126 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +#if UNITY_STANDALONE_LINUX + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using VoltstroStudios.UnityWebBrowser.Logging; +using VoltstroStudios.UnityWebBrowser.UnixSupport; + +namespace VoltstroStudios.UnityWebBrowser.Core.Engines.Process +{ + internal sealed class LinuxProcess : IProcess + { + private readonly System.Diagnostics.Process process; + private readonly IWebBrowserLogger logger; + + public LinuxProcess(IWebBrowserLogger logger) + { + process = new System.Diagnostics.Process(); + this.logger = logger; + } + + public bool HasExited { get; } + public int ExitCode { get; } + + public void StartProcess(string executable, string workingDir, string arguments, DataReceivedEventHandler onLogEvent, + DataReceivedEventHandler onErrorLogEvent) + { + if (PermissionsManager.CheckAndSetIfNeededFileExecutablePermission(executable)) + logger.Warn( + "UWB engine process did not have +rwx permissions! Engine process permission's were updated for the user."); + + ProcessStartInfo startInfo = new(executable, arguments) + { + CreateNoWindow = true, + UseShellExecute = false, + RedirectStandardOutput = true, + RedirectStandardError = true, + WorkingDirectory = workingDir + }; + + process.StartInfo = startInfo; + process.OutputDataReceived += onLogEvent; + process.ErrorDataReceived += onErrorLogEvent; + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + } + + public void KillProcess() + { + TimeSpan timeout = TimeSpan.FromSeconds(30); + HashSet children = new(); + GetAllChildIdsUnix(process.Id, children, timeout); + foreach (int childId in children) KillProcessUnix(childId, timeout); + KillProcessUnix(process.Id, timeout); + } + + public void Dispose() + { + process.Dispose(); + } + + private static void GetAllChildIdsUnix(int parentId, ISet children, TimeSpan timeout) + { + int exitCode = RunProcessAndWaitForExit( + "pgrep", + $"-P {parentId}", + timeout, + out string stdout); + + if (exitCode != 0 || string.IsNullOrEmpty(stdout)) return; + using StringReader reader = new(stdout); + while (true) + { + string text = reader.ReadLine(); + if (text == null) return; + + if (!int.TryParse(text, out int id)) continue; + + children.Add(id); + // Recursively get the children + GetAllChildIdsUnix(id, children, timeout); + } + } + + private static void KillProcessUnix(int processId, TimeSpan timeout) + { + RunProcessAndWaitForExit( + "kill", + $"-TERM {processId}", + timeout, + out string _); + } + + private static int RunProcessAndWaitForExit(string fileName, string arguments, TimeSpan timeout, + out string stdout) + { + ProcessStartInfo startInfo = new() + { + FileName = fileName, + Arguments = arguments, + RedirectStandardOutput = true, + UseShellExecute = false, + CreateNoWindow = true + }; + + System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo); + + stdout = null; + if (process.WaitForExit((int)timeout.TotalMilliseconds)) + stdout = process.StandardOutput.ReadToEnd(); + else + process.Kill(); + + return process.ExitCode; + } + } +} + +#endif \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs.meta b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs.meta new file mode 100644 index 00000000..3c284244 --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 43c55047f2ed460cba1d6f13bfb9fe74 +timeCreated: 1710658748 \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs index c2997c83..08fea8d1 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs @@ -3,6 +3,8 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. +#if UNITY_STANDALONE_WIN + using System; using System.ComponentModel; using System.Diagnostics; @@ -162,4 +164,6 @@ public struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION #endregion } -} \ No newline at end of file +} + +#endif \ No newline at end of file From 3f39aa79f364db9ba2d123f8b6459ac96d1026de Mon Sep 17 00:00:00 2001 From: Voltstro Date: Sun, 17 Mar 2024 17:16:19 +1000 Subject: [PATCH 13/19] Ensure beforeAssemblyReload is unsubscribed from Check HasDisposed in OnBeforeAssemblyReload --- .../UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs | 2 +- .../UnityWebBrowser/Runtime/Core/WebBrowserClient.cs | 7 ++++++- .../Runtime/Core/WebBrowserCommunicationsManager.cs | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs index 9c3f89b3..79ac4690 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs @@ -30,7 +30,7 @@ public EngineProcess(Engine engine, IWebBrowserLogger logger) #if UNITY_STANDALONE_WIN processHandle = new WindowProcess(); #elif UNITY_STANDALONE_LINUX - processHandle = new LinuxProcess(); + processHandle = new LinuxProcess(logger); #endif this.engine = engine; diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs index 39ed41db..5fcc8d01 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs @@ -1048,7 +1048,7 @@ internal void InvokeJsMethod(ExecuteJsMethod executeJsMethod) #if UNITY_EDITOR private void OnBeforeAssemblyReload() { - if (HasInitialized) + if (HasInitialized && !HasDisposed) { logger.Warn("UWB is shutting down due to incoming domain reload. UWB does not support domain reloading while running."); Dispose(); @@ -1128,6 +1128,11 @@ private void ReleaseResources() engineProcess.Dispose(); engineProcess = null; } + +#if UNITY_EDITOR + //Install reload events handler + UnityEditor.AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload; +#endif //Dispose of buffers if (resizeLock == null) diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs index 80d13f16..7d1f9b23 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs @@ -203,7 +203,6 @@ public void Listen() { UniTask.RunOnThreadPool(async () => { - try { ipcHost.StartListening(); From f1b18a4b403938843e653002059ccc6e5a7f04aa Mon Sep 17 00:00:00 2001 From: Voltstro Date: Sun, 17 Mar 2024 17:30:23 +1000 Subject: [PATCH 14/19] Improve cancellation in coms manager --- .../UnityWebBrowser/Runtime/Core/WebBrowserClient.cs | 5 ++--- .../Runtime/Core/WebBrowserCommunicationsManager.cs | 10 +++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs index 5fcc8d01..3fe0a0f9 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs @@ -387,7 +387,8 @@ internal void Init() string arguments = argsBuilder.ToString(); //Setup communication manager - communicationsManager = new WebBrowserCommunicationsManager(this); + cancellationSource = new CancellationTokenSource(); + communicationsManager = new WebBrowserCommunicationsManager(this, cancellationSource); communicationsManager.Listen(); #if UNITY_EDITOR @@ -405,8 +406,6 @@ internal void Init() { logger.Error($"Error invoking OnClientInitialized! {ex}"); } - - cancellationSource = new CancellationTokenSource(); //Start the engine process UniTask.Create(() => diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs index 7d1f9b23..adc14e1e 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserCommunicationsManager.cs @@ -42,12 +42,14 @@ internal class WebBrowserCommunicationsManager : IEngineControls, IClientControl private readonly object threadLock; private readonly SynchronizationContext unityThread; + private readonly CancellationTokenSource cancellationTokenSource; /// /// Creates a new instance /// /// - public WebBrowserCommunicationsManager(WebBrowserClient browserClient) + /// + public WebBrowserCommunicationsManager(WebBrowserClient browserClient, CancellationTokenSource cancellationTokenSource) { threadLock = new object(); unityThread = SynchronizationContext.Current; @@ -72,6 +74,7 @@ public WebBrowserCommunicationsManager(WebBrowserClient browserClient) ipcClient.AddService(); ipcClient.AddService(); engineProxy = new EngineControls(ipcClient); + this.cancellationTokenSource = cancellationTokenSource; } /// @@ -211,10 +214,11 @@ public void Listen() { await using (UniTask.ReturnToMainThread()) { - throw; + if(!cancellationTokenSource.IsCancellationRequested) + throw; } } - }); + }, true, cancellationTokenSource.Token); } private void ExecuteOnUnity(Action action, [CallerMemberName] string memberName = "") From e432985d818ee4c41750f94e2cdac855b702e2f6 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Fri, 22 Mar 2024 12:55:16 +1000 Subject: [PATCH 15/19] Update CEF to 122.1.13 Upgrade Unity project to 2021.3.36f1 --- .../UnityWebBrowser.Engine.Cef.Linux-x64/package.json | 4 ++-- src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json | 4 ++-- src/Packages/UnityWebBrowser.Engine.Cef/package.json | 2 +- src/ThirdParty/CefGlue | 2 +- .../UnityWebBrowser.Engine.Cef.csproj | 2 +- src/UnityWebBrowser.UnityProject/Packages/packages-lock.json | 4 ++-- .../ProjectSettings/ProjectVersion.txt | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json b/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json index e69324ba..89b9a323 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json @@ -13,11 +13,11 @@ "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", "unity": "2021.2", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-121.3.13", + "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-122.1.13", "dev.voltstro.unitywebbrowser.unix-support": "1.0.0" }, "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", "description": "CEF Engine for Unity Web Browser (Linux x64)", "displayName": "Unity Web Browser CEF Engine (Linux x64)", - "version": "2.1.0-121.3.13" + "version": "2.1.0-122.1.13" } diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json b/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json index ea6bcd89..486c9668 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json @@ -13,10 +13,10 @@ "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", "unity": "2021.2", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-121.3.13" + "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-122.1.13" }, "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", "description": "CEF Engine for Unity Web Browser (Windows x64)", "displayName": "Unity Web Browser CEF Engine (Windows x64)", - "version": "2.1.0-121.3.13" + "version": "2.1.0-122.1.13" } diff --git a/src/Packages/UnityWebBrowser.Engine.Cef/package.json b/src/Packages/UnityWebBrowser.Engine.Cef/package.json index 631aac2f..fbde44cf 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef/package.json @@ -3,7 +3,7 @@ "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", "description": "CEF Engine for Unity Web Browser", "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", - "version": "2.1.0-121.3.13", + "version": "2.1.0-122.1.13", "author": { "email": "me@voltstro.dev", "url": "https://voltstro.dev", diff --git a/src/ThirdParty/CefGlue b/src/ThirdParty/CefGlue index cbd1fc56..1f5a4fa3 160000 --- a/src/ThirdParty/CefGlue +++ b/src/ThirdParty/CefGlue @@ -1 +1 @@ -Subproject commit cbd1fc562a5bca627eb9a902d84a87605e370588 +Subproject commit 1f5a4fa3799900b574706c87c954bf1f68f0da51 diff --git a/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj b/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj index 8267a207..4998e077 100644 --- a/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj +++ b/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj @@ -10,7 +10,7 @@ chromium-logo.ico External process to handel rendering with CEF win-x64;linux-x64;osx-x64 - 2.1.0-121.3.13 + 2.1.0-122.1.13 BROWSER_PROCESS diff --git a/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json b/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json index 79a92f30..3bc3396b 100644 --- a/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json +++ b/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json @@ -181,7 +181,7 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-121.3.13", + "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-122.1.13", "dev.voltstro.unitywebbrowser.unix-support": "1.0.0" } }, @@ -199,7 +199,7 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-121.3.13" + "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-122.1.13" } }, "dev.voltstro.unitywebbrowser.unix-support": { diff --git a/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt b/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt index 39a629e9..26d0e2da 100644 --- a/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt +++ b/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.35f1 -m_EditorVersionWithRevision: 2021.3.35f1 (157b46ce122a) +m_EditorVersion: 2021.3.36f1 +m_EditorVersionWithRevision: 2021.3.36f1 (7a0645017be0) From 4b66dd1b8441fd681d6d45509353fdbc67cce0df Mon Sep 17 00:00:00 2001 From: Voltstro Date: Fri, 22 Mar 2024 15:42:39 +1000 Subject: [PATCH 16/19] Add UWB Runtime demo/example --- src/Packages/UnityWebBrowser/package.json | 7 +- .../Assets/Scenes/UWB.unity | 6 +- .../Assets/Scenes/UWBRuntime.unity | 314 ++++++++++++++++++ .../Assets/Scenes/UWBRuntime.unity.meta | 7 + .../Assets/Scripts/UWBRuntime.cs | 92 +++++ .../Assets/Scripts/UWBRuntime.cs.meta | 11 + 6 files changed, 435 insertions(+), 2 deletions(-) create mode 100644 src/UnityWebBrowser.UnityProject/Assets/Scenes/UWBRuntime.unity create mode 100644 src/UnityWebBrowser.UnityProject/Assets/Scenes/UWBRuntime.unity.meta create mode 100644 src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs create mode 100644 src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs.meta diff --git a/src/Packages/UnityWebBrowser/package.json b/src/Packages/UnityWebBrowser/package.json index ddba844a..39046a75 100644 --- a/src/Packages/UnityWebBrowser/package.json +++ b/src/Packages/UnityWebBrowser/package.json @@ -26,8 +26,13 @@ "samples": [ { "displayName": "Basic", - "description": "Basic browser window prefab", + "description": "Basic set of prefabs for UWB.", "path": "Samples~/Basic" + }, + { + "displayName": "Runtime Example", + "description": "Basic script example of creating everything for UWB at runtime dynamically", + "path": "Samples~/Runtime" } ] } \ No newline at end of file diff --git a/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWB.unity b/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWB.unity index 7bb1cd34..fea58453 100644 --- a/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWB.unity +++ b/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWB.unity @@ -213,7 +213,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &298048589 Transform: m_ObjectHideFlags: 0 @@ -313,6 +313,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 906994673, guid: eb44fadbfd943194e85df7faf3a9dc5b, type: 3} + propertyPath: browserClient.cache + value: 0 + objectReference: {fileID: 0} - target: {fileID: 906994673, guid: eb44fadbfd943194e85df7faf3a9dc5b, type: 3} propertyPath: browserClient.logSeverity value: 1 diff --git a/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWBRuntime.unity b/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWBRuntime.unity new file mode 100644 index 00000000..62936e54 --- /dev/null +++ b/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWBRuntime.unity @@ -0,0 +1,314 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &956650770 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 956650773} + - component: {fileID: 956650772} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!20 &956650772 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 956650770} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &956650773 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 956650770} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1164793773 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1164793775} + - component: {fileID: 1164793774} + m_Layer: 0 + m_Name: UWBRuntime + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1164793774 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164793773} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 41445004a10b3344f92a7c5562dbddf7, type: 3} + m_Name: + m_EditorClassIdentifier: + container: {fileID: 1164793773} + mainCamera: {fileID: 956650772} +--- !u!4 &1164793775 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164793773} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1677794148 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1677794151} + - component: {fileID: 1677794150} + - component: {fileID: 1677794149} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1677794149 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1677794148} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &1677794150 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1677794148} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &1677794151 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1677794148} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWBRuntime.unity.meta b/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWBRuntime.unity.meta new file mode 100644 index 00000000..73ac8d16 --- /dev/null +++ b/src/UnityWebBrowser.UnityProject/Assets/Scenes/UWBRuntime.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 10757ea1686822e43a40978a339bfb2b +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs b/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs new file mode 100644 index 00000000..c1de94bf --- /dev/null +++ b/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs @@ -0,0 +1,92 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using UnityEngine; +using UnityEngine.UI; +using VoltstroStudios.UnityWebBrowser.Communication; +using VoltstroStudios.UnityWebBrowser.Core.Engines; +using VoltstroStudios.UnityWebBrowser.Input; +using VoltstroStudios.UnityWebBrowser.Shared.Core; + +namespace VoltstroStudios.UnityWebBrowser.Prj +{ + /// + /// Demo script for creating UWB at runtime + /// + public sealed class UWBRuntime : MonoBehaviour + { + /// + /// to create everything on + /// + [SerializeField] + private GameObject container; + + [SerializeField] + private Camera mainCamera; + + private void Start() + { + //Create canvas + Canvas canvas = container.AddComponent(); + canvas.renderMode = RenderMode.ScreenSpaceCamera; + canvas.worldCamera = mainCamera; + + CanvasScaler canvasScaler = container.AddComponent(); + canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; + canvasScaler.referenceResolution = new Vector2(1920, 1080); + canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight; + canvasScaler.matchWidthOrHeight = 0; + + container.AddComponent(); + + //Child object, where raw image and UWB itself will live + GameObject uwbGameObject = new("UWBContainer"); + uwbGameObject.transform.SetParent(container.transform); + + //Configure rect transform + RectTransform uwbRectTransform = uwbGameObject.AddComponent(); + uwbRectTransform.anchorMin = Vector2.zero; + uwbRectTransform.anchorMax = Vector2.one; + uwbRectTransform.pivot = new Vector2(0.5f, 0.5f); + uwbRectTransform.localScale = Vector3.one; + uwbRectTransform.offsetMin = Vector2.zero; + uwbRectTransform.offsetMax = Vector2.zero; + + //Add raw image + uwbGameObject.AddComponent(); + + //UWB Pre-Setup + + //Create engine dynamically + EngineConfiguration engineConfig = ScriptableObject.CreateInstance(); + engineConfig.engineAppName = "UnityWebBrowser.Engine.Cef"; + + engineConfig.engineFiles = new[] { + new Engine.EnginePlatformFiles + { + platform = Platform.Windows64, + engineFileLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.win.x64/Engine~/" + }, + new Engine.EnginePlatformFiles + { + platform = Platform.Linux64, + engineFileLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.linux.x64/Engine~/" + } + }; + + //Create coms layer dynamically + CommunicationLayer comsLayer = ScriptableObject.CreateInstance(); + + //Create input handler dynamically + WebBrowserInputHandler inputHandler = ScriptableObject.CreateInstance(); + + //UWB Object Setup + WebBrowserUIBasic webBrowser = uwbGameObject.AddComponent(); + webBrowser.browserClient.engine = engineConfig; + webBrowser.browserClient.communicationLayer = comsLayer; + webBrowser.inputHandler = inputHandler; + } + } +} diff --git a/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs.meta b/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs.meta new file mode 100644 index 00000000..fa762681 --- /dev/null +++ b/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41445004a10b3344f92a7c5562dbddf7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 1ce6fa5a1951eac5c7acf5ce224cc67ae00a3806 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Fri, 22 Mar 2024 15:49:33 +1000 Subject: [PATCH 17/19] Update page --- src/UnityWebBrowser.Pages/dist/about.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnityWebBrowser.Pages/dist/about.html b/src/UnityWebBrowser.Pages/dist/about.html index 7ce09095..a257785f 100644 --- a/src/UnityWebBrowser.Pages/dist/about.html +++ b/src/UnityWebBrowser.Pages/dist/about.html @@ -1 +1 @@ -UWB - About

Unity Web Browser About

UWB by Voltstro-Studios, under MIT license.

UWB Engine Version: Getting...
Web Engine Name: Getting...
Web Engine Version: Getting...

GitHub | Site

\ No newline at end of file +UWB - About

Unity Web Browser About

UWB by Voltstro-Studios, under MIT license.

UWB Engine Version: Getting...
Web Engine Name: Getting...
Web Engine Version: Getting...

GitHub | Site

\ No newline at end of file From a74d01ffb35b677854c4c27c1230e36f88cf4c80 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Fri, 22 Mar 2024 16:02:38 +1000 Subject: [PATCH 18/19] Update runtime example with Editor defs Include Runtime sample --- src/Packages/.gitignore | 3 +- .../Samples~/Runtime/Scripts.meta | 8 ++ .../Samples~/Runtime/Scripts/UWBRuntime.cs | 94 +++++++++++++++++++ .../Assets/Scripts/UWBRuntime.cs | 2 + 4 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts.meta create mode 100644 src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts/UWBRuntime.cs diff --git a/src/Packages/.gitignore b/src/Packages/.gitignore index 0e55c7bc..1301e313 100644 --- a/src/Packages/.gitignore +++ b/src/Packages/.gitignore @@ -1,3 +1,4 @@ **/*.dll !**/*.prefab -!**/*.meta \ No newline at end of file +!**/*.meta +!Samples~ \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts.meta b/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts.meta new file mode 100644 index 00000000..0c6f57ac --- /dev/null +++ b/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5b25dfc4c6a70e24fb38833255c4acc1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts/UWBRuntime.cs b/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts/UWBRuntime.cs new file mode 100644 index 00000000..2178b57a --- /dev/null +++ b/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts/UWBRuntime.cs @@ -0,0 +1,94 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using UnityEngine; +using UnityEngine.UI; +using VoltstroStudios.UnityWebBrowser.Communication; +using VoltstroStudios.UnityWebBrowser.Core.Engines; +using VoltstroStudios.UnityWebBrowser.Input; +using VoltstroStudios.UnityWebBrowser.Shared.Core; + +namespace VoltstroStudios.UnityWebBrowser.Prj +{ + /// + /// Demo script for creating UWB at runtime + /// + public sealed class UWBRuntime : MonoBehaviour + { + /// + /// to create everything on + /// + [SerializeField] + private GameObject container; + + [SerializeField] + private Camera mainCamera; + + private void Start() + { + //Create canvas + Canvas canvas = container.AddComponent(); + canvas.renderMode = RenderMode.ScreenSpaceCamera; + canvas.worldCamera = mainCamera; + + CanvasScaler canvasScaler = container.AddComponent(); + canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; + canvasScaler.referenceResolution = new Vector2(1920, 1080); + canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight; + canvasScaler.matchWidthOrHeight = 0; + + container.AddComponent(); + + //Child object, where raw image and UWB itself will live + GameObject uwbGameObject = new("UWBContainer"); + uwbGameObject.transform.SetParent(container.transform); + + //Configure rect transform + RectTransform uwbRectTransform = uwbGameObject.AddComponent(); + uwbRectTransform.anchorMin = Vector2.zero; + uwbRectTransform.anchorMax = Vector2.one; + uwbRectTransform.pivot = new Vector2(0.5f, 0.5f); + uwbRectTransform.localScale = Vector3.one; + uwbRectTransform.offsetMin = Vector2.zero; + uwbRectTransform.offsetMax = Vector2.zero; + + //Add raw image + uwbGameObject.AddComponent(); + + //UWB Pre-Setup + + //Create engine dynamically + EngineConfiguration engineConfig = ScriptableObject.CreateInstance(); + engineConfig.engineAppName = "UnityWebBrowser.Engine.Cef"; + +#if UNITY_EDITOR + engineConfig.engineFiles = new[] { + new Engine.EnginePlatformFiles + { + platform = Platform.Windows64, + engineFileLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.win.x64/Engine~/" + }, + new Engine.EnginePlatformFiles + { + platform = Platform.Linux64, + engineFileLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.linux.x64/Engine~/" + } + }; +#endif + + //Create coms layer dynamically + CommunicationLayer comsLayer = ScriptableObject.CreateInstance(); + + //Create input handler dynamically + WebBrowserInputHandler inputHandler = ScriptableObject.CreateInstance(); + + //UWB Object Setup + WebBrowserUIBasic webBrowser = uwbGameObject.AddComponent(); + webBrowser.browserClient.engine = engineConfig; + webBrowser.browserClient.communicationLayer = comsLayer; + webBrowser.inputHandler = inputHandler; + } + } +} diff --git a/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs b/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs index c1de94bf..2178b57a 100644 --- a/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs +++ b/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs @@ -63,6 +63,7 @@ private void Start() EngineConfiguration engineConfig = ScriptableObject.CreateInstance(); engineConfig.engineAppName = "UnityWebBrowser.Engine.Cef"; +#if UNITY_EDITOR engineConfig.engineFiles = new[] { new Engine.EnginePlatformFiles { @@ -75,6 +76,7 @@ private void Start() engineFileLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.linux.x64/Engine~/" } }; +#endif //Create coms layer dynamically CommunicationLayer comsLayer = ScriptableObject.CreateInstance(); From 527fd8ab579bf6e49a3cb0bca1ce7aa4eba15ba0 Mon Sep 17 00:00:00 2001 From: Voltstro Date: Fri, 22 Mar 2024 16:53:32 +1000 Subject: [PATCH 19/19] Bump version --- CHANGELOG.md | 20 +++++++++++++++++++ .../package.json | 4 ++-- .../package.json | 4 ++-- .../UnityWebBrowser.Engine.Cef/package.json | 4 ++-- .../UnityWebBrowser/Runtime/AssemblyInfo.cs | 4 ++-- src/Packages/UnityWebBrowser/package.json | 2 +- .../UnityWebBrowser.Engine.Cef.csproj | 2 +- .../Packages/packages-lock.json | 6 +++--- src/version.json | 2 +- 9 files changed, 34 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d60ca05b..497c327d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.1.1] - 2024-03-22 + +### Added + +- Added Dynamic Runtime Sample + +### Changed + +- Bump deps +- Updated CEF to 122.1.13 +- Updated basic sample description + +### Fixed + +- Implemented a handful of fixes to attempt to resolve issue #166 + - Prevent engine process lingering when main parent process dies + - Uses Job Objects on Windows + - Uses prctl on Linux + - Errors related to binding ports are no longer swallowed + ## [2.1.0] - 2024-02-18 ### Added diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json b/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json index 89b9a323..0f822dc7 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json @@ -13,11 +13,11 @@ "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", "unity": "2021.2", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-122.1.13", + "dev.voltstro.unitywebbrowser.engine.cef": "2.1.1-122.1.13", "dev.voltstro.unitywebbrowser.unix-support": "1.0.0" }, "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", "description": "CEF Engine for Unity Web Browser (Linux x64)", "displayName": "Unity Web Browser CEF Engine (Linux x64)", - "version": "2.1.0-122.1.13" + "version": "2.1.1-122.1.13" } diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json b/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json index 486c9668..d0947da5 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json @@ -13,10 +13,10 @@ "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", "unity": "2021.2", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-122.1.13" + "dev.voltstro.unitywebbrowser.engine.cef": "2.1.1-122.1.13" }, "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", "description": "CEF Engine for Unity Web Browser (Windows x64)", "displayName": "Unity Web Browser CEF Engine (Windows x64)", - "version": "2.1.0-122.1.13" + "version": "2.1.1-122.1.13" } diff --git a/src/Packages/UnityWebBrowser.Engine.Cef/package.json b/src/Packages/UnityWebBrowser.Engine.Cef/package.json index fbde44cf..5ab94f3a 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef/package.json @@ -3,7 +3,7 @@ "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", "description": "CEF Engine for Unity Web Browser", "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", - "version": "2.1.0-122.1.13", + "version": "2.1.1-122.1.13", "author": { "email": "me@voltstro.dev", "url": "https://voltstro.dev", @@ -11,7 +11,7 @@ }, "unity": "2021.3", "dependencies": { - "dev.voltstro.unitywebbrowser": "2.0.2" + "dev.voltstro.unitywebbrowser": "2.1.1" }, "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", "repository": { diff --git a/src/Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs b/src/Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs index 1b00cc58..19b6b2ec 100644 --- a/src/Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs +++ b/src/Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs @@ -34,8 +34,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.0")] -[assembly: AssemblyFileVersion("2.1.0")] +[assembly: AssemblyVersion("2.1.1")] +[assembly: AssemblyFileVersion("2.1.1")] [assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser.Prj")] [assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser.Editor")] diff --git a/src/Packages/UnityWebBrowser/package.json b/src/Packages/UnityWebBrowser/package.json index 39046a75..0d566fef 100644 --- a/src/Packages/UnityWebBrowser/package.json +++ b/src/Packages/UnityWebBrowser/package.json @@ -1,7 +1,7 @@ { "name": "dev.voltstro.unitywebbrowser", "displayName": "Unity Web Browser", - "version": "2.1.0", + "version": "2.1.1", "unity": "2021.3", "description": "Unity Web Browser (UWB) is a Unity package that allows displaying and interacting with the web from within Unity.", "author": { diff --git a/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj b/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj index 4998e077..ce4edc71 100644 --- a/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj +++ b/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj @@ -10,7 +10,7 @@ chromium-logo.ico External process to handel rendering with CEF win-x64;linux-x64;osx-x64 - 2.1.0-122.1.13 + 2.1.1-122.1.13 BROWSER_PROCESS diff --git a/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json b/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json index 3bc3396b..1ff7b3fe 100644 --- a/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json +++ b/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json @@ -173,7 +173,7 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser": "2.0.2" + "dev.voltstro.unitywebbrowser": "2.1.1" } }, "dev.voltstro.unitywebbrowser.engine.cef.linux.x64": { @@ -181,7 +181,7 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-122.1.13", + "dev.voltstro.unitywebbrowser.engine.cef": "2.1.1-122.1.13", "dev.voltstro.unitywebbrowser.unix-support": "1.0.0" } }, @@ -199,7 +199,7 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.0-122.1.13" + "dev.voltstro.unitywebbrowser.engine.cef": "2.1.1-122.1.13" } }, "dev.voltstro.unitywebbrowser.unix-support": { diff --git a/src/version.json b/src/version.json index ff2f1e9b..e12be7a5 100644 --- a/src/version.json +++ b/src/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.1.0", + "version": "2.1.1", "publicReleaseRefSpec": [ "^refs/heads/master$", "^refs/heads/v\\d+(?:\\.\\d+)?$"