Skip to content

Commit

Permalink
Android and iOS CI flake fixes (#868)
Browse files Browse the repository at this point in the history
* some CI fixes [full ci]

* missing env var [full ci]

* simpler check [full ci]

* skip flakey tests until later [full ci]

* typo [full ci]

* disable native frames until we fix unity 6 [full ci]
  • Loading branch information
richardelms authored Jan 9, 2025
1 parent 03961c5 commit 71350dd
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 75 deletions.
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
123 changes: 62 additions & 61 deletions Bugsnag/Assets/Bugsnag/Runtime/Native/Cocoa/NativeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,68 +540,69 @@ private StackTraceLine[] ToStackFrames(System.Exception exception, IntPtr[] nati
public StackTraceLine[] ToStackFrames(System.Exception exception)
{
var notFound = new StackTraceLine[0];

if (exception == null)
{
return notFound;
}

#if ENABLE_IL2CPP && UNITY_2021_3_OR_NEWER
var hException = GCHandle.Alloc(exception);
var pNativeAddresses = IntPtr.Zero;
var pImageUuid = IntPtr.Zero;
var pImageName = IntPtr.Zero;
try
{
if (hException == null)
{
return notFound;
}

var pException = il2cpp_gchandle_get_target(GCHandle.ToIntPtr(hException).ToInt32());
if (pException == IntPtr.Zero)
{
return notFound;
}

var frameCount = 0;
string? mainImageFileName = null;

il2cpp_native_stack_trace(pException, out pNativeAddresses, out frameCount, out pImageUuid, out pImageName);
if (pNativeAddresses == IntPtr.Zero)
{
return notFound;
}

mainImageFileName = ExtractString(pImageName);
var nativeAddresses = new IntPtr[frameCount];
Marshal.Copy(pNativeAddresses, nativeAddresses, 0, frameCount);

loadedImages.Refresh(mainImageFileName);
return ToStackFrames(exception, nativeAddresses);
}
finally
{
if (pImageUuid != IntPtr.Zero)
{
il2cpp_free(pImageUuid);
}
if (pImageName != IntPtr.Zero)
{
il2cpp_free(pImageName);
}
if (pNativeAddresses != IntPtr.Zero)
{
il2cpp_free(pNativeAddresses);
}
if (hException != null)
{
hException.Free();
}
}
#else
return notFound;
#endif
// Disabled until we can get this working with IL2CPP and Unity 6. raised in PLAT-13394
// if (exception == null)
// {
// return notFound;
// }

// #if ENABLE_IL2CPP && UNITY_2021_3_OR_NEWER
// var hException = GCHandle.Alloc(exception);
// var pNativeAddresses = IntPtr.Zero;
// var pImageUuid = IntPtr.Zero;
// var pImageName = IntPtr.Zero;
// try
// {
// if (hException == null)
// {
// return notFound;
// }

// var pException = il2cpp_gchandle_get_target(GCHandle.ToIntPtr(hException).ToInt32());
// if (pException == IntPtr.Zero)
// {
// return notFound;
// }

// var frameCount = 0;
// string? mainImageFileName = null;

// il2cpp_native_stack_trace(pException, out pNativeAddresses, out frameCount, out pImageUuid, out pImageName);
// if (pNativeAddresses == IntPtr.Zero)
// {
// return notFound;
// }

// mainImageFileName = ExtractString(pImageName);
// var nativeAddresses = new IntPtr[frameCount];
// Marshal.Copy(pNativeAddresses, nativeAddresses, 0, frameCount);

// loadedImages.Refresh(mainImageFileName);
// return ToStackFrames(exception, nativeAddresses);
// }
// finally
// {
// if (pImageUuid != IntPtr.Zero)
// {
// il2cpp_free(pImageUuid);
// }
// if (pImageName != IntPtr.Zero)
// {
// il2cpp_free(pImageName);
// }
// if (pNativeAddresses != IntPtr.Zero)
// {
// il2cpp_free(pNativeAddresses);
// }
// if (hException != null)
// {
// hException.Free();
// }
// }
// #else
// return notFound;
// #endif
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions features/android/android_jvm_errors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ Feature: Android JVM Exceptions
# Stacktrace validation
And the error payload field "events.0.exceptions.0.stacktrace" is a non-empty array
And the event "exceptions.0.stacktrace.0.method" equals "com.example.bugsnagcrashplugin.CrashHelper.triggerJvmException()"
And the exception "stacktrace.0.file" equals "CrashHelper.java"
And the event "exceptions.0.stacktrace.0.lineNumber" equals 20
And the exception "stacktrace.0.file" equals one of:
| CrashHelper.java |
| SourceFile |
And the error payload field "events.0.exceptions.0.stacktrace.0.lineNumber" is a number
And the error payload field "events.0.threads" is null

Scenario: Android JVM Background Thread Smoke Test
Expand Down Expand Up @@ -61,8 +63,10 @@ Feature: Android JVM Exceptions

# Stacktrace validation
And the error payload field "events.0.exceptions.0.stacktrace" is a non-empty array
And the exception "stacktrace.0.file" equals "CrashHelper.java"
And the event "exceptions.0.stacktrace.0.lineNumber" equals 5
And the exception "stacktrace.0.file" equals one of:
| CrashHelper.java |
| SourceFile |
And the error payload field "events.0.exceptions.0.stacktrace.0.lineNumber" is a number
And the error payload field "events.0.threads" is not null

And the error payload field "events.0.usage.config" is not null
Expand Down
15 changes: 8 additions & 7 deletions features/csharp/csharp_events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Feature: csharp events
And expected app metadata is included in the event

@ios_only
@skip_before_unity_2021
Scenario: Uncaught Exception ios smoke test
@skip_unity_2020
Scenario: Uncaught Exception ios smoke test with more frame information
When I run the game in the "UncaughtExceptionSmokeTest" state
And I wait to receive an error
Then the error is valid for the error reporting API sent by the Unity notifier
Expand All @@ -44,12 +44,13 @@ Feature: csharp events
And custom metadata is included in the event
And expected device metadata is included in the event
And expected app metadata is included in the event
And the error payload field "events.0.exceptions.0.stacktrace.0.frameAddress" matches the regex "\d+"
# some skipped steps pending: PLAT-13392
#And the error payload field "events.0.exceptions.0.stacktrace.0.frameAddress" matches the regex "\d+"
And the error payload field "events.0.exceptions.0.stacktrace.0.method" equals "UncaughtExceptionSmokeTest.Run()"
And the error payload field "events.0.exceptions.0.stacktrace.0.machoFile" matches the regex ".*/UnityFramework.framework/UnityFramework"
And the error payload field "events.0.exceptions.0.stacktrace.0.machoLoadAddress" matches the regex "\d+"
And the error payload field "events.0.exceptions.0.stacktrace.0.machoUUID" matches the regex "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
And the error payload field "events.0.exceptions.0.stacktrace.0.inProject" is true
#And the error payload field "events.0.exceptions.0.stacktrace.0.machoFile" matches the regex ".*/UnityFramework.framework/UnityFramework"
#And the error payload field "events.0.exceptions.0.stacktrace.0.machoLoadAddress" matches the regex "\d+"
#And the error payload field "events.0.exceptions.0.stacktrace.0.machoUUID" matches the regex "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
#And the error payload field "events.0.exceptions.0.stacktrace.0.inProject" is true

Scenario: Debug Log Exception smoke test
When I run the game in the "DebugLogExceptionSmokeTest" state
Expand Down
5 changes: 5 additions & 0 deletions features/steps/unity_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,8 @@ def switch_run_on_target
# Check if the integer event value is one of the expected values
Maze.check.true(expected_values.include?(event_value), "Expected one of #{expected_values} but got #{event_value}")
end

Then("the exception {string} equals one of:") do |keypath, possible_values|
value = Maze::Helper.read_key_path(Maze::Server.errors.current[:body], "events.0.exceptions.0.#{keypath}")
Maze.check.include(possible_values.raw.flatten, value)
end
6 changes: 3 additions & 3 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
end
end

Before('@skip_before_unity_2021') do |_scenario|
Before('@skip_unity_2020') do |_scenario|
if ENV['UNITY_VERSION']
unity_version = ENV['UNITY_VERSION'][0..3].to_i
if unity_version < 2021
skip_this_scenario('Skipping scenario on Unity < 2021')
if unity_version == 2020
skip_this_scenario('Skipping scenario on Unity 2020')
end
end
end
Expand Down

0 comments on commit 71350dd

Please sign in to comment.