Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
projectPath: ${{ matrix.projectPath }}/
allowDirtyBuild: true

7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ jobs:
projectPath:
- test-package
unityVersion:
- 2022.3.19f1
- 2019.4.40f1
- 2020.3.48f1
# Pending LTS License
#- 2021.3.48f1
#- 6000.0.38f1
- 2022.3.56f1
steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand Down
Binary file modified Android/lib/arm64-v8a/libbacktrace-native.so
Binary file not shown.
2 changes: 1 addition & 1 deletion Android/lib/arm64-v8a/libbacktrace-native.so.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed Android/lib/arm64-v8a/libcrashpad_handler.so
Binary file not shown.
Binary file modified Android/lib/arm64-v8a/libnative-lib.so
Binary file not shown.
2 changes: 1 addition & 1 deletion Android/lib/arm64-v8a/libnative-lib.so.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Android/lib/armeabi-v7a/libbacktrace-native.so
Binary file not shown.
2 changes: 1 addition & 1 deletion Android/lib/armeabi-v7a/libbacktrace-native.so.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed Android/lib/armeabi-v7a/libcrashpad_handler.so
Binary file not shown.
34 changes: 0 additions & 34 deletions Android/lib/armeabi-v7a/libcrashpad_handler.so.meta

This file was deleted.

