Skip to content

Commit

Permalink
Disable native trace capture on older Unity
Browse files Browse the repository at this point in the history
  • Loading branch information
kstenerud committed Dec 6, 2024
1 parent 569a3da commit ffdd333
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Bugsnag/Assets/Bugsnag/Runtime/Native/Cocoa/NativeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,6 @@ public void RegisterForOnSessionCallbacks()
NativeCode.bugsnag_registerForSessionCallbacksAfterStart(HandleSessionCallbacks);
}

[DllImport("__Internal")]
private static extern IntPtr il2cpp_gchandle_get_target(int gchandle);

[DllImport("__Internal")]
private static extern void il2cpp_free(IntPtr ptr);

[DllImport("__Internal")]
private static extern void il2cpp_native_stack_trace(IntPtr exc, out IntPtr addresses, out int numFrames, out IntPtr imageUUID, out IntPtr imageName);

#nullable enable
private static string? ExtractString(IntPtr pString)
{
Expand Down Expand Up @@ -535,6 +526,17 @@ private StackTraceLine[] ToStackFrames(System.Exception exception, IntPtr[] nati
return stackFrames;
}

#if ENABLE_IL2CPP && UNITY_2021_3_OR_NEWER
[DllImport("__Internal")]
private static extern IntPtr il2cpp_gchandle_get_target(int gchandle);

[DllImport("__Internal")]
private static extern void il2cpp_free(IntPtr ptr);

[DllImport("__Internal")]
private static extern void il2cpp_native_stack_trace(IntPtr exc, out IntPtr addresses, out int numFrames, out IntPtr imageUUID, out IntPtr imageName);
#endif

public StackTraceLine[] ToStackFrames(System.Exception exception)
{
var notFound = new StackTraceLine[0];
Expand All @@ -544,7 +546,7 @@ public StackTraceLine[] ToStackFrames(System.Exception exception)
return notFound;
}

#if ENABLE_IL2CPP
#if ENABLE_IL2CPP && UNITY_2021_3_OR_NEWER
var hException = GCHandle.Alloc(exception);
var pNativeAddresses = IntPtr.Zero;
var pImageUuid = IntPtr.Zero;
Expand Down Expand Up @@ -603,4 +605,5 @@ public StackTraceLine[] ToStackFrames(System.Exception exception)
}
}
}

#endif
1 change: 1 addition & 0 deletions features/csharp/csharp_events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Feature: csharp events
And expected app metadata is included in the event

@ios_only
@skip_before_unity_2021
Scenario: Uncaught Exception ios smoke test
When I run the game in the "UncaughtExceptionSmokeTest" state
And I wait to receive an error
Expand Down
9 changes: 9 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
end
end

Before('@skip_before_unity_2021') 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')
end
end
end


Before('@skip_webgl') do |_scenario|
skip_this_scenario('Skipping scenario') unless Maze.config.browser.nil?
Expand Down

0 comments on commit ffdd333

Please sign in to comment.