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

Release v8.4.0 #869

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .buildkite/unity.2020.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ steps:
depends_on: "build-ios-fixture-2020"
agents:
queue: opensource
env:
UNITY_VERSION: *2020
plugins:
artifacts#v1.9.0:
download:
Expand Down
2 changes: 1 addition & 1 deletion Bugsnag/Assets/Bugsnag/Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
using System.Reflection;
[assembly: AssemblyVersion("8.3.1.0")]
[assembly: AssemblyVersion("8.4.0.0")]
2 changes: 1 addition & 1 deletion Bugsnag/Assets/Bugsnag/Runtime/BugsnagAutoInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace BugsnagUnity

public class BugsnagAutoInit
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void OnBeforeSceneLoadRuntimeMethod()
{
var settings = Resources.Load<BugsnagSettingsObject>("Bugsnag/BugsnagSettingsObject");
Expand Down
18 changes: 9 additions & 9 deletions Bugsnag/Assets/Bugsnag/Runtime/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ private void SetupAdvancedExceptionInterceptor()

public Client(INativeClient nativeClient)
{
InitMainthreadDispatcher();
NativeClient = nativeClient;
_errorBuilder = new ErrorBuilder(nativeClient);
CacheManager = new CacheManager(Configuration);
Expand Down Expand Up @@ -144,11 +143,6 @@ public Client(INativeClient nativeClient)
InitLogHandlers();
}

private void InitMainthreadDispatcher()
{
MainThreadDispatchBehaviour.Instance();
}

private bool IsUnity2019OrHigher()
{
var version = Application.unityVersion;
Expand Down Expand Up @@ -384,8 +378,7 @@ private void Notify(Error[] exceptions, HandledState handledState, Func<IEvent,
{
try
{
var asyncHandler = MainThreadDispatchBehaviour.Instance();
asyncHandler.Enqueue(() => { NotifyOnMainThread(exceptions, handledState, callback,logType, correlation); });
MainThreadDispatchBehaviour.Enqueue(() => { NotifyOnMainThread(exceptions, handledState, callback,logType, correlation); });
}
catch
{
Expand Down Expand Up @@ -459,6 +452,9 @@ private void NotifyOnMainThread(Error[] exceptions, HandledState handledState, F
@event.AddAndroidProjectPackagesToEvent(Configuration.ProjectPackages);
}

// save handled state before callbacks so we can check later if it was overidden
var initialUnhandledState = @event.Unhandled;

lock (CallbackLock)
{
foreach (var onErrorCallback in Configuration.GetOnErrorCallbacks())
Expand Down Expand Up @@ -492,6 +488,11 @@ private void NotifyOnMainThread(Error[] exceptions, HandledState handledState, F
// If the callback causes an exception, ignore it and execute the next one
}

if (initialUnhandledState != @event.Unhandled)
{
@event.UnhandledOverridden();
}

var report = new Report(Configuration, @event);
if (!report.Ignored)
{
Expand All @@ -508,7 +509,6 @@ private void NotifyOnMainThread(Error[] exceptions, HandledState handledState, F
}
}


private bool ShouldAddProjectPackagesToEvent(Payload.Event theEvent)
{
return Application.platform.Equals(RuntimePlatform.Android)
Expand Down
24 changes: 16 additions & 8 deletions Bugsnag/Assets/Bugsnag/Runtime/Delivery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public void Deliver(IPayload payload)
var report = (Report)payload;
if (_configuration.GetOnSendErrorCallbacks().Count > 0)
{
// save handled state before callbacks so we can check later if it was overidden
var initialUnhandledState = report.Event.Unhandled;
lock (_callbackLock)
{
foreach (var onSendErrorCallback in _configuration.GetOnSendErrorCallbacks())
Expand All @@ -84,14 +86,18 @@ public void Deliver(IPayload payload)
}
}
}
if (initialUnhandledState != report.Event.Unhandled)
{
report.Event.UnhandledOverridden();
}
}
report.Event.RedactMetadata(_configuration);
//pipeline expects and array of events even though we only ever report 1
report.ApplyEventsArray();
}
try
{
MainThreadDispatchBehaviour.Instance().Enqueue(PushToServer(payload));
MainThreadDispatchBehaviour.Enqueue(PushToServer(payload));
}
catch
{
Expand All @@ -110,7 +116,8 @@ IEnumerator PushToServer(IPayload payload)
else
{
var networkCheckDone = false;
new Thread(() => {
new Thread(() =>
{
shouldDeliver = _client.NativeClient.ShouldAttemptDelivery();
networkCheckDone = true;
}).Start();
Expand Down Expand Up @@ -158,7 +165,8 @@ IEnumerator PushToServer(IPayload payload)
else
{
var bodyReady = false;
new Thread(() => {
new Thread(() =>
{
try
{
body = PrepareEventBody(payload);
Expand Down Expand Up @@ -210,7 +218,7 @@ IEnumerator PushToServer(IPayload payload)
_payloadManager.RemovePayload(payload);
StartDeliveringCachedPayloads();
}
else if ( code == 0 || code == 408 || code == 429 || code >= 500)
else if (code == 0 || code == 408 || code == 429 || code >= 500)
{
// sending failed with no network or retryable error, cache payload to disk
_payloadManager.SendPayloadFailed(payload);
Expand Down Expand Up @@ -250,7 +258,7 @@ private byte[] PrepareEventBody(IPayload payload)
}
}
}

return serialisedPayload;
}

Expand All @@ -277,7 +285,7 @@ private byte[] PrepareEventBodySimple(IPayload payload)
}
}
}

return serialisedPayload;
}

Expand Down Expand Up @@ -508,7 +516,7 @@ public void StartDeliveringCachedPayloads()
try
{
_finishedCacheDeliveries.Clear();
MainThreadDispatchBehaviour.Instance().Enqueue(DeliverCachedPayloads());
MainThreadDispatchBehaviour.Enqueue(DeliverCachedPayloads());
}
catch
{
Expand Down Expand Up @@ -587,7 +595,7 @@ private IEnumerator ProcessCachedItems(Type t)
}
Deliver(report);
}

yield return new WaitUntil(() => CachedPayloadProcessed(id));
}
}
Expand Down
8 changes: 1 addition & 7 deletions Bugsnag/Assets/Bugsnag/Runtime/INativeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,7 @@ interface INativeClient : IFeatureFlagStore

IDictionary<string, object> GetNativeMetadata();

/// <summary>
/// Find the native loaded image that corresponds to a native instruction address
/// supplied by il2cpp_native_stack_trace().
/// </summary>
/// <param name="address">The address to find the corresponding image of</param>
/// <returns>The corresponding image, or null</returns>
LoadedImage FindImageAtAddress(UInt64 address);
StackTraceLine[] ToStackFrames(System.Exception exception);

bool ShouldAttemptDelivery();

Expand Down
4 changes: 3 additions & 1 deletion Bugsnag/Assets/Bugsnag/Runtime/LoadedImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ namespace BugsnagUnity
{
class LoadedImage
{
public LoadedImage(UInt64 loadAddress, UInt64 size, string fileName, string uuid)
public LoadedImage(UInt64 loadAddress, UInt64 size, string fileName, string uuid, bool isMainImage)
{
LoadAddress = loadAddress;
Size = size;
FileName = fileName;
Uuid = uuid;
IsMainImage = isMainImage;
}

public readonly UInt64 LoadAddress;
public readonly UInt64 Size;
public readonly string FileName;
public readonly string Uuid;
public readonly bool IsMainImage;
}
}
106 changes: 40 additions & 66 deletions Bugsnag/Assets/Bugsnag/Runtime/MainThreadDispatchBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
/*
Copyright 2015 Pim de Witte All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System;
using System;
using System.Collections.Generic;
using System.Collections;
using UnityEngine;
using UnityEngine.LowLevel;

/// Author: Pim de Witte (pimdewitte.com) and contributors
/// <summary>
/// A thread-safe class which holds a queue with actions to execute on the next Update() method. It can be used to make calls to the main thread for
/// things such as UI Manipulation in Unity. It was developed for use in combination with the Firebase Unity plugin, which uses separate threads for event handling
/// </summary>
namespace BugsnagUnity
{
public class MainThreadDispatchBehaviour : MonoBehaviour
public class BugsnagCoroutineRunner : MonoBehaviour
{
private static BugsnagCoroutineRunner _instance;

private static MainThreadDispatchBehaviour _instance;

private static readonly Queue<Action> _executionQueue = new Queue<Action>();
public static BugsnagCoroutineRunner Instance
{
get
{
if (_instance == null)
{
var runnerObject = new GameObject("BugsnagCoroutineRunner");
_instance = runnerObject.AddComponent<BugsnagCoroutineRunner>();
DontDestroyOnLoad(runnerObject);
}
return _instance;
}
}
}
public class MainThreadDispatchBehaviour
{

private static readonly Queue<Action> _executionQueue = new Queue<Action>();

public static MainThreadDispatchBehaviour Instance()
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void InitializeLoop()
{
if (_instance == null)
var playerLoop = PlayerLoop.GetCurrentPlayerLoop();
var newSystem = new PlayerLoopSystem
{
_instance = new GameObject("Bugsnag main thread dispatcher").AddComponent<MainThreadDispatchBehaviour>();
}
return _instance;
updateDelegate = OnUpdate
};

var systems = new List<PlayerLoopSystem>(playerLoop.subSystemList);
systems.Insert(0, newSystem);
playerLoop.subSystemList = systems.ToArray();
PlayerLoop.SetPlayerLoop(playerLoop);
}

public void Update()
private static void OnUpdate()
{
lock (_executionQueue)
{
Expand All @@ -54,50 +55,23 @@ public void Update()
}
}

/// <summary>
/// Locks the queue and adds the IEnumerator to the queue
/// </summary>
/// <param name="action">IEnumerator function that will be executed from the main thread.</param>
public void Enqueue(IEnumerator action)
public static void Enqueue(IEnumerator action)
{
lock (_executionQueue)
{
_executionQueue.Enqueue(() =>
{
StartCoroutine(action);
BugsnagCoroutineRunner.Instance.StartCoroutine(action);
});
}
}

/// <summary>
/// Locks the queue and adds the Action to the queue
/// </summary>
/// <param name="action">function that will be executed from the main thread.</param>
public void Enqueue(Action action)
public static void Enqueue(Action action)
{
Enqueue(ActionWrapper(action));
}
IEnumerator ActionWrapper(Action a)
{
a();
yield return null;
}

public void EnqueueWithDelayCoroutine(Action action, float delay)
{
StartCoroutine(DelayAction(action, delay));
}

private IEnumerator DelayAction(Action action, float delay)
{
yield return new WaitForSeconds(delay);
action.Invoke();
}

private void Awake()
{
DontDestroyOnLoad(gameObject);
lock (_executionQueue)
{
_executionQueue.Enqueue(action);
}
}

}
}
4 changes: 2 additions & 2 deletions Bugsnag/Assets/Bugsnag/Runtime/Native/Android/NativeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ public void RegisterForOnSessionCallbacks()
NativeInterface.RegisterForOnSessionCallbacks();
}

public LoadedImage FindImageAtAddress(UInt64 address)
public StackTraceLine[] ToStackFrames(System.Exception exception)
{
return null;
return new StackTraceLine[0];
}
}

Expand Down
Loading
Loading