Skip to content

Commit 5dabc30

Browse files
committed
Merge branch 'fix/native-bridge-alloc' of https://github.com/getsentry/sentry-unity into fix/native-bridge-alloc
2 parents 8d5269a + 6c74a89 commit 5dabc30

File tree

12 files changed

+95
-28
lines changed

12 files changed

+95
-28
lines changed

CHANGELOG.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,26 @@
1010

1111
- Fixed crashes when adding breadcrumbs on iOS/macOS. This was caused by invalid date parsing and corrupted string data in the native bridge responsible for scope sync ([#2327](https://github.com/getsentry/sentry-unity/pull/2327))
1212
- Fixed input handling in samples to work with old and new input system ([#2319](https://github.com/getsentry/sentry-unity/pull/2319))
13+
- The SDK now captures exceptions on WebGL through the logging integration instead of the incompatible log handler, providing better stack trace support . ([#2322](https://github.com/getsentry/sentry-unity/pull/2322))
14+
- Fixed input handling in samples to work with old and new input system. ([#2319](https://github.com/getsentry/sentry-unity/pull/2319))
1315

1416
### Dependencies
1517

16-
- Bump Cocoa SDK from v8.55.1 to v8.56.0 ([#2318](https://github.com/getsentry/sentry-unity/pull/2318))
17-
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8560)
18-
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.55.1...8.56.0)
19-
- Bump Native SDK from v0.10.1 to v0.11.0 ([#2323](https://github.com/getsentry/sentry-unity/pull/2323))
20-
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0110)
21-
- [diff](https://github.com/getsentry/sentry-native/compare/0.10.1...0.11.0)
22-
- Bump CLI from v2.53.0 to v2.54.0 ([#2324](https://github.com/getsentry/sentry-unity/pull/2324))
23-
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2540)
24-
- [diff](https://github.com/getsentry/sentry-cli/compare/2.53.0...2.54.0)
18+
- Bump Cocoa SDK from v8.55.1 to v8.56.1 ([#2318](https://github.com/getsentry/sentry-unity/pull/2318), [#2331](https://github.com/getsentry/sentry-unity/pull/2331))
19+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8561)
20+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.55.1...8.56.1)
21+
- Bump Native SDK from v0.10.1 to v0.11.1 ([#2323](https://github.com/getsentry/sentry-unity/pull/2323), [#2332](https://github.com/getsentry/sentry-unity/pull/2332))
22+
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0111)
23+
- [diff](https://github.com/getsentry/sentry-native/compare/0.10.1...0.11.1)
24+
- Bump CLI from v2.53.0 to v2.55.0 ([#2324](https://github.com/getsentry/sentry-unity/pull/2324), [#2330](https://github.com/getsentry/sentry-unity/pull/2330))
25+
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2550)
26+
- [diff](https://github.com/getsentry/sentry-cli/compare/2.53.0...2.55.0)
2527
- Bump .NET SDK from v5.15.0 to v5.15.1 ([#2326](https://github.com/getsentry/sentry-unity/pull/2326))
2628
- [changelog](https://github.com/getsentry/sentry-dotnet/blob/main/CHANGELOG.md#5151)
2729
- [diff](https://github.com/getsentry/sentry-dotnet/compare/5.15.0...5.15.1)
30+
- Bump Java SDK from v8.21.1 to v8.22.0 ([#2328](https://github.com/getsentry/sentry-unity/pull/2328))
31+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8220)
32+
- [diff](https://github.com/getsentry/sentry-java/compare/8.21.1...8.22.0)
2833

2934
## 4.0.0-beta.2
3035

modules/sentry-cli.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = 2.54.0
1+
version = 2.55.0
22
repo = https://github.com/getsentry/sentry-cli

modules/sentry-cocoa.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = 8.56.0
1+
version = 8.56.1
22
repo = https://github.com/getsentry/sentry-cocoa

modules/sentry-java

Submodule sentry-java updated 127 files

src/Sentry.Unity.Editor/WebGL/BuildPreProcess.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,21 @@ public void OnPreprocessBuild(BuildReport report)
1818
return;
1919
}
2020

21+
var (options, _) = SentryScriptableObject.ConfiguredBuildTimeOptions();
22+
if (options?.Enabled is not true)
23+
{
24+
return;
25+
}
26+
2127
if (PlayerSettings.WebGL.exceptionSupport == WebGLExceptionSupport.None)
2228
{
2329
throw new BuildFailedException("WebGL exception support is set to None. The Sentry SDK requires exception " +
2430
"support to function properly. Please change the WebGL exception support setting in Player Settings " +
2531
"or disable the Sentry SDK.");
2632
}
27-
else if (PlayerSettings.WebGL.exceptionSupport != WebGLExceptionSupport.FullWithStacktrace)
33+
34+
if (PlayerSettings.WebGL.exceptionSupport != WebGLExceptionSupport.FullWithStacktrace)
2835
{
29-
var (options, _) = SentryScriptableObject.ConfiguredBuildTimeOptions();
3036
var logger = options?.DiagnosticLogger ?? new UnityLogger(options ?? new SentryUnityOptions());
3137

3238
logger.LogWarning("The SDK requires the Exception Support to be set " +

src/Sentry.Unity/Integrations/UnityApplicationLoggingIntegration.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
using Sentry.Extensibility;
12
using Sentry.Integrations;
3+
using Sentry.Protocol;
24
using UnityEngine;
35

46
namespace Sentry.Unity.Integrations;
57

68
internal class UnityApplicationLoggingIntegration : ISdkIntegration
79
{
810
private readonly IApplication _application;
11+
private readonly bool _captureExceptions;
912
private ErrorTimeDebounce? _errorTimeDebounce;
1013
private LogTimeDebounce? _logTimeDebounce;
1114
private WarningTimeDebounce? _warningTimeDebounce;
1215

1316
private IHub? _hub;
1417
private SentryUnityOptions? _options;
1518

16-
internal UnityApplicationLoggingIntegration(IApplication? application = null)
19+
internal UnityApplicationLoggingIntegration(bool captureExceptions = false, IApplication? application = null)
1720
{
21+
_captureExceptions = captureExceptions;
1822
_application = application ?? ApplicationAdapter.Instance;
1923
}
2024

@@ -49,7 +53,8 @@ internal void OnLogMessageReceived(string message, string stacktrace, LogType lo
4953
}
5054

5155
// LogType.Exception are getting handled by the UnityLogHandlerIntegration
52-
if (logType is LogType.Exception)
56+
// Unless we're configured to handle them - i.e. WebGL
57+
if (logType is LogType.Exception && !_captureExceptions)
5358
{
5459
return;
5560
}
@@ -58,6 +63,7 @@ internal void OnLogMessageReceived(string message, string stacktrace, LogType lo
5863
{
5964
var debounced = logType switch
6065
{
66+
LogType.Exception => _errorTimeDebounce?.Debounced(),
6167
LogType.Error or LogType.Assert => _errorTimeDebounce?.Debounced(),
6268
LogType.Log => _logTimeDebounce?.Debounced(),
6369
LogType.Warning => _warningTimeDebounce?.Debounced(),
@@ -70,14 +76,19 @@ internal void OnLogMessageReceived(string message, string stacktrace, LogType lo
7076
}
7177
}
7278

73-
if (logType is LogType.Error && _options?.CaptureLogErrorEvents is true)
79+
if (logType is LogType.Exception)
80+
{
81+
var ule = new UnityErrorLogException(message, stacktrace, _options);
82+
_hub.CaptureException(ule);
83+
}
84+
else if (logType is LogType.Error && _options?.CaptureLogErrorEvents is true)
7485
{
7586
if (_options?.AttachStacktrace is true && !string.IsNullOrEmpty(stacktrace))
7687
{
7788
var ule = new UnityErrorLogException(message, stacktrace, _options);
78-
var evt = new SentryEvent(ule) { Level = SentryLevel.Error };
89+
var sentryEvent = new SentryEvent(ule) { Level = SentryLevel.Error };
7990

80-
_hub.CaptureEvent(evt);
91+
_hub.CaptureEvent(sentryEvent);
8192
}
8293
else
8394
{

src/Sentry.Unity/SentryUnityOptions.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,13 @@ internal SentryUnityOptions(IApplication? application = null,
333333
AddTransactionProcessor(processor);
334334
AddExceptionProcessor(new UnityExceptionProcessor());
335335

336-
AddIntegration(new UnityLogHandlerIntegration(this));
337-
AddIntegration(new UnityApplicationLoggingIntegration());
336+
// UnityLogHandlerIntegration is not compatible with WebGL, so it's added conditionally
337+
if (application.Platform != RuntimePlatform.WebGLPlayer)
338+
{
339+
AddIntegration(new UnityLogHandlerIntegration(this));
340+
AddIntegration(new UnityApplicationLoggingIntegration());
341+
}
342+
338343
AddIntegration(new StartupTracingIntegration());
339344
AddIntegration(new AnrIntegration(behaviour));
340345
AddIntegration(new UnityScopeIntegration(application, unityInfo));

src/Sentry.Unity/SentryUnitySdk.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,17 @@ public SentrySdk.CrashedLastRun CrashedLastRun()
9494
{
9595
if (_options.CrashedLastRun is null)
9696
{
97-
_options.DiagnosticLogger?.LogDebug("The SDK does not have a 'CrashedLastRun' set. " +
98-
"This might be due to a missing or disabled native integration.");
97+
if (ApplicationAdapter.Instance.Platform == RuntimePlatform.WebGLPlayer)
98+
{
99+
_options.DiagnosticLogger?.LogDebug("Currently, the Sentry SDK for Unity provides no native support for WebGL." +
100+
"LastRunState is `Unknown`.");
101+
}
102+
else
103+
{
104+
_options.DiagnosticLogger?.LogDebug("The SDK does not have a 'CrashedLastRun' set. " +
105+
"This might be due to a missing or disabled native integration.");
106+
}
107+
99108
return SentrySdk.CrashedLastRun.Unknown;
100109
}
101110

src/Sentry.Unity/WebGL/SentryWebGL.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Sentry.Extensibility;
2+
using Sentry.Unity.Integrations;
23
using UnityEngine.Analytics;
34

45
namespace Sentry.Unity.WebGL;
@@ -16,6 +17,9 @@ public static void Configure(SentryUnityOptions options)
1617
{
1718
options.DiagnosticLogger?.LogDebug("Updating configuration for Unity WebGL.");
1819

20+
// Due to special exception handling on WebGL we capture these through `LogMessageReceived` too
21+
options.AddIntegration(new UnityApplicationLoggingIntegration(captureExceptions: true));
22+
1923
// Note: we need to use a custom background worker which actually doesn't work in the background
2024
// because Unity doesn't support async (multithreading) yet. This may change in the future so let's watch
2125
// https://docs.unity3d.com/2019.4/Documentation/ScriptReference/PlayerSettings.WebGL-threadsSupport.html
@@ -26,16 +30,23 @@ public static void Configure(SentryUnityOptions options)
2630
// "An abnormal situation has occurred: the PlayerLoop internal function has been called recursively.
2731
// Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it."
2832
// Maybe we could write a file when this error occurs and recognize it on the next start. Like unity-native.
29-
options.CrashedLastRun = () => false;
33+
options.CrashedLastRun = null;
3034

3135
// Disable async when accessing files (e.g. FileStream(useAsync: true)) because it throws on WebGL.
3236
options.UseAsyncFileIO = false;
3337

3438
if (options.AttachScreenshot)
3539
{
3640
options.AttachScreenshot = false;
37-
options.DiagnosticLogger?.LogWarning("Attaching screenshots on WebGL is disabled - " +
38-
"it currently produces blank screenshots mid-frame.");
41+
options.DiagnosticLogger?.LogWarning("Attaching screenshots is unsupported on WebGL - disabling. " +
42+
"Currently, it produces blank screenshots mid-frame.");
43+
}
44+
45+
// On WebGL, the IL2CPP backend does not provide the API required to make the IL2CPP Event Processor work
46+
if (options.Il2CppLineNumberSupportEnabled)
47+
{
48+
options.Il2CppLineNumberSupportEnabled = false;
49+
options.DiagnosticLogger?.LogWarning("IL2CPP line number support is unsupported on WebGL - disabling.");
3950
}
4051

4152
// Use AnalyticsSessionInfo.userId as the default UserID

0 commit comments

Comments
 (0)