From 8336e2d7f2ebb6c64238e61f7cb9b057bfd5b34e Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 9 Feb 2023 10:34:08 +0000 Subject: [PATCH 1/6] dep: bump bugsnag-android to v5.28.4 --- CHANGELOG.md | 1 + bugsnag-android | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e5772ce1..c030e5a61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Dependency updates - Update bugsnag-cocoa from v6.25.1 to [v6.25.2](https://github.com/bugsnag/bugsnag-cocoa/blob/master/CHANGELOG.md#6252-2023-01-18) +* Update bugsnag-android from v5.28.3 to [v5.28.4](https://github.com/bugsnag/bugsnag-android/blob/master/CHANGELOG.md#5284-2023-02-08) ### Bug fixes diff --git a/bugsnag-android b/bugsnag-android index 824fc4f71..77eb8fc51 160000 --- a/bugsnag-android +++ b/bugsnag-android @@ -1 +1 @@ -Subproject commit 824fc4f71e5b70e6d491c75d66dfd57774846826 +Subproject commit 77eb8fc5108eaa8027d39817c1edb1078925ac60 From 96ac9313addab0d664e0399c67989ea3902cd144 Mon Sep 17 00:00:00 2001 From: Richard Elms Date: Tue, 14 Feb 2023 21:22:44 +0100 Subject: [PATCH 2/6] PLAT-9660 upm release script changes (#698) --- CONTRIBUTING.md | 2 +- upm-tools/build-edm-package.sh | 3 ++- upm-tools/build-upm-package.sh | 13 +++---------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a35b240fa..56e5a1b42 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -133,7 +133,7 @@ bundle exec maze-runner features/handled_errors.feature Once the UnityPackage release is confirmed a UPM release should be deployed -1. Checkout the release commit on `master` +1. Make sure that the package used in the github release is present in the root of the repo. 2. Build the upm package by running the `build-upm-package.sh` script in the upm-tools directory. You should pass the version number of the release like so `./build-upm-package.sh 7.x.x`. You must run the script from within the upm-tools folder. This will build the upm package in a directory called `upm-package` diff --git a/upm-tools/build-edm-package.sh b/upm-tools/build-edm-package.sh index e67aec5f3..977330a73 100755 --- a/upm-tools/build-edm-package.sh +++ b/upm-tools/build-edm-package.sh @@ -14,4 +14,5 @@ cp EDM/BugsnagAndroidDependencies.xml "$PACKAGE_DIR/Editor" cp EDM/BugsnagAndroidDependencies.xml.meta "$PACKAGE_DIR/Editor" # Change the readme title to reference EDM4U -sed -i '' "s/Bugsnag SDK for Unity/Bugsnag SDK for Unity Including EDM4U Support/g" "$PACKAGE_DIR/README.md" \ No newline at end of file +sed -i '' "s/Bugsnag SDK for Unity/Bugsnag SDK for Unity Including EDM4U Support/g" "$PACKAGE_DIR/README.md" +sed -i '' "s/bugsnag-unity-upm.git/bugsnag-unity-upm-edm4u.git/g" "$PACKAGE_DIR/README.md" \ No newline at end of file diff --git a/upm-tools/build-upm-package.sh b/upm-tools/build-upm-package.sh index 97e02ad3b..88e0735fc 100755 --- a/upm-tools/build-upm-package.sh +++ b/upm-tools/build-upm-package.sh @@ -23,19 +23,12 @@ then exit 1 fi -#Build the plugin -echo "Building the sdk" - -cd .. - -rake plugin:export - -cd upm-tools - +#Check for the release package +echo "Checking for the release package" # make sure the package of the release is present after building if [ ! -f "$PACKAGE_FILE" ]; then - echo "$PACKAGE_FILE not found, please check for build errors." + echo "$PACKAGE_FILE not found, please provide a release package." exit 1 fi From 206ea8c6e600519d03e0317f4cb962219423bb1b Mon Sep 17 00:00:00 2001 From: Richard Elms Date: Fri, 17 Feb 2023 10:36:03 +0100 Subject: [PATCH 3/6] PLAT-9670 make Start main thread safe (#699) --- CHANGELOG.md | 6 ++++++ src/BugsnagUnity/Client.cs | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e5772ce1..60cab9e2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## TBD + +### Bug fixes + +* Fix a race condition in Bugsnag.Start involving creation of gameobjects outside of the main Unity thread. [#699](https://github.com/bugsnag/bugsnag-unity/pull/699) + ## 7.5.1 (2023-02-08) ### Dependency updates diff --git a/src/BugsnagUnity/Client.cs b/src/BugsnagUnity/Client.cs index e58b4453a..9246d50e0 100644 --- a/src/BugsnagUnity/Client.cs +++ b/src/BugsnagUnity/Client.cs @@ -108,6 +108,7 @@ private void SetupAdvancedExceptionInterceptor() public Client(INativeClient nativeClient) { + InitMainthreadDispatcher(); NativeClient = nativeClient; CacheManager = new CacheManager(Configuration); PayloadManager = new PayloadManager(CacheManager); @@ -120,8 +121,6 @@ public Client(INativeClient nativeClient) InitMetadata(); InitFeatureFlags(); InitCounters(); - ListenForSceneLoad(); - InitLogHandlers(); if (_isUnity2019OrHigher) { SetupAdvancedExceptionInterceptor(); @@ -131,6 +130,13 @@ public Client(INativeClient nativeClient) CheckForMisconfiguredEndpointsWarning(); AddBugsnagLoadedBreadcrumb(); _delivery.StartDeliveringCachedPayloads(); + ListenForSceneLoad(); + InitLogHandlers(); + } + + private void InitMainthreadDispatcher() + { + MainThreadDispatchBehaviour.Instance(); } private bool IsUnity2019OrHigher() From 904f151c10f94521d46ee42bb94868a0e3111839 Mon Sep 17 00:00:00 2001 From: Richard Elms Date: Tue, 7 Mar 2023 14:36:31 +0100 Subject: [PATCH 4/6] PLAT-9092 missing stacktraces in android notify events (#700) --- CHANGELOG.md | 2 + features/csharp/csharp_callbacks.feature | 1 - features/csharp/csharp_events.feature | 4 +- src/BugsnagUnity/Bugsnag.cs | 16 ++---- src/BugsnagUnity/Client.cs | 59 ++++------------------- src/BugsnagUnity/IClient.cs | 4 -- tests/BugsnagUnity.Tests/OverloadCheck.cs | 33 +++++++++++++ 7 files changed, 50 insertions(+), 69 deletions(-) create mode 100644 tests/BugsnagUnity.Tests/OverloadCheck.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 5953cf6df..6fb5a8fa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * Fix a race condition in Bugsnag.Start involving creation of gameobjects outside of the main Unity thread. [#699](https://github.com/bugsnag/bugsnag-unity/pull/699) +* Fix an issue causing empty stacktraces in some Android events. [#700](https://github.com/bugsnag/bugsnag-unity/pull/700) + ## 7.5.1 (2023-02-08) ### Dependency updates diff --git a/features/csharp/csharp_callbacks.feature b/features/csharp/csharp_callbacks.feature index 644862a75..f584d19c9 100644 --- a/features/csharp/csharp_callbacks.feature +++ b/features/csharp/csharp_callbacks.feature @@ -45,7 +45,6 @@ Feature: Callbacks And the exception "message" equals "Error 2" And all possible parameters have been edited in a callback - @skip_android #pending PLAT-9092 Scenario: Callback passed directly to Notify When I run the game in the "CallbackInNotify" state And I wait to receive 1 error diff --git a/features/csharp/csharp_events.feature b/features/csharp/csharp_events.feature index 98489631e..7e2b1d033 100644 --- a/features/csharp/csharp_events.feature +++ b/features/csharp/csharp_events.feature @@ -3,7 +3,6 @@ Feature: csharp events Background: Given I clear the Bugsnag cache - @skip_android #pending PLAT-9092 Scenario: Notify smoke test When I run the game in the "NotifySmokeTest" state And I wait to receive an error @@ -13,8 +12,7 @@ Feature: csharp events And the event "unhandled" is false And custom metadata is included in the event And the stack frame methods should match: - | NotifySmokeTest.Run() | - | ScenarioRunner.RunScenario(string scenarioName, string apiKey, string host) | + | NotifySmokeTest.Run() | Main+d__5.MoveNext() | And expected device metadata is included in the event And expected app metadata is included in the event diff --git a/src/BugsnagUnity/Bugsnag.cs b/src/BugsnagUnity/Bugsnag.cs index 215eece35..4cb91d096 100644 --- a/src/BugsnagUnity/Bugsnag.cs +++ b/src/BugsnagUnity/Bugsnag.cs @@ -38,21 +38,13 @@ public static void Start(Configuration configuration) private static IClient Client => InternalClient; - public static void Notify(string name, string message, string stackTrace) => InternalClient.Notify(name, message, stackTrace, null); + public static void Notify(string name, string message, string stackTrace, Func callback = null) => InternalClient.Notify(name, message, stackTrace, callback); - public static void Notify(string name, string message, string stackTrace, Func callback) => InternalClient.Notify(name, message, stackTrace, callback); + public static void Notify(System.Exception exception, string stacktrace, Func callback = null) => InternalClient.Notify(exception, stacktrace, callback); - public static void Notify(System.Exception exception) => InternalClient.Notify(exception, 3); + public static void Notify(System.Exception exception, Func callback = null) => InternalClient.Notify(exception, callback); - public static void Notify(System.Exception exception, string stacktrace) => InternalClient.Notify(exception, stacktrace, null); - - public static void Notify(System.Exception exception, string stacktrace, Func callback) => InternalClient.Notify(exception, stacktrace, callback); - - public static void Notify(System.Exception exception, Func callback) => InternalClient.Notify(exception, callback, 3); - - public static void Notify(System.Exception exception, Severity severity) => InternalClient.Notify(exception, severity, 3); - - public static void Notify(System.Exception exception, Severity severity, Func callback) => InternalClient.Notify(exception, severity, callback, 3); + public static void Notify(System.Exception exception, Severity severity, Func callback = null) => InternalClient.Notify(exception, severity, callback); public static List Breadcrumbs => Client.Breadcrumbs.Retrieve(); diff --git a/src/BugsnagUnity/Client.cs b/src/BugsnagUnity/Client.cs index 9246d50e0..a3aa67974 100644 --- a/src/BugsnagUnity/Client.cs +++ b/src/BugsnagUnity/Client.cs @@ -3,7 +3,6 @@ using System.Collections.Specialized; using System.Diagnostics; using System.Linq; -using System.ComponentModel; using System.Threading; using UnityEngine; using UnityEngine.SceneManagement; @@ -82,7 +81,7 @@ public void LogException(System.Exception exception, UnityEngine.Object context) if (shouldSend) { var handledState = _config.ReportExceptionLogsAsHandled ? HandledState.ForLoggedException() : HandledState.ForUnhandledException(); - _client.Notify(exception, handledState, null, 3); + _client.Notify(exception, handledState, null); } } if (_oldLogHandler != null) @@ -180,7 +179,7 @@ private void InitTimingTracker() private void InitLogHandlers() { Application.logMessageReceivedThreaded += MultiThreadedNotify; - Application.logMessageReceived += Notify; + Application.logMessageReceived += NotifyFromUnityLog; } private void InitCounters() @@ -277,19 +276,11 @@ void MultiThreadedNotify(string condition, string stackTrace, LogType logType) // Discard messages from the main thread as they will be reported separately if (!ReferenceEquals(Thread.CurrentThread, MainThread)) { - Notify(condition, stackTrace, logType); + NotifyFromUnityLog(condition, stackTrace, logType); } } - /// - /// Notify a Unity log message if it the client has been configured to - /// notify at the specified level, if not leave a breadcrumb with the log - /// message. - /// - /// - /// - /// - void Notify(string condition, string stackTrace, LogType logType) + private void NotifyFromUnityLog(string condition, string stackTrace, LogType logType) { if (!Configuration.EnabledErrorTypes.UnityLog) { @@ -336,52 +327,22 @@ public void Notify(System.Exception exception, string stacktrace, Func callback) { - Notify(exception, callback, 3); - } - - internal void Notify(System.Exception exception, Func callback, int level) - { - Notify(exception, HandledState.ForHandledException(), callback, level); - } - - public void Notify(System.Exception exception, Severity severity) - { - Notify(exception, severity, 3); - } - - internal void Notify(System.Exception exception, Severity severity, int level) - { - Notify(exception, HandledState.ForUserSpecifiedSeverity(severity), null, level); + Notify(exception, HandledState.ForHandledException(), callback); } public void Notify(System.Exception exception, Severity severity, Func callback) { - Notify(exception, severity, callback, 3); + Notify(exception, HandledState.ForUserSpecifiedSeverity(severity), callback); } - internal void Notify(System.Exception exception, Severity severity, Func callback, int level) - { - Notify(exception, HandledState.ForUserSpecifiedSeverity(severity), callback, level); - } - - void Notify(System.Exception exception, HandledState handledState, Func callback, int level) + void Notify(System.Exception exception, HandledState handledState, Func callback) { // we need to generate a substitute stacktrace here as if we are not able // to generate one from the exception that we are given then we are not able // to do this inside of the IEnumerator generator code - var substitute = new System.Diagnostics.StackTrace(level, true).GetFrames(); + var substitute = new System.Diagnostics.StackTrace(true).GetFrames(); var errors = new Errors(exception, substitute).ToArray(); foreach (var error in errors) { @@ -393,7 +354,7 @@ void Notify(System.Exception exception, HandledState handledState, Func callback, LogType? logType) + private void Notify(Error[] exceptions, HandledState handledState, Func callback, LogType? logType) { if (!ShouldSendRequests() || EventContainsDiscardedClass(exceptions) || !Configuration.Endpoints.IsValid) { @@ -401,7 +362,7 @@ void Notify(Error[] exceptions, HandledState handledState, Func ca } - if (!object.ReferenceEquals(Thread.CurrentThread, MainThread)) + if (!ReferenceEquals(Thread.CurrentThread, MainThread)) { try { diff --git a/src/BugsnagUnity/IClient.cs b/src/BugsnagUnity/IClient.cs index c213fb81e..1c8522c5d 100644 --- a/src/BugsnagUnity/IClient.cs +++ b/src/BugsnagUnity/IClient.cs @@ -17,12 +17,8 @@ internal interface IClient : IMetadataEditor, IFeatureFlagStore void Send(IPayload payload); - void Notify(System.Exception exception); - void Notify(System.Exception exception, Func callback); - void Notify(System.Exception exception, Severity severity); - void Notify(System.Exception exception, Severity severity, Func callback); void Notify(System.Exception exception, string stacktrace, Func callback); diff --git a/tests/BugsnagUnity.Tests/OverloadCheck.cs b/tests/BugsnagUnity.Tests/OverloadCheck.cs new file mode 100644 index 000000000..79ac13c25 --- /dev/null +++ b/tests/BugsnagUnity.Tests/OverloadCheck.cs @@ -0,0 +1,33 @@ +using System; +namespace BugsnagUnity.Tests +{ + public class OverloadCheck + { + + // this method never runs and is just used to check that no notify overides are accidentally broken during refactoring + // if one is broken then the notifier will not compile + private void Check() + { + Bugsnag.Notify("name", "message", "stacktrace"); + + Bugsnag.Notify("name", "message", "stacktrace", CallBack); + + Bugsnag.Notify(new Exception()); + + Bugsnag.Notify(new Exception(), "stacktrace"); + + Bugsnag.Notify(new Exception(), "stacktrace", CallBack); + + Bugsnag.Notify(new Exception(), CallBack); + + Bugsnag.Notify(new Exception(), Severity.Error); + + Bugsnag.Notify(new Exception(), Severity.Error, CallBack); + } + + private bool CallBack(IEvent e) + { + return true; + } + } +} From e9fa08e711dfa5ea84c364e280890bb377df5267 Mon Sep 17 00:00:00 2001 From: Richard Elms Date: Wed, 8 Mar 2023 10:07:40 +0100 Subject: [PATCH 5/6] Release v7.5.2 --- CHANGELOG.md | 2 +- build.cake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fb5a8fa9..d69721e9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## TBD +## 7.5.2 (2023-03-08) ### Bug fixes diff --git a/build.cake b/build.cake index da3b1d5fe..c72ebc055 100644 --- a/build.cake +++ b/build.cake @@ -5,7 +5,7 @@ var target = Argument("target", "Default"); var solution = File("./BugsnagUnity.sln"); var configuration = Argument("configuration", "Release"); var project = File("./src/BugsnagUnity/BugsnagUnity.csproj"); -var version = "7.5.1"; +var version = "7.5.2"; Task("Restore-NuGet-Packages") .Does(() => NuGetRestore(solution)); From 724bbe00598b932457e5d3e9baaa6c2c75b12c51 Mon Sep 17 00:00:00 2001 From: Richard Elms Date: Wed, 8 Mar 2023 10:12:47 +0100 Subject: [PATCH 6/6] Changelog fix --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d69721e9d..32378df16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,15 @@ * Fix an issue causing empty stacktraces in some Android events. [#700](https://github.com/bugsnag/bugsnag-unity/pull/700) +### Dependency updates + +* Update bugsnag-android from v5.28.3 to [v5.28.4](https://github.com/bugsnag/bugsnag-android/blob/master/CHANGELOG.md#5284-2023-02-08) + ## 7.5.1 (2023-02-08) ### Dependency updates - Update bugsnag-cocoa from v6.25.1 to [v6.25.2](https://github.com/bugsnag/bugsnag-cocoa/blob/master/CHANGELOG.md#6252-2023-01-18) -* Update bugsnag-android from v5.28.3 to [v5.28.4](https://github.com/bugsnag/bugsnag-android/blob/master/CHANGELOG.md#5284-2023-02-08) ### Bug fixes