Skip to content

Commit efaf127

Browse files
committed
fix: mac compilation flags
1 parent 1d61f8e commit efaf127

File tree

69 files changed

+357
-115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+357
-115
lines changed

sample/Assets/Scripts/Passport/WebViewTesting/VoltUnityWebBrowserAdapter.cs

Lines changed: 109 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Linq;
45
using UnityEngine;
@@ -9,6 +10,7 @@
910
using VoltstroStudios.UnityWebBrowser.Core;
1011
using VoltstroStudios.UnityWebBrowser.Core.Engines;
1112
using VoltstroStudios.UnityWebBrowser.Communication;
13+
using VoltstroStudios.UnityWebBrowser.Helper;
1214
using VoltstroStudios.UnityWebBrowser.Shared;
1315
using VoltstroStudios.UnityWebBrowser.Shared.Core;
1416
using VoltstroStudios.UnityWebBrowser.Shared.Popups;
@@ -51,6 +53,11 @@ public void Initialize(int width, int height)
5153
{
5254
try
5355
{
56+
#if UNITY_EDITOR
57+
// Enable native collection leak detection with full stack traces
58+
Unity.Collections.NativeLeakDetection.Mode = Unity.Collections.NativeLeakDetectionMode.EnabledWithStackTrace;
59+
#endif
60+
5461
// Start timing the initialization
5562
initializationTimer = System.Diagnostics.Stopwatch.StartNew();
5663
initStartTime = Time.realtimeSinceStartup;
@@ -333,17 +340,76 @@ public void Dispose()
333340
{
334341
if (isInitialized)
335342
{
336-
// TODO: Implement proper disposal
337-
// webBrowserClient?.Dispose();
343+
Debug.Log("[VoltUWBAdapter] 🧹 Starting UWB disposal...");
344+
345+
#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
346+
// Unsubscribe from events first
347+
if (webBrowserClient != null)
348+
{
349+
try
350+
{
351+
webBrowserClient.OnLoadFinish -= OnLoadFinishHandler;
352+
webBrowserClient.OnLoadStart -= OnLoadStartHandler;
353+
Debug.Log("[VoltUWBAdapter] ✅ Event handlers unsubscribed");
354+
}
355+
catch (Exception ex)
356+
{
357+
Debug.LogWarning($"[VoltUWBAdapter] ⚠️ Error unsubscribing events: {ex.Message}");
358+
}
359+
}
360+
361+
// Dispose WebBrowser components
362+
if (webBrowserUI != null)
363+
{
364+
try
365+
{
366+
// WebBrowserUIFull should handle its own disposal
367+
UnityEngine.Object.DestroyImmediate(webBrowserUI);
368+
Debug.Log("[VoltUWBAdapter] ✅ WebBrowserUIFull destroyed");
369+
}
370+
catch (Exception ex)
371+
{
372+
Debug.LogWarning($"[VoltUWBAdapter] ⚠️ Error destroying WebBrowserUIFull: {ex.Message}");
373+
}
374+
}
375+
376+
// Destroy GameObject
377+
if (uwbGameObject != null)
378+
{
379+
try
380+
{
381+
UnityEngine.Object.DestroyImmediate(uwbGameObject);
382+
Debug.Log("[VoltUWBAdapter] ✅ UWB GameObject destroyed");
383+
}
384+
catch (Exception ex)
385+
{
386+
Debug.LogWarning($"[VoltUWBAdapter] ⚠️ Error destroying GameObject: {ex.Message}");
387+
}
388+
}
389+
390+
// Clear references
391+
webBrowserClient = null;
392+
webBrowserUI = null;
393+
uwbGameObject = null;
394+
#endif
395+
396+
// Stop timers
397+
initializationTimer?.Stop();
398+
navigationTimer?.Stop();
338399

339400
IsActive = false;
340401
isInitialized = false;
341-
Debug.Log("[VoltUWBAdapter] Volt Unity Web Browser disposed");
402+
Debug.Log("[VoltUWBAdapter] ✅ Volt Unity Web Browser disposed successfully");
403+
}
404+
else
405+
{
406+
Debug.Log("[VoltUWBAdapter] 💡 UWB already disposed or not initialized");
342407
}
343408
}
344409
catch (Exception ex)
345410
{
346-
Debug.LogError($"[VoltUWBAdapter] Disposal error: {ex.Message}");
411+
Debug.LogError($"[VoltUWBAdapter] ❌ Disposal error: {ex.Message}");
412+
Debug.LogError($"[VoltUWBAdapter] Stack trace: {ex.StackTrace}");
347413
}
348414
}
349415

@@ -589,28 +655,56 @@ private void ConfigureUWBEngine()
589655
{
590656
Debug.Log("[VoltUWBAdapter] 🔧 Configuring UWB CEF Engine for UI instance...");
591657

658+
var detectedPlatform = WebBrowserUtils.GetRunningPlatform();
659+
592660
// Create engine configuration (same as SDK but for UI instance)
593661
var engineConfig = ScriptableObject.CreateInstance<EngineConfiguration>();
594662
engineConfig.engineAppName = "UnityWebBrowser.Engine.Cef";
595-
engineConfig.engineFiles = new Engine.EnginePlatformFiles[]
663+
664+
var engineFiles = new List<Engine.EnginePlatformFiles>();
665+
666+
// Windows engine configuration
667+
engineFiles.Add(new Engine.EnginePlatformFiles()
596668
{
597-
new Engine.EnginePlatformFiles()
598-
{
599-
platform = Platform.Windows64,
600-
engineBaseAppLocation = "",
601-
engineRuntimeLocation = "UWB/"
669+
platform = Platform.Windows64,
670+
engineBaseAppLocation = "",
671+
engineRuntimeLocation = "UWB/"
602672
#if UNITY_EDITOR
603-
,
604-
engineEditorLocation = "Packages/com.immutable.passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Engine~"
673+
,
674+
engineEditorLocation = "Packages/com.immutable.passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Engine~"
605675
#endif
606-
}
607-
};
676+
});
677+
678+
// macOS engine configuration (Intel)
679+
engineFiles.Add(new Engine.EnginePlatformFiles()
680+
{
681+
platform = Platform.MacOS,
682+
engineBaseAppLocation = "UnityWebBrowser.Engine.Cef.app/Contents/MacOS",
683+
engineRuntimeLocation = "UWB/"
684+
#if UNITY_EDITOR
685+
,
686+
engineEditorLocation = "Packages/com.immutable.passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Engine~"
687+
#endif
688+
});
689+
690+
// macOS engine configuration (ARM64 - Apple Silicon)
691+
engineFiles.Add(new Engine.EnginePlatformFiles()
692+
{
693+
platform = Platform.MacOSArm64,
694+
engineBaseAppLocation = "UnityWebBrowser.Engine.Cef.app/Contents/MacOS",
695+
engineRuntimeLocation = "UWB/"
696+
#if UNITY_EDITOR
697+
,
698+
engineEditorLocation = "Packages/com.immutable.passport/Runtime/ThirdParty/UnityWebBrowser/dev.voltstro.unitywebbrowser.engine.cef.macos.arm64@2.2.5-130.1.16/Engine~"
699+
#endif
700+
});
701+
702+
engineConfig.engineFiles = engineFiles.ToArray();
608703

609704
// Assign engine to our UI instance
610705
webBrowserClient.engine = engineConfig;
611706

612707
Debug.Log("[VoltUWBAdapter] ✅ CEF Engine configured successfully for UI instance");
613-
Debug.Log("[VoltUWBAdapter] 🎯 Engine path: Packages/com.immutable.passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Engine~");
614708
}
615709
catch (System.Exception ex)
616710
{

sample/Packages/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
},
6565
{
6666
"name": "npmjs",
67-
"url": "https://registry.npmjs.org/",
67+
"url": "https://registry.npmjs.org",
6868
"scopes": [
6969
"com.unity.uiextensions"
7070
]

sample/ProjectSettings/PackageManagerSettings.asset

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ MonoBehaviour:
5151
m_Capabilities: 0
5252
m_ConfigSource: 4
5353
m_UserSelectedRegistryName: npmjs
54-
m_UserAddingNewScopedRegistry: 1
54+
m_UserAddingNewScopedRegistry: 0
5555
m_RegistryInfoDraft:
5656
m_Modified: 0
5757
m_ErrorMessage:
58-
m_UserModificationsInstanceId: -824
59-
m_OriginalInstanceId: -828
58+
m_UserModificationsInstanceId: -842
59+
m_OriginalInstanceId: -846
6060
m_LoadAssets: 0

src/Packages/Passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Runtime/NativeArrayExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
1+
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
22

33
using System;
44
using Unity.Collections;

src/Packages/Passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Runtime/NativeSliceExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
1+
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
22

33
using System;
44
using Unity.Collections;

src/Packages/Passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Runtime/SpanExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
1+
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
22

33
using System;
44
using Unity.Collections;

src/Packages/Passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Runtime/Utils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
1+
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
22

33
using System;
44
using System.Diagnostics;

src/Packages/Passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Runtime/VoltstroStudios.NativeArraySpanExtensions.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"references": [],
55
"includePlatforms": [
66
"Editor",
7-
"WindowsStandalone64"
7+
"WindowsStandalone64",
8+
"macOSStandalone"
89
],
910
"excludePlatforms": [],
1011
"allowUnsafeCode": true,

src/Packages/Passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Runtime/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
1+
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
22

33
// UnityWebBrowser (UWB)
44
// Copyright (c) 2021-2022 Voltstro-Studios

src/Packages/Passport/Runtime/ThirdParty/UnityWebBrowser/[email protected]/Runtime/Communication/CommunicationLayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
1+
#if !IMMUTABLE_CUSTOM_BROWSER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))
22

33
// UnityWebBrowser (UWB)
44
// Copyright (c) 2021-2022 Voltstro-Studios

0 commit comments

Comments
 (0)