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

Unity unhandled exception proguard flow #221

Merged
merged 2 commits into from
Jun 26, 2024
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
8 changes: 7 additions & 1 deletion Runtime/BacktraceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,14 @@ internal void HandleUnityMessage(string message, string stackTrace, LogType type
Type = type
};
}
var report = new BacktraceReport(exception);
#if UNITY_ANDROID
if(exception.NativeStackTrace && _useProguard) {
report.UseSymbolication("proguard");
}
#endif

SendUnhandledExceptionReport(new BacktraceReport(exception), invokeSkipApi);
SendUnhandledExceptionReport(report, invokeSkipApi);
}

/// <summary>
Expand Down
13 changes: 12 additions & 1 deletion Runtime/Model/BacktraceUnhandledException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public override string StackTrace
/// </summary>
public readonly List<BacktraceStackFrame> StackFrames;

/// <summary>
/// Returns information if the stack trace is from the native environment (non-Unity)
/// </summary>
internal bool NativeStackTrace
{
get;
private set;
}

public BacktraceUnhandledException(string message, string stacktrace) : base(message)
{
Expand Down Expand Up @@ -172,6 +180,8 @@ private BacktraceStackFrame ConvertFrame(string frameString, int methodNameEndIn
FunctionName = frameString
};
}

NativeStackTrace = true;
// add length of the '('
methodStartIndex += 1;
var methodArguments = frameString.Substring(methodStartIndex, methodNameEndIndex - methodStartIndex);
Expand Down Expand Up @@ -250,7 +260,8 @@ private BacktraceStackFrame SetJITStackTraceInformation(string frameString)
{
stackFrame.Library = stackFrame.FunctionName.Substring(0, libraryNameSeparator).Trim();
stackFrame.FunctionName = stackFrame.FunctionName.Substring(++libraryNameSeparator).Trim();
} else
}
else
{
stackFrame.Library = "native";
}
Expand Down
17 changes: 17 additions & 0 deletions Tests/Runtime/BacktraceStackTraceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,23 @@ public void TestStackTraceCreation_AndroidException_ValidStackTraceObject()
}
}

[Test]
public void TestNativeStackTraceDetection_AndroidExceptionShouldSetFlag_NativeStackTraceIsSet()
{
var stackTrace = ConvertStackTraceToString(_anrStackTrace);
var exception = new BacktraceUnhandledException(string.Empty, stackTrace);
Assert.IsTrue(exception.NativeStackTrace);
}


[Test]
public void TestNativeStackTraceDetection_UnityExceptionShouldNotSetFlag_NativeStackTraceIsNotSet()
{
var stackTrace = ConvertStackTraceToString(_simpleStack);
var exception = new BacktraceUnhandledException(string.Empty, stackTrace);
Assert.IsFalse(exception.NativeStackTrace);
}


[Test]
public void TestStackTraceCreation_AndroidMixModeCallStack_ValidStackTraceObject()
Expand Down
Loading