Skip to content

fix: Add missing WER handler on Windows #1873

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

Merged
merged 10 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Fixed an issue where the SDK would write the `SampleRate` as an `int` instead of a `float` to the Android Manifest, causing issues during the Android SDK's initialization ([#1872](https://github.com/getsentry/sentry-unity/pull/1872))
- The SDK no longer calls into `Application.persistentDataPath` on unknown platforms. This prevents crashes during startup on platforms with restricted disk access like the Nintendo Switch ([#1870](https://github.com/getsentry/sentry-unity/pull/1870))

### Features

- The SDK now also supports capturing native crashes via the WER handler on Windows ([#1873](https://github.com/getsentry/sentry-unity/pull/1873))

### Dependencies

- Bump Java SDK from v7.15.0 to v7.16.0 ([#1862](https://github.com/getsentry/sentry-unity/pull/1862))
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ Expected to exist:

<ItemGroup>
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/crashpad_build/handler/Release/crashpad_handler.exe" />
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/crashpad_build/handler/RelWithDebInfo/crashpad_wer.dll" />
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/RelWithDebInfo/sentry.dll" />
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/RelWithDebInfo/sentry.pdb" />
</ItemGroup>
Expand Down
39 changes: 18 additions & 21 deletions src/Sentry.Unity.Editor/Native/BuildPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,27 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)

private static void AddCrashHandler(IDiagnosticLogger logger, BuildTarget target, string buildOutputDir, string executableName)
{
string crashpadPath;
if (target is BuildTarget.StandaloneWindows64)
{
crashpadPath = Path.Combine("Windows", "Sentry", "crashpad_handler.exe");
}
else if (target is BuildTarget.StandaloneLinux64)
{
// No standalone crash handler for Linux - uses built-in breakpad.
return;
}
else if (target is BuildTarget.StandaloneOSX)
{
// No standalone crash handler for macOS - uses built-in handler in sentry-cocoa.
return;
}
else
switch (target)
{
throw new ArgumentException($"Unsupported build target: {target}");
case BuildTarget.StandaloneWindows64:
CopyHandler(logger, buildOutputDir, Path.Combine("Windows", "Sentry", "crashpad_handler.exe"));
CopyHandler(logger, buildOutputDir, Path.Combine("Windows", "Sentry", "crashpad_wer.dll"));
break;
case BuildTarget.StandaloneLinux64:
case BuildTarget.StandaloneOSX:
// No standalone crash handler for Linux/macOS - uses built-in handlers.
return;
default:
throw new ArgumentException($"Unsupported build target: {target}");
}
}

crashpadPath = Path.GetFullPath(Path.Combine("Packages", SentryPackageInfo.GetName(), "Plugins", crashpadPath));
var targetPath = Path.Combine(buildOutputDir, Path.GetFileName(crashpadPath));
logger.LogInfo("Copying the native crash handler '{0}' to {1}", Path.GetFileName(crashpadPath), targetPath);
File.Copy(crashpadPath, targetPath, true);
private static void CopyHandler(IDiagnosticLogger logger, string buildOutputDir, string handlerPath)
{
var fullHandlerPath = Path.GetFullPath(Path.Combine("Packages", SentryPackageInfo.GetName(), "Plugins", handlerPath));
var targetHandlerPath = Path.Combine(buildOutputDir, Path.GetFileName(fullHandlerPath));
logger.LogInfo("Copying handler '{0}' to {1}", Path.GetFileName(fullHandlerPath), targetHandlerPath);
File.Copy(fullHandlerPath, targetHandlerPath, true);
}

private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget target, string buildOutputDir, string executableName, SentryUnityOptions options, SentryCliOptions? cliOptions, bool isMono)
Expand Down
2 changes: 2 additions & 0 deletions test/Scripts.Tests/package-release.zip.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,8 @@ Plugins/Android/Sentry~/sentry.jar
Plugins/Windows/Sentry.meta
Plugins/Windows/Sentry/crashpad_handler.exe
Plugins/Windows/Sentry/crashpad_handler.exe.meta
Plugins/Windows/Sentry/crashpad_wer.dll
Plugins/Windows/Sentry/crashpad_wer.dll.meta
Plugins/Windows/Sentry/sentry.dll
Plugins/Windows/Sentry/sentry.dll.meta
Plugins/Windows/Sentry/sentry.pdb
Expand Down
Loading