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
12 changes: 12 additions & 0 deletions package-dev/Runtime/SentryInitialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,20 @@ 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
}


bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
public class SentryUnityInfo : ISentryUnityInfo
{
public bool IL2CPP
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