Binary file modified Android/lib/armeabi-v7a/libnative-lib.so
Binary file not shown.
2 changes: 1 addition & 1 deletion Android/lib/armeabi-v7a/libnative-lib.so.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Android/lib/x86/libbacktrace-native.so
Binary file not shown.
3 changes: 1 addition & 2 deletions Android/lib/x86/libbacktrace-native.so.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed Android/lib/x86/libcrashpad_handler.so
Binary file not shown.
Binary file modified Android/lib/x86/libnative-lib.so
Binary file not shown.
8 changes: 8 additions & 0 deletions Android/lib/x86_64.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Android/lib/x86_64/libbacktrace-native.so
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Android/lib/x86_64/libnative-lib.so
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 23 additions & 38 deletions Runtime/Native/Android/NativeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ namespace Backtrace.Unity.Runtime.Native.Android
internal sealed class NativeClient : NativeClientBase, INativeClient
{
private const string CallbackMethodName = "OnAnrDetected";
[DllImport("backtrace-native")]
private static extern bool Initialize(IntPtr submissionUrl, IntPtr databasePath, IntPtr handlerPath, IntPtr keys, IntPtr values, IntPtr attachments, bool enableClientSideUnwinding, int unwindingMode);

[DllImport("backtrace-native")]
private static extern bool InitializeJavaCrashHandler(IntPtr submissionUrl, IntPtr databasePath, IntPtr classPath, IntPtr keys, IntPtr values, IntPtr attachments, IntPtr environmentVariables);
Expand Down Expand Up @@ -86,11 +84,6 @@ private void SetDefaultAttributeMaps()
// Unity-Android native interface path
private const string _namespace = "backtraceio.unity";

/// <summary>
/// unwinding mode
/// </summary>
private UnwindingMode UnwindingMode = UnwindingMode.LOCAL_DUMPWITHOUTCRASH;

/// <summary>
/// Path to class responsible for detecting ANRs occurred by Java code.
/// </summary>
Expand Down Expand Up @@ -131,7 +124,6 @@ private void SetDefaultAttributeMaps()
/// </summary>
private AndroidJavaObject _unhandledExceptionWatcher;

private readonly bool _enableClientSideUnwinding = false;
public string GameObjectName { get; internal set; }
public NativeClient(BacktraceConfiguration configuration, BacktraceBreadcrumbs breadcrumbs, IDictionary<string, string> clientAttributes, IEnumerable<string> attachments, string gameObjectName) : base(configuration, breadcrumbs)
{
Expand All @@ -141,9 +133,7 @@ public NativeClient(BacktraceConfiguration configuration, BacktraceBreadcrumbs b
{
return;
}
#if UNITY_2019_2_OR_NEWER
_enableClientSideUnwinding = _configuration.ClientSideUnwinding;
#endif

HandlerANR = _configuration.HandleANR;
HandleNativeCrashes(clientAttributes, attachments);
if (!configuration.ReportFilterType.HasFlag(Types.ReportFilterType.Hang))
Expand Down Expand Up @@ -246,8 +236,16 @@ private void HandleNativeCrashes(IDictionary<string, string> backtraceAttributes
Debug.LogWarning("Backtrace native integration status: Disabled NDK integration");
return;
}

var databasePath = _configuration.CrashpadDatabasePath;
if (string.IsNullOrEmpty(databasePath) || !Directory.Exists(_configuration.GetFullDatabasePath()))
var fullDatabasePath = _configuration.GetFullDatabasePath();

if (string.IsNullOrEmpty(databasePath) || string.IsNullOrEmpty(fullDatabasePath))
{
Debug.LogWarning("Backtrace native integration status: database path undefined");
return;
}
if (!Directory.Exists(fullDatabasePath))
{
Debug.LogWarning("Backtrace native integration status: database path doesn't exist");
return;
Expand All @@ -261,6 +259,7 @@ private void HandleNativeCrashes(IDictionary<string, string> backtraceAttributes
int apiLevel;
if (apiLevelString == null || !int.TryParse(apiLevelString, out apiLevel))
{
Debug.LogWarning("Backtrace native integration status: Cannot determine Android API level");
return;
}

Expand All @@ -275,25 +274,29 @@ private void HandleNativeCrashes(IDictionary<string, string> backtraceAttributes

var minidumpUrl = new BacktraceCredentials(_configuration.GetValidServerUrl()).GetMinidumpSubmissionUrl().ToString();

// Resolve native library directory
var libDirectory = GetNativeDirectoryPath();
if (string.IsNullOrEmpty(libDirectory) || !Directory.Exists(libDirectory))
{
libDirectory = GuessNativeDirectoryPath();
}
const string crashpadHandlerName = "libcrashpad_handler.so";
var crashpadHandlerPath = Path.Combine(libDirectory, crashpadHandlerName);

CaptureNativeCrashes = CanInitializeExecutableCrashHandler(libDirectory, crashpadHandlerPath)
? InitializeExecutableCrashHandler(minidumpUrl, databasePath, crashpadHandlerPath, attachments)
: InitializeJavaCrashHandler(minidumpUrl, databasePath, backtraceAttributes["device.abi"], libDirectory, attachments);
if (string.IsNullOrEmpty(libDirectory) || !Directory.Exists(libDirectory))
{
Debug.LogWarning("Backtrace native integration status: Cannot resolve native library directory");
return;
}

CaptureNativeCrashes = InitializeJavaCrashHandler(minidumpUrl, databasePath, backtraceAttributes["device.abi"], libDirectory, attachments);

if (!CaptureNativeCrashes)
{
Debug.LogWarning("Backtrace native integration status: Cannot initialize Crashpad client");
Debug.LogWarning("Backtrace native integration status: Cannot initialize Java crash handler");
return;
}

foreach (var attribute in backtraceAttributes)
{
{
AddAttribute(AndroidJNI.NewStringUTF(attribute.Key), AndroidJNI.NewStringUTF(attribute.Value));
}

Expand All @@ -305,25 +308,7 @@ private void HandleNativeCrashes(IDictionary<string, string> backtraceAttributes
// don't add attributes that can change over the time to initialization method attributes. Crashpad will prevent from
// overriding them on game runtime. ANRs/OOMs methods can override error.type attribute, so we shouldn't pass error.type
// attribute via attributes parameters.
AddAttribute(
AndroidJNI.NewStringUTF(ErrorTypeAttribute),
AndroidJNI.NewStringUTF(CrashType));
}

private bool CanInitializeExecutableCrashHandler(String nativeLibraryDirectory, String handlerPath) {
return Directory.Exists(nativeLibraryDirectory) && File.Exists(handlerPath);
}

private bool InitializeExecutableCrashHandler(String minidumpUrl, String databasePath, String crashpadHandlerPath, IEnumerable<String> attachments) {
return Initialize(
AndroidJNI.NewStringUTF(minidumpUrl),
AndroidJNI.NewStringUTF(databasePath),
AndroidJNI.NewStringUTF(crashpadHandlerPath),
AndroidJNIHelper.ConvertToJNIArray(new string[0]),
AndroidJNIHelper.ConvertToJNIArray(new string[0]),
AndroidJNIHelper.ConvertToJNIArray(attachments.ToArray()),
_enableClientSideUnwinding,
(int)UnwindingMode);
AddAttribute(AndroidJNI.NewStringUTF(ErrorTypeAttribute), AndroidJNI.NewStringUTF(CrashType));
}

private bool InitializeJavaCrashHandler(String minidumpUrl, String databasePath, String deviceAbi, String nativeDirectory, IEnumerable<String> attachments) {
Expand Down
Loading