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

fix: Reinstall backend to capture native crashes #1622

Merged
merged 10 commits into from
Apr 15, 2024
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- Tweaked the SDK reinstalling the backend to capture native crashes on Windows. C++ exceptions are now getting properly captured again ([#1622](https://github.com/getsentry/sentry-unity/pull/1622))

### Dependencies

- Bump Java SDK from v7.6.0 to v7.7.0 ([#1610](https://github.com/getsentry/sentry-unity/pull/1610))
Expand Down
11 changes: 11 additions & 0 deletions package-dev/Runtime/SentryInitialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ public static void Init()
#endif
}
}

#if SENTRY_NATIVE
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void ReinstallBackend()
{
// At this point Unity has taken the signal handler and will not invoke our handler. So we register our
// backend once more to make sure user-defined data is available in the crash report and the SDK is able
// to capture the crash.
SentryNative.ReinstallBackend();
}
#endif
}

public class SentryUnityInfo : ISentryUnityInfo
Expand Down
7 changes: 2 additions & 5 deletions src/Sentry.Unity.Native/SentryNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ public static void Configure(SentryUnityOptions options, ISentryUnityInfo sentry
}
}
options.CrashedLastRun = () => crashedLastRun;

// At this point Unity has taken the signal handler and will not invoke our handler. So we register our
// backend once more to make sure user-defined data is available in the crash report and the SDK is able
// to capture the crash.
SentryNativeBridge.ReinstallBackend();
}

public static void ReinstallBackend() => SentryNativeBridge.ReinstallBackend();
}
}
1 change: 0 additions & 1 deletion src/Sentry.Unity.Native/SentryNativeBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace Sentry.Unity.Native
/// <see href="https://github.com/getsentry/sentry-native"/>
public static class SentryNativeBridge
{

public static bool CrashedLastRun;

public static bool Init(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo)
Expand Down
Loading