Skip to content

Commit

Permalink
fix: Reinstall backend to capture native crashes (#1622)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsandfoxes authored Apr 15, 2024
1 parent 86a55b3 commit 8f8805c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
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.8.0 ([#1610](https://github.com/getsentry/sentry-unity/pull/1610), [#1613](https://github.com/getsentry/sentry-unity/pull/1613))
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

0 comments on commit 8f8805c

Please sign in to comment.