Skip to content

Commit

Permalink
iOS native bindings update (#222)
Browse files Browse the repository at this point in the history
* Make sure we never check values outside _logSize queue

* Use proguard symbolication in the Unity logger exception flow

* Do not use unsupported API

* iOS native bindings update

* Update iOS bindings
  • Loading branch information
konraddysput authored Jun 26, 2024
1 parent ecadffe commit 0b87a7e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
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
Binary file modified iOS/libBacktrace-Unity-Cocoa.a
Binary file not shown.

0 comments on commit 0b87a7e

Please sign in to comment.