diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d4302227..35335be27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/package-dev/Runtime/SentryInitialization.cs b/package-dev/Runtime/SentryInitialization.cs index 7cefc142b..f44875c77 100644 --- a/package-dev/Runtime/SentryInitialization.cs +++ b/package-dev/Runtime/SentryInitialization.cs @@ -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 diff --git a/src/Sentry.Unity.Native/SentryNative.cs b/src/Sentry.Unity.Native/SentryNative.cs index bcc5485ee..9825619fe 100644 --- a/src/Sentry.Unity.Native/SentryNative.cs +++ b/src/Sentry.Unity.Native/SentryNative.cs @@ -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(); } } diff --git a/src/Sentry.Unity.Native/SentryNativeBridge.cs b/src/Sentry.Unity.Native/SentryNativeBridge.cs index eb2367342..bde377f36 100644 --- a/src/Sentry.Unity.Native/SentryNativeBridge.cs +++ b/src/Sentry.Unity.Native/SentryNativeBridge.cs @@ -14,7 +14,6 @@ namespace Sentry.Unity.Native /// public static class SentryNativeBridge { - public static bool CrashedLastRun; public static bool Init(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo)