From 64dbf0282107d87343feeae64b262c306bdf9d6a Mon Sep 17 00:00:00 2001 From: Ben Hymers Date: Fri, 10 Jan 2025 08:56:02 +0000 Subject: [PATCH 1/2] Handle missing Backtrace/Crashpad DLLs gracefully --- Runtime/Native/Windows/NativeClient.cs | 34 +++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Runtime/Native/Windows/NativeClient.cs b/Runtime/Native/Windows/NativeClient.cs index 6a966d85..d882a318 100644 --- a/Runtime/Native/Windows/NativeClient.cs +++ b/Runtime/Native/Windows/NativeClient.cs @@ -108,6 +108,13 @@ private void HandleNativeCrashes(IDictionary clientAttributes, I return; } + var backtraceCrashpadHandlerPath = GetDefaultPathToBacktraceCrashpadHandler(pluginDirectoryPath); + if (string.IsNullOrEmpty(backtraceCrashpadHandlerPath) || !File.Exists(backtraceCrashpadHandlerPath)) + { + Debug.LogWarning("Backtrace native integration status: Cannot find path to Backtrace Crashpad handler."); + return; + } + var databasePath = _configuration.CrashpadDatabasePath; if (string.IsNullOrEmpty(databasePath) || !Directory.Exists(_configuration.GetFullDatabasePath())) { @@ -122,12 +129,19 @@ private void HandleNativeCrashes(IDictionary clientAttributes, I Directory.CreateDirectory(databasePath); } - CaptureNativeCrashes = Initialize( - minidumpUrl, - databasePath, - crashpadHandlerPath, - attachments.ToArray(), - attachments.Count()); + try + { + CaptureNativeCrashes = Initialize( + minidumpUrl, + databasePath, + crashpadHandlerPath, + attachments.ToArray(), + attachments.Count() ); + } + catch ( DllNotFoundException ) + { + Debug.LogWarning("Backtrace native integration status: Can't load Backtrace DLL"); + } if (!CaptureNativeCrashes) { @@ -328,8 +342,16 @@ private string GetDefaultPathToCrashpadHandler(string pluginDirectoryPath) const string supportedArchitecture = "x86_64"; var architectureDirectory = Path.Combine(pluginDirectoryPath, supportedArchitecture); return Path.Combine(architectureDirectory, crashpadHandlerName); + } + private string GetDefaultPathToBacktraceCrashpadHandler(string pluginDirectoryPath) + { + const string crashpadHandlerName = "BacktraceCrashpadWindows.dll"; + const string supportedArchitecture = "x86_64"; + var architectureDirectory = Path.Combine(pluginDirectoryPath, supportedArchitecture); + return Path.Combine(architectureDirectory, crashpadHandlerName); } + /// /// Clean scoped attributes /// From f599eb0bdc82dfe6556571f7776c4c887bb2e3dd Mon Sep 17 00:00:00 2001 From: kdysput Date: Fri, 24 Jan 2025 15:43:15 +0100 Subject: [PATCH 2/2] Format file and return on error --- Runtime/Native/Windows/NativeClient.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Runtime/Native/Windows/NativeClient.cs b/Runtime/Native/Windows/NativeClient.cs index d882a318..6719848e 100644 --- a/Runtime/Native/Windows/NativeClient.cs +++ b/Runtime/Native/Windows/NativeClient.cs @@ -136,11 +136,12 @@ private void HandleNativeCrashes(IDictionary clientAttributes, I databasePath, crashpadHandlerPath, attachments.ToArray(), - attachments.Count() ); + attachments.Count()); } - catch ( DllNotFoundException ) + catch (DllNotFoundException) { Debug.LogWarning("Backtrace native integration status: Can't load Backtrace DLL"); + return; } if (!CaptureNativeCrashes) @@ -269,7 +270,7 @@ public IEnumerator SendMinidumpOnStartup(ICollection clientAttachments, Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), tempDirectory), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), tempDirectory) }; - + List nativeCrashesDirs = new List(); foreach (string direcotry in crashDirectories) {