From a3cefa266e1cbd69a5c20954d73e510b3021af37 Mon Sep 17 00:00:00 2001 From: saul-l Date: Mon, 11 Aug 2025 20:06:19 +0300 Subject: [PATCH 1/2] fix: assign random cache folders to prevent errors with multiple browser instances --- .../UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs b/src/Packages/UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs index bf194c2f..d7b2f4cd 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs @@ -4,6 +4,7 @@ // This project is under the MIT license. See the LICENSE.md file for more details. using System; +using System.IO; using UnityEngine; namespace VoltstroStudios.UnityWebBrowser.Core @@ -28,6 +29,11 @@ public abstract class BaseUwbClientManager : MonoBehaviour private void Start() { + //Give random cache path for the browser client + string randomCachePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.Guid.NewGuid().ToString()); + FileInfo rcpFileInfo = new FileInfo(randomCachePath); + browserClient.CachePath = rcpFileInfo; + //Start the browser client browserClient.Init(); From 0f553a5d0cf75347e3549a522c9bfa292c229426 Mon Sep 17 00:00:00 2001 From: saul-l Date: Tue, 12 Aug 2025 21:39:02 +0300 Subject: [PATCH 2/2] Update BaseUwbClientManager.cs Random cache path is now deleted OnDestroy --- .../Runtime/Core/BaseUwbClientManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs b/src/Packages/UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs index d7b2f4cd..b2dc62b7 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs @@ -26,11 +26,12 @@ public abstract class BaseUwbClientManager : MonoBehaviour /// [Tooltip("The browser client, what handles the communication between the UWB engine and Unity")] public WebBrowserClient browserClient = new(); - + private string randomCachePath; + private void Start() { //Give random cache path for the browser client - string randomCachePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.Guid.NewGuid().ToString()); + randomCachePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.Guid.NewGuid().ToString()); FileInfo rcpFileInfo = new FileInfo(randomCachePath); browserClient.CachePath = rcpFileInfo; @@ -53,6 +54,9 @@ private void FixedUpdate() private void OnDestroy() { + // Delete random assigned cache folders + Directory.Delete(randomCachePath, true); + browserClient.Dispose(); OnDestroyed(); } @@ -151,4 +155,4 @@ public void ExecuteJs(string js) #endregion } -} \ No newline at end of file +}