Skip to content

Commit 7704f96

Browse files
authored
Merge pull request #869 from bugsnag/next
Release v8.4.0
2 parents ff806ea + d3b317e commit 7704f96

File tree

34 files changed

+573
-184
lines changed

34 files changed

+573
-184
lines changed

.buildkite/unity.2020.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ steps:
183183
depends_on: "build-ios-fixture-2020"
184184
agents:
185185
queue: opensource
186+
env:
187+
UNITY_VERSION: *2020
186188
plugins:
187189
artifacts#v1.9.0:
188190
download:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
using System.Reflection;
2-
[assembly: AssemblyVersion("8.3.1.0")]
2+
[assembly: AssemblyVersion("8.4.0.0")]

Bugsnag/Assets/Bugsnag/Runtime/BugsnagAutoInit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace BugsnagUnity
44

55
public class BugsnagAutoInit
66
{
7-
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
7+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
88
static void OnBeforeSceneLoadRuntimeMethod()
99
{
1010
var settings = Resources.Load<BugsnagSettingsObject>("Bugsnag/BugsnagSettingsObject");

Bugsnag/Assets/Bugsnag/Runtime/Client.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ private void SetupAdvancedExceptionInterceptor()
116116

117117
public Client(INativeClient nativeClient)
118118
{
119-
InitMainthreadDispatcher();
120119
NativeClient = nativeClient;
121120
_errorBuilder = new ErrorBuilder(nativeClient);
122121
CacheManager = new CacheManager(Configuration);
@@ -144,11 +143,6 @@ public Client(INativeClient nativeClient)
144143
InitLogHandlers();
145144
}
146145

147-
private void InitMainthreadDispatcher()
148-
{
149-
MainThreadDispatchBehaviour.Instance();
150-
}
151-
152146
private bool IsUnity2019OrHigher()
153147
{
154148
var version = Application.unityVersion;
@@ -384,8 +378,7 @@ private void Notify(Error[] exceptions, HandledState handledState, Func<IEvent,
384378
{
385379
try
386380
{
387-
var asyncHandler = MainThreadDispatchBehaviour.Instance();
388-
asyncHandler.Enqueue(() => { NotifyOnMainThread(exceptions, handledState, callback,logType, correlation); });
381+
MainThreadDispatchBehaviour.Enqueue(() => { NotifyOnMainThread(exceptions, handledState, callback,logType, correlation); });
389382
}
390383
catch
391384
{
@@ -459,6 +452,9 @@ private void NotifyOnMainThread(Error[] exceptions, HandledState handledState, F
459452
@event.AddAndroidProjectPackagesToEvent(Configuration.ProjectPackages);
460453
}
461454

455+
// save handled state before callbacks so we can check later if it was overidden
456+
var initialUnhandledState = @event.Unhandled;
457+
462458
lock (CallbackLock)
463459
{
464460
foreach (var onErrorCallback in Configuration.GetOnErrorCallbacks())
@@ -492,6 +488,11 @@ private void NotifyOnMainThread(Error[] exceptions, HandledState handledState, F
492488
// If the callback causes an exception, ignore it and execute the next one
493489
}
494490

491+
if (initialUnhandledState != @event.Unhandled)
492+
{
493+
@event.UnhandledOverridden();
494+
}
495+
495496
var report = new Report(Configuration, @event);
496497
if (!report.Ignored)
497498
{
@@ -508,7 +509,6 @@ private void NotifyOnMainThread(Error[] exceptions, HandledState handledState, F
508509
}
509510
}
510511

511-
512512
private bool ShouldAddProjectPackagesToEvent(Payload.Event theEvent)
513513
{
514514
return Application.platform.Equals(RuntimePlatform.Android)

Bugsnag/Assets/Bugsnag/Runtime/Delivery.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public void Deliver(IPayload payload)
6767
var report = (Report)payload;
6868
if (_configuration.GetOnSendErrorCallbacks().Count > 0)
6969
{
70+
// save handled state before callbacks so we can check later if it was overidden
71+
var initialUnhandledState = report.Event.Unhandled;
7072
lock (_callbackLock)
7173
{
7274
foreach (var onSendErrorCallback in _configuration.GetOnSendErrorCallbacks())
@@ -84,14 +86,18 @@ public void Deliver(IPayload payload)
8486
}
8587
}
8688
}
89+
if (initialUnhandledState != report.Event.Unhandled)
90+
{
91+
report.Event.UnhandledOverridden();
92+
}
8793
}
8894
report.Event.RedactMetadata(_configuration);
8995
//pipeline expects and array of events even though we only ever report 1
9096
report.ApplyEventsArray();
9197
}
9298
try
9399
{
94-
MainThreadDispatchBehaviour.Instance().Enqueue(PushToServer(payload));
100+
MainThreadDispatchBehaviour.Enqueue(PushToServer(payload));
95101
}
96102
catch
97103
{
@@ -110,7 +116,8 @@ IEnumerator PushToServer(IPayload payload)
110116
else
111117
{
112118
var networkCheckDone = false;
113-
new Thread(() => {
119+
new Thread(() =>
120+
{
114121
shouldDeliver = _client.NativeClient.ShouldAttemptDelivery();
115122
networkCheckDone = true;
116123
}).Start();
@@ -158,7 +165,8 @@ IEnumerator PushToServer(IPayload payload)
158165
else
159166
{
160167
var bodyReady = false;
161-
new Thread(() => {
168+
new Thread(() =>
169+
{
162170
try
163171
{
164172
body = PrepareEventBody(payload);
@@ -210,7 +218,7 @@ IEnumerator PushToServer(IPayload payload)
210218
_payloadManager.RemovePayload(payload);
211219
StartDeliveringCachedPayloads();
212220
}
213-
else if ( code == 0 || code == 408 || code == 429 || code >= 500)
221+
else if (code == 0 || code == 408 || code == 429 || code >= 500)
214222
{
215223
// sending failed with no network or retryable error, cache payload to disk
216224
_payloadManager.SendPayloadFailed(payload);
@@ -250,7 +258,7 @@ private byte[] PrepareEventBody(IPayload payload)
250258
}
251259
}
252260
}
253-
261+
254262
return serialisedPayload;
255263
}
256264

@@ -277,7 +285,7 @@ private byte[] PrepareEventBodySimple(IPayload payload)
277285
}
278286
}
279287
}
280-
288+
281289
return serialisedPayload;
282290
}
283291

@@ -508,7 +516,7 @@ public void StartDeliveringCachedPayloads()
508516
try
509517
{
510518
_finishedCacheDeliveries.Clear();
511-
MainThreadDispatchBehaviour.Instance().Enqueue(DeliverCachedPayloads());
519+
MainThreadDispatchBehaviour.Enqueue(DeliverCachedPayloads());
512520
}
513521
catch
514522
{
@@ -587,7 +595,7 @@ private IEnumerator ProcessCachedItems(Type t)
587595
}
588596
Deliver(report);
589597
}
590-
598+
591599
yield return new WaitUntil(() => CachedPayloadProcessed(id));
592600
}
593601
}

Bugsnag/Assets/Bugsnag/Runtime/INativeClient.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,7 @@ interface INativeClient : IFeatureFlagStore
103103

104104
IDictionary<string, object> GetNativeMetadata();
105105

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

114108
bool ShouldAttemptDelivery();
115109

Bugsnag/Assets/Bugsnag/Runtime/LoadedImage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ namespace BugsnagUnity
44
{
55
class LoadedImage
66
{
7-
public LoadedImage(UInt64 loadAddress, UInt64 size, string fileName, string uuid)
7+
public LoadedImage(UInt64 loadAddress, UInt64 size, string fileName, string uuid, bool isMainImage)
88
{
99
LoadAddress = loadAddress;
1010
Size = size;
1111
FileName = fileName;
1212
Uuid = uuid;
13+
IsMainImage = isMainImage;
1314
}
1415

1516
public readonly UInt64 LoadAddress;
1617
public readonly UInt64 Size;
1718
public readonly string FileName;
1819
public readonly string Uuid;
20+
public readonly bool IsMainImage;
1921
}
2022
}
Lines changed: 40 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
1-
/*
2-
Copyright 2015 Pim de Witte All Rights Reserved.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
16-
17-
using System;
1+
using System;
182
using System.Collections.Generic;
193
using System.Collections;
204
using UnityEngine;
5+
using UnityEngine.LowLevel;
216

22-
/// Author: Pim de Witte (pimdewitte.com) and contributors
23-
/// <summary>
24-
/// 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
25-
/// 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
26-
/// </summary>
277
namespace BugsnagUnity
288
{
29-
public class MainThreadDispatchBehaviour : MonoBehaviour
9+
public class BugsnagCoroutineRunner : MonoBehaviour
3010
{
11+
private static BugsnagCoroutineRunner _instance;
3112

32-
private static MainThreadDispatchBehaviour _instance;
33-
34-
private static readonly Queue<Action> _executionQueue = new Queue<Action>();
13+
public static BugsnagCoroutineRunner Instance
14+
{
15+
get
16+
{
17+
if (_instance == null)
18+
{
19+
var runnerObject = new GameObject("BugsnagCoroutineRunner");
20+
_instance = runnerObject.AddComponent<BugsnagCoroutineRunner>();
21+
DontDestroyOnLoad(runnerObject);
22+
}
23+
return _instance;
24+
}
25+
}
26+
}
27+
public class MainThreadDispatchBehaviour
28+
{
3529

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

37-
public static MainThreadDispatchBehaviour Instance()
32+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
33+
private static void InitializeLoop()
3834
{
39-
if (_instance == null)
35+
var playerLoop = PlayerLoop.GetCurrentPlayerLoop();
36+
var newSystem = new PlayerLoopSystem
4037
{
41-
_instance = new GameObject("Bugsnag main thread dispatcher").AddComponent<MainThreadDispatchBehaviour>();
42-
}
43-
return _instance;
38+
updateDelegate = OnUpdate
39+
};
40+
41+
var systems = new List<PlayerLoopSystem>(playerLoop.subSystemList);
42+
systems.Insert(0, newSystem);
43+
playerLoop.subSystemList = systems.ToArray();
44+
PlayerLoop.SetPlayerLoop(playerLoop);
4445
}
4546

46-
public void Update()
47+
private static void OnUpdate()
4748
{
4849
lock (_executionQueue)
4950
{
@@ -54,50 +55,23 @@ public void Update()
5455
}
5556
}
5657

57-
/// <summary>
58-
/// Locks the queue and adds the IEnumerator to the queue
59-
/// </summary>
60-
/// <param name="action">IEnumerator function that will be executed from the main thread.</param>
61-
public void Enqueue(IEnumerator action)
58+
public static void Enqueue(IEnumerator action)
6259
{
6360
lock (_executionQueue)
6461
{
6562
_executionQueue.Enqueue(() =>
6663
{
67-
StartCoroutine(action);
64+
BugsnagCoroutineRunner.Instance.StartCoroutine(action);
6865
});
6966
}
7067
}
7168

72-
/// <summary>
73-
/// Locks the queue and adds the Action to the queue
74-
/// </summary>
75-
/// <param name="action">function that will be executed from the main thread.</param>
76-
public void Enqueue(Action action)
69+
public static void Enqueue(Action action)
7770
{
78-
Enqueue(ActionWrapper(action));
79-
}
80-
IEnumerator ActionWrapper(Action a)
81-
{
82-
a();
83-
yield return null;
84-
}
85-
86-
public void EnqueueWithDelayCoroutine(Action action, float delay)
87-
{
88-
StartCoroutine(DelayAction(action, delay));
89-
}
90-
91-
private IEnumerator DelayAction(Action action, float delay)
92-
{
93-
yield return new WaitForSeconds(delay);
94-
action.Invoke();
95-
}
96-
97-
private void Awake()
98-
{
99-
DontDestroyOnLoad(gameObject);
71+
lock (_executionQueue)
72+
{
73+
_executionQueue.Enqueue(action);
74+
}
10075
}
101-
10276
}
10377
}

Bugsnag/Assets/Bugsnag/Runtime/Native/Android/NativeClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ public void RegisterForOnSessionCallbacks()
164164
NativeInterface.RegisterForOnSessionCallbacks();
165165
}
166166

167-
public LoadedImage FindImageAtAddress(UInt64 address)
167+
public StackTraceLine[] ToStackFrames(System.Exception exception)
168168
{
169-
return null;
169+
return new StackTraceLine[0];
170170
}
171171
}
172172

0 commit comments

Comments
 (0)