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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Backtrace Unity Release Notes

## Version 3.1.1
- Prevent erroneously extending backtraceClient attributes with backtraceReport attributes.
- Removed randomly generated path to assembly from callstacks.
- Prevent client from multi initialization.

## Version 3.1.0
This release adds an ability to capture native NDK crashes from Unity games deployed on Android. The Backtrace Configuration now exposes a setting for games being prepared for Android OS to choose `Capture native crashes`. When enabled, Backtrace will capture and symbolicate native stack traces from crashes impacting the Unity Engine or any Unity Engine Plugin.

Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,7 @@ backtraceClient.BeforeSend =

## Reporting unhandled application exceptions

`BacktraceClient` supports reporting of unhandled application exceptions not captured by your try-catch blocks. To enable reporting of unhandled exceptions even if you don't set this option in `Backtrace configuration window` please use code below:

```csharp
backtraceClient.HandleApplicationException();
```
`BacktraceClient` supports reporting of unhandled application exceptions not captured by your try-catch blocks. To enable reporting of unhandled exceptions please use Backtrace configuration UI available in the Unity IDE.

## Filtering a report
Report filtering is enabled by using the `Filter reports` option in the user interface or for more advanced use-cases, the `SkipReport` delegate available in the BacktraceClient.
Expand Down
18 changes: 16 additions & 2 deletions Runtime/BacktraceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public string this[string index]
set
{
_clientAttributes[index] = value;
if(_nativeClient != null)
if (_nativeClient != null)
{
_nativeClient.SetAttribute(index, value);
}
Expand All @@ -58,6 +58,14 @@ public void SetAttributes(Dictionary<string, string> attributes)
}
}

/// <summary>
/// Number of client attributes
/// </summary>
public int GetAttributesCount()
{
return _clientAttributes.Count;
}

/// <summary>
/// Backtrace client instance.
/// </summary>
Expand Down Expand Up @@ -261,6 +269,11 @@ public void Refresh()
return;
}

if (Instance != null)
{
return;
}

Enabled = true;

CaptureUnityMessages();
Expand Down Expand Up @@ -528,7 +541,8 @@ private BacktraceData SetupBacktraceData(BacktraceReport report)
? _clientAttributes
: _nativeClient.GetAttributes().Merge(_clientAttributes);

return report.ToBacktraceData(reportAttributes, GameObjectDepth);
// pass copy of dictionary to prevent overriding client attributes
return report.ToBacktraceData(new Dictionary<string, string>(reportAttributes), GameObjectDepth);
}

#if UNITY_ANDROID
Expand Down
4 changes: 4 additions & 0 deletions Runtime/BacktraceDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public void Reload()
{
Configuration = GetComponent<BacktraceClient>().Configuration;
}
if (Instance != null)
{
return;
}
if (Configuration == null || !Configuration.IsValid())
{
Enable = false;
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Model/BacktraceData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class BacktraceData
/// <summary>
/// Version of the C# library
/// </summary>
public const string AgentVersion = "3.1.0";
public const string AgentVersion = "3.1.1";

/// <summary>
/// Application thread details
Expand Down
6 changes: 5 additions & 1 deletion Runtime/Model/BacktraceStackFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ public BacktraceJObject ToJson()
["il"] = Il,
["metadata_token"] = MemberInfo,
["address"] = ILOffset,
["library"] = Library,
["assembly"] = Assembly
};

if (!string.IsNullOrEmpty(Library) && !(Library.StartsWith("<") && Library.EndsWith(">")))
{
stackFrame["library"] = Library;
}

if (Line != 0)
{
Expand Down
3 changes: 1 addition & 2 deletions Runtime/Model/BacktraceUnhandledException.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;

namespace Backtrace.Unity.Model
{
Expand Down Expand Up @@ -43,7 +42,7 @@ public override string StackTrace
/// <summary>
/// Unhandled exception stack frames
/// </summary>
public List<BacktraceStackFrame> StackFrames = new List<BacktraceStackFrame>();
public readonly List<BacktraceStackFrame> StackFrames = new List<BacktraceStackFrame>();


public BacktraceUnhandledException(string message, string stacktrace) : base(message)
Expand Down
39 changes: 24 additions & 15 deletions Tests/Runtime/BacktraceAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ public IEnumerator TesClientAttributeAccessor_BacktraceDataShouldIncludeClientAt
yield return null;
}

[UnityTest]
public IEnumerator TesClientAttributes_ReprotShouldntExtendClientAttributes_ClientAttributesWontStoreReportAttributes()
{
var key = "foo";
var value = "bar";
BacktraceClient[key] = value;
BacktraceData data = null;
BacktraceClient.BeforeSend = (BacktraceData reportData) =>
{
data = reportData;
return null;
};
BacktraceClient.Send(new Exception("foo"));
yield return new WaitForEndOfFrame();
Assert.IsNotNull(data);
Assert.AreEqual(data.Attributes.Attributes[key], value);
Assert.AreEqual(1, BacktraceClient.GetAttributesCount());
BacktraceClient.Send(new Exception("bar"));
Assert.AreEqual(1, BacktraceClient.GetAttributesCount());
yield return null;
}


[UnityTest]
public IEnumerator TesClientAttributesMethod_BacktraceDataShouldIncludeClientAttributes_ClientAttributesAreAvailableInDiagnosticData()
Expand Down Expand Up @@ -80,8 +102,8 @@ public IEnumerator TestAttributesGeneration_CreateCorrectAttributes_WithDiffrent
yield return null;
}

[UnityTest]
public IEnumerator TestCorrectDictionaryGeneration_CreateCorrectAttributesDictionary_WithDiffrentClientAttributes()
[Test]
public void TestCorrectDictionaryGeneration_CreateCorrectAttributesDictionary_WithDiffrentClientAttributes()
{
var exception = new FileNotFoundException();
var reportAttributeKey = "report_attr";
Expand All @@ -98,19 +120,6 @@ public IEnumerator TestCorrectDictionaryGeneration_CreateCorrectAttributesDictio
Assert.IsTrue(testObject.Attributes.Keys.Any(n => n == reportAttributeKey));
Assert.IsTrue(testObject.Attributes[clientAttributeKey] == clientAttributeValue);
Assert.IsTrue(testObject.Attributes[reportAttributeKey] == reportAttributeValue);
yield return null;
}

[UnityTest]
public IEnumerator TestCorrectDictionaryGeneration_ReplaceAttributes_TheSameDictionaryAttributes()
{
var reportAttributeKey = "report_attr";
var reportAttributeValue = string.Format("{0}-value", reportAttributeKey);
var clientAttributes = new Dictionary<string, string>() { { reportAttributeKey,
string.Format("{0}-client", reportAttributeValue)
} };
Assert.IsFalse(clientAttributes[reportAttributeKey] == reportAttributeValue);
yield return null;
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "io.backtrace.unity",
"displayName": "Backtrace",
"version": "3.1.0",
"version": "3.1.1",
"unity": "2017.1",
"description": "Backtrace's integration with Unity games allows customers to capture and report handled and unhandled Unity exceptions to their Backtrace instance, instantly offering the ability to prioritize and debug software errors.",
"keywords": [
Expand Down