Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing Backtrace/Crashpad DLLs gracefully #236

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions Runtime/Native/Windows/NativeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ private void HandleNativeCrashes(IDictionary<string, string> 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()))
{
Expand All @@ -122,12 +129,20 @@ private void HandleNativeCrashes(IDictionary<string, string> 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");
return;
}

if (!CaptureNativeCrashes)
{
Expand Down Expand Up @@ -255,7 +270,7 @@ public IEnumerator SendMinidumpOnStartup(ICollection<string> clientAttachments,
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), tempDirectory),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), tempDirectory)
};

List<string> nativeCrashesDirs = new List<string>();
foreach (string direcotry in crashDirectories)
{
Expand Down Expand Up @@ -328,8 +343,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);
}

/// <summary>
/// Clean scoped attributes
/// </summary>
Expand Down
Loading