From fc6e1e910ccac3280fe0eb656dd512577874e558 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Fri, 22 Apr 2022 14:12:35 +0200 Subject: [PATCH 1/3] feat: add macOS native SDK lib --- .gitignore | 3 + Directory.Build.targets | 30 ++++++- .../Resources/DWARF/libsentry.dylib.meta | 63 +++++++++++++++ .../Plugins/macOS/Sentry/libsentry.dylib.meta | 81 +++++++++++++++++++ 4 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 package-dev/Plugins/macOS/Sentry/libsentry.dylib.dSYM/Contents/Resources/DWARF/libsentry.dylib.meta create mode 100644 package-dev/Plugins/macOS/Sentry/libsentry.dylib.meta diff --git a/.gitignore b/.gitignore index a4aed42d7..d8dcb4a4c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,12 +22,15 @@ package-dev/**/*.meta package-dev/**/*.framework package-dev/**/*.pdb package-dev/**/*.xml +package-dev/**/*.dylib +package-dev/**/*.dSYM package-dev/**/TestSentryOptions.json package-dev/Tests/Editor/TestFiles/ package-dev/Plugins/*/Sentry/crashpad_handler* # Adding .meta to control target platforms for all of our DLLs !package-dev/**/Sentry*.dll.meta +!package-dev/**/libsentry.dylib.meta # required to be marked as iOS only !package-dev/**/*.framework.meta diff --git a/Directory.Build.targets b/Directory.Build.targets index b1619e211..b0b0e8577 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -24,6 +24,7 @@ $(SentryArtifactsDestination)/Android/Sentry/ $(RepoRoot)modules/sentry-native/ + $(SentryArtifactsDestination)/macOS/Sentry/ $(SentryArtifactsDestination)/Windows/Sentry/ @@ -117,8 +118,9 @@ Expected to exist: - + + @@ -168,6 +170,26 @@ Expected to exist: + + + + + + + + + + + + + + + + + + - + + + + + diff --git a/package-dev/Plugins/macOS/Sentry/libsentry.dylib.dSYM/Contents/Resources/DWARF/libsentry.dylib.meta b/package-dev/Plugins/macOS/Sentry/libsentry.dylib.dSYM/Contents/Resources/DWARF/libsentry.dylib.meta new file mode 100644 index 000000000..7e90d308f --- /dev/null +++ b/package-dev/Plugins/macOS/Sentry/libsentry.dylib.dSYM/Contents/Resources/DWARF/libsentry.dylib.meta @@ -0,0 +1,63 @@ +fileFormatVersion: 2 +guid: 600df94d8e1de4988ba93329137e1420 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + userData: + assetBundleName: + assetBundleVariant: diff --git a/package-dev/Plugins/macOS/Sentry/libsentry.dylib.meta b/package-dev/Plugins/macOS/Sentry/libsentry.dylib.meta new file mode 100644 index 000000000..683fefac4 --- /dev/null +++ b/package-dev/Plugins/macOS/Sentry/libsentry.dylib.meta @@ -0,0 +1,81 @@ +fileFormatVersion: 2 +guid: bfb2b5d283ee041ae90a408bd7afd91a +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 0 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + iPhone: iOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CPU: AnyCPU + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: From da87008958f3ae04ab9ac9dc6f00770d6e5740a0 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Fri, 22 Apr 2022 14:33:27 +0200 Subject: [PATCH 2/3] feat: add MacosNativeSupportEnabled option --- .../Assets/Resources/Sentry/SentryOptions.asset | 1 + .../ConfigurationWindow/AdvancedTab.cs | 7 +++++-- src/Sentry.Unity.Editor/Native/BuildPostProcess.cs | 13 ++++++++++--- .../ScriptableSentryUnityOptionsEditor.cs | 1 + src/Sentry.Unity/ScriptableSentryUnityOptions.cs | 2 ++ src/Sentry.Unity/SentryOptionsUtility.cs | 1 + src/Sentry.Unity/SentryUnityOptions.cs | 5 +++++ .../ScriptableSentryUnityOptionsTests.cs | 1 + 8 files changed, 26 insertions(+), 5 deletions(-) diff --git a/samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset b/samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset index 89d937fc4..00c2aba65 100644 --- a/samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset +++ b/samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset @@ -38,6 +38,7 @@ MonoBehaviour: k__BackingField: 1 k__BackingField: 1 k__BackingField: 1 + k__BackingField: 1 k__BackingField: {fileID: 11400000, guid: bda1a724b0875436aade31393b0129c0, type: 2} k__BackingField: 1 diff --git a/src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs b/src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs index 5d79da5bf..425a34c89 100644 --- a/src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs +++ b/src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs @@ -59,9 +59,12 @@ internal static void Display(ScriptableSentryUnityOptions options) options.AndroidNativeSupportEnabled); options.WindowsNativeSupportEnabled = EditorGUILayout.Toggle( - new GUIContent("Windows Native Support", "Whether to enable Native Windows support to " + - "capture errors written in languages such as C and C++."), + new GUIContent("Windows Native Support", "Whether to enable native crashes support on Windows."), options.WindowsNativeSupportEnabled); + + options.MacosNativeSupportEnabled = EditorGUILayout.Toggle( + new GUIContent("macOS Native Support", "Whether to enable native crashes support on macOS."), + options.MacosNativeSupportEnabled); } diff --git a/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs b/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs index 823bcd381..b46cfe80f 100644 --- a/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs +++ b/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs @@ -13,7 +13,7 @@ public static class BuildPostProcess [PostProcessBuild(1)] public static void OnPostProcessBuild(BuildTarget target, string executablePath) { - if (target is not (BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64)) + if (EditorUserBuildSettings.selectedBuildTargetGroup is not BuildTargetGroup.Standalone) { return; } @@ -35,9 +35,9 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath) return; } - if (!options.WindowsNativeSupportEnabled) + if (!IsEnabledForPlatform(target, options)) { - logger.LogDebug("Windows Native support disabled through the options."); + logger.LogDebug("Native support for the current platform is disabled in the configuration."); return; } @@ -53,6 +53,13 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath) } } + private static bool IsEnabledForPlatform(BuildTarget target, SentryUnityOptions options) => target switch + { + BuildTarget.StandaloneWindows64 => options.WindowsNativeSupportEnabled, + BuildTarget.StandaloneOSX => options.MacosNativeSupportEnabled, + _ => false, + }; + private static void AddCrashHandler(IDiagnosticLogger logger, string projectDir) { var crashpadPath = Path.GetFullPath(Path.Combine("Packages", SentryPackageInfo.GetName(), "Plugins", diff --git a/src/Sentry.Unity.Editor/ScriptableSentryUnityOptionsEditor.cs b/src/Sentry.Unity.Editor/ScriptableSentryUnityOptionsEditor.cs index 9d10afee7..d8979336e 100644 --- a/src/Sentry.Unity.Editor/ScriptableSentryUnityOptionsEditor.cs +++ b/src/Sentry.Unity.Editor/ScriptableSentryUnityOptionsEditor.cs @@ -65,6 +65,7 @@ public override void OnInspectorGUI() EditorGUILayout.Toggle("iOS Native Support", options.IosNativeSupportEnabled); EditorGUILayout.Toggle("Android Native Support", options.AndroidNativeSupportEnabled); EditorGUILayout.Toggle("Windows Native Support", options.WindowsNativeSupportEnabled); + EditorGUILayout.Toggle("macOS Native Support", options.MacosNativeSupportEnabled); EditorGUILayout.Space(); EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), Color.gray); diff --git a/src/Sentry.Unity/ScriptableSentryUnityOptions.cs b/src/Sentry.Unity/ScriptableSentryUnityOptions.cs index 916f9580e..3eecf6472 100644 --- a/src/Sentry.Unity/ScriptableSentryUnityOptions.cs +++ b/src/Sentry.Unity/ScriptableSentryUnityOptions.cs @@ -56,6 +56,7 @@ public static string GetConfigPath(string? notDefaultConfigName = null) [field: SerializeField] public bool IosNativeSupportEnabled { get; set; } = true; [field: SerializeField] public bool AndroidNativeSupportEnabled { get; set; } = true; [field: SerializeField] public bool WindowsNativeSupportEnabled { get; set; } = true; + [field: SerializeField] public bool MacosNativeSupportEnabled { get; set; } = true; [field: SerializeField] public ScriptableOptionsConfiguration? OptionsConfiguration { get; set; } @@ -129,6 +130,7 @@ internal static SentryUnityOptions ToSentryUnityOptions(ScriptableSentryUnityOpt options.IosNativeSupportEnabled = scriptableOptions.IosNativeSupportEnabled; options.AndroidNativeSupportEnabled = scriptableOptions.AndroidNativeSupportEnabled; options.WindowsNativeSupportEnabled = scriptableOptions.WindowsNativeSupportEnabled; + options.MacosNativeSupportEnabled = scriptableOptions.MacosNativeSupportEnabled; options.Debug = scriptableOptions.Debug; options.DebugOnlyInEditor = scriptableOptions.DebugOnlyInEditor; diff --git a/src/Sentry.Unity/SentryOptionsUtility.cs b/src/Sentry.Unity/SentryOptionsUtility.cs index 070457df4..71ef1fc39 100644 --- a/src/Sentry.Unity/SentryOptionsUtility.cs +++ b/src/Sentry.Unity/SentryOptionsUtility.cs @@ -43,6 +43,7 @@ public static void SetDefaults(ScriptableSentryUnityOptions scriptableOptions) scriptableOptions.IosNativeSupportEnabled = options.IosNativeSupportEnabled; scriptableOptions.AndroidNativeSupportEnabled = options.AndroidNativeSupportEnabled; scriptableOptions.WindowsNativeSupportEnabled = options.WindowsNativeSupportEnabled; + scriptableOptions.MacosNativeSupportEnabled = options.MacosNativeSupportEnabled; scriptableOptions.Debug = true; scriptableOptions.DebugOnlyInEditor = true; diff --git a/src/Sentry.Unity/SentryUnityOptions.cs b/src/Sentry.Unity/SentryUnityOptions.cs index b7be1547b..295ace4bf 100644 --- a/src/Sentry.Unity/SentryUnityOptions.cs +++ b/src/Sentry.Unity/SentryUnityOptions.cs @@ -108,6 +108,11 @@ public sealed class SentryUnityOptions : SentryOptions /// public bool WindowsNativeSupportEnabled { get; set; } = true; + /// + /// Whether the SDK should add native support for MacOS + /// + public bool MacosNativeSupportEnabled { get; set; } = true; + public SentryUnityOptions() : this(ApplicationAdapter.Instance, false) { } diff --git a/test/Sentry.Unity.Editor.Tests/ScriptableSentryUnityOptionsTests.cs b/test/Sentry.Unity.Editor.Tests/ScriptableSentryUnityOptionsTests.cs index 153915c08..b01d0882f 100644 --- a/test/Sentry.Unity.Editor.Tests/ScriptableSentryUnityOptionsTests.cs +++ b/test/Sentry.Unity.Editor.Tests/ScriptableSentryUnityOptionsTests.cs @@ -44,6 +44,7 @@ public void ScriptableSentryUnityOptions_Creation_AllPropertiesPresent() StringAssert.Contains("IosNativeSupportEnabled", optionsAsString); StringAssert.Contains("AndroidNativeSupportEnabled", optionsAsString); StringAssert.Contains("WindowsNativeSupportEnabled", optionsAsString); + StringAssert.Contains("MacosNativeSupportEnabled", optionsAsString); StringAssert.Contains("OptionsConfiguration", optionsAsString); StringAssert.Contains("Debug", optionsAsString); StringAssert.Contains("DebugOnlyInEditor", optionsAsString); From bed2bdd9bb6a23f870c5a21ebfa4408d08effcf9 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Fri, 22 Apr 2022 18:55:19 +0200 Subject: [PATCH 3/3] feat: macOS native crashpad handler integration & debug symbol upload --- .../Runtime/Sentry.Unity.Native.dll.meta | 6 +-- package-dev/Runtime/SentryInitialization.cs | 13 +++-- .../Native/BuildPostProcess.cs | 49 +++++++++++++------ src/Sentry.Unity.Native/SentryNative.cs | 8 ++- src/Sentry.Unity.Native/SentryNativeBridge.cs | 26 +++++----- src/Sentry.Unity/SentryUnity.cs | 1 + 6 files changed, 66 insertions(+), 37 deletions(-) diff --git a/package-dev/Runtime/Sentry.Unity.Native.dll.meta b/package-dev/Runtime/Sentry.Unity.Native.dll.meta index 39b30bcb4..2735a9bc5 100644 --- a/package-dev/Runtime/Sentry.Unity.Native.dll.meta +++ b/package-dev/Runtime/Sentry.Unity.Native.dll.meta @@ -19,7 +19,7 @@ PluginImporter: Exclude Android: 1 Exclude Editor: 0 Exclude Linux64: 1 - Exclude OSXUniversal: 1 + Exclude OSXUniversal: 0 Exclude WebGL: 1 Exclude Win: 0 Exclude Win64: 0 @@ -53,9 +53,9 @@ PluginImporter: - first: Standalone: OSXUniversal second: - enabled: 0 + enabled: 1 settings: - CPU: None + CPU: AnyCPU - first: Standalone: Win second: diff --git a/package-dev/Runtime/SentryInitialization.cs b/package-dev/Runtime/SentryInitialization.cs index 2c6381e62..3d1bd2aad 100644 --- a/package-dev/Runtime/SentryInitialization.cs +++ b/package-dev/Runtime/SentryInitialization.cs @@ -3,8 +3,13 @@ #define SENTRY_NATIVE_IOS #elif UNITY_ANDROID #define SENTRY_NATIVE_ANDROID +// After enabling support for Linux, we can use UNITY_STANDALONE: +// #elif UNITY_STANDALONE && ENABLE_IL2CPP +// #define SENTRY_NATIVE_STANDALONE #elif UNITY_STANDALONE_WIN && ENABLE_IL2CPP -#define SENTRY_NATIVE_WINDOWS +#define SENTRY_NATIVE_STANDALONE +#elif UNITY_STANDALONE_OSX && ENABLE_IL2CPP +#define SENTRY_NATIVE_STANDALONE #elif UNITY_WEBGL #define SENTRY_WEBGL #endif @@ -15,9 +20,9 @@ #if SENTRY_NATIVE_IOS using Sentry.Unity.iOS; -#elif UNITY_ANDROID +#elif SENTRY_NATIVE_ANDROID using Sentry.Unity.Android; -#elif SENTRY_NATIVE_WINDOWS +#elif SENTRY_NATIVE_STANDALONE using Sentry.Unity.Native; #elif SENTRY_WEBGL using Sentry.Unity.WebGL; @@ -41,7 +46,7 @@ public static void Init() SentryNativeIos.Configure(options); #elif SENTRY_NATIVE_ANDROID SentryNativeAndroid.Configure(options, sentryUnityInfo); -#elif SENTRY_NATIVE_WINDOWS +#elif SENTRY_NATIVE_STANDALONE SentryNative.Configure(options); #elif SENTRY_WEBGL SentryWebGL.Configure(options); diff --git a/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs b/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs index b46cfe80f..df2966fc5 100644 --- a/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs +++ b/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs @@ -42,8 +42,9 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath) } var projectDir = Path.GetDirectoryName(executablePath); - AddCrashHandler(logger, projectDir); - UploadDebugSymbols(logger, projectDir, Path.GetFileName(executablePath)); + var executableName = Path.GetFileName(executablePath); + AddCrashHandler(logger, target, projectDir, executableName); + UploadDebugSymbols(logger, target, projectDir, executableName); } catch (Exception e) @@ -60,16 +61,31 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath) _ => false, }; - private static void AddCrashHandler(IDiagnosticLogger logger, string projectDir) + private static void AddCrashHandler(IDiagnosticLogger logger, BuildTarget target, string projectDir, string executableName) { - var crashpadPath = Path.GetFullPath(Path.Combine("Packages", SentryPackageInfo.GetName(), "Plugins", - "Windows", "Sentry", "crashpad_handler.exe")); - var targetPath = Path.Combine(projectDir, Path.GetFileName(crashpadPath)); - logger.LogInfo("Copying the native crash handler '{0}' to the output directory", Path.GetFileName(crashpadPath)); + string crashpadPath; + string targetPath; + if (target is (BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64)) + { + crashpadPath = Path.Combine("Windows", "Sentry", "crashpad_handler.exe"); + targetPath = Path.Combine(projectDir, Path.GetFileName(crashpadPath)); + } + else if (target is BuildTarget.StandaloneOSX) + { + crashpadPath = Path.Combine("macOS", "Sentry", "crashpad_handler"); + targetPath = Path.Combine(projectDir, executableName, "Contents", "MacOS", Path.GetFileName(crashpadPath)); + } + else + { + throw new ArgumentException($"Unsupported build target: {target}"); + } + + crashpadPath = Path.GetFullPath(Path.Combine("Packages", SentryPackageInfo.GetName(), "Plugins", crashpadPath)); + logger.LogInfo("Copying the native crash handler '{0}' to {1}", Path.GetFileName(crashpadPath), targetPath); File.Copy(crashpadPath, targetPath, true); } - private static void UploadDebugSymbols(IDiagnosticLogger logger, string projectDir, string executableName) + private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget target, string projectDir, string executableName) { var cliOptions = SentryCliOptions.LoadCliOptions(); if (!cliOptions.IsValid(logger)) @@ -97,13 +113,18 @@ private static void UploadDebugSymbols(IDiagnosticLogger logger, string projectD }; addPath(executableName); - addPath("GameAssembly.dll"); - addPath("UnityPlayer.dll"); addPath(Path.GetFileNameWithoutExtension(executableName) + "_BackUpThisFolder_ButDontShipItWithYourGame"); - addPath(Path.GetFileNameWithoutExtension(executableName) + "_Data/Plugins/x86_64/sentry.dll"); - - // Note: using Path.GetFullPath as suggested by https://docs.unity3d.com/Manual/upm-assets.html - addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Windows/Sentry/sentry.pdb")); + if (target is (BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64)) + { + addPath("GameAssembly.dll"); + addPath("UnityPlayer.dll"); + addPath(Path.GetFileNameWithoutExtension(executableName) + "_Data/Plugins/x86_64/sentry.dll"); + addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Windows/Sentry/sentry.pdb")); + } + else if (target is BuildTarget.StandaloneOSX) + { + addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/macOS/Sentry/libsentry.dylib.dSYM")); + } // Configure the process using the StartInfo properties. var process = new Process diff --git a/src/Sentry.Unity.Native/SentryNative.cs b/src/Sentry.Unity.Native/SentryNative.cs index 5c5624a6b..cd241aaf6 100644 --- a/src/Sentry.Unity.Native/SentryNative.cs +++ b/src/Sentry.Unity.Native/SentryNative.cs @@ -1,6 +1,7 @@ using Sentry.Extensibility; using Sentry.Unity.Integrations; using System.Collections.Generic; +using UnityEngine; namespace Sentry.Unity.Native { @@ -17,7 +18,12 @@ public static class SentryNative /// The Sentry Unity options to use. public static void Configure(SentryUnityOptions options) { - if (options.WindowsNativeSupportEnabled) + if (ApplicationAdapter.Instance.Platform switch + { + RuntimePlatform.WindowsPlayer => options.WindowsNativeSupportEnabled, + RuntimePlatform.OSXPlayer => options.MacosNativeSupportEnabled, + _ => false, + }) { SentryNativeBridge.Init(options); ApplicationAdapter.Instance.Quitting += () => diff --git a/src/Sentry.Unity.Native/SentryNativeBridge.cs b/src/Sentry.Unity.Native/SentryNativeBridge.cs index 32520f5b1..4fafe61c9 100644 --- a/src/Sentry.Unity.Native/SentryNativeBridge.cs +++ b/src/Sentry.Unity.Native/SentryNativeBridge.cs @@ -10,16 +10,9 @@ namespace Sentry.Unity /// /// P/Invoke to `sentry-native` functions. /// - /// - /// The `sentry-native` SDK on Android is brought in through the `sentry-android-ndk` - /// maven package. - /// On Standalone players on Windows and Linux it's build directly for those platforms. - /// - /// /// public static class SentryNativeBridge { - public static bool CrashedLastRun; public static void Init(SentryUnityOptions options) @@ -173,19 +166,22 @@ private static void nativeLog(int cLevel, string message, IntPtr args, IntPtr us // vsnprintf (to find out the length of the resulting buffer) & vsprintf (to actually format the message). if (message.Contains("%")) { - var formattedLength = vsnprintf(null, UIntPtr.Zero, message, args); - var buffer = new StringBuilder(formattedLength + 1); - vsprintf(buffer, message, args); - message = buffer.ToString(); + // TODO macOS & Linux support + // var formattedLength = vsnprintf(null, UIntPtr.Zero, message, args); + // var buffer = new StringBuilder(formattedLength + 1); + // vsprintf(buffer, message, args); + // message = buffer.ToString(); } logger.Log(level, $"Native: {message}"); } - [DllImport("msvcrt.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] - private static extern int vsprintf(StringBuilder buffer, string format, IntPtr args); + // [DllImport("msvcrt.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + // [DllImport("__Internal", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + // private static extern int vsprintf(StringBuilder buffer, string format, IntPtr args); - [DllImport("msvcrt.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] - private static extern int vsnprintf(string? buffer, UIntPtr bufferSize, string format, IntPtr args); + // [DllImport("msvcrt.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + // [DllImport("__Internal", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + // private static extern int vsnprintf(string? buffer, UIntPtr bufferSize, string format, IntPtr args); [DllImport("sentry")] private static extern void sentry_init(IntPtr options); diff --git a/src/Sentry.Unity/SentryUnity.cs b/src/Sentry.Unity/SentryUnity.cs index 5263ed4db..535dff8ba 100644 --- a/src/Sentry.Unity/SentryUnity.cs +++ b/src/Sentry.Unity/SentryUnity.cs @@ -38,6 +38,7 @@ public static void Init(SentryUnityOptions options) // On Standalone, we disable cache dir in case multiple app instances run over the same path. // Note: we cannot use a named Mutex, because Unit doesn't support it. Instead, we create a file with `FileShare.None`. // https://forum.unity.com/threads/unsupported-internal-call-for-il2cpp-mutex-createmutex_internal-named-mutexes-are-not-supported.387334/ + // TODO macOS & Linux implementation if (ApplicationAdapter.Instance.Platform is RuntimePlatform.WindowsPlayer && options.CacheDirectoryPath is not null) { try