Skip to content

Commit d2ff335

Browse files
authored
fix: Skip native logger setup on Desktop on Mono (#2445)
1 parent d8f9199 commit d2ff335

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
- `SetBeforeCaptureViewHierarchy` signature changed from `Func<bool>` to `Func<SentryEvent, bool>`, now receiving the event that
1010
triggered the view hierarchy capture. This allows context-aware decisions before capture begins. ([#2429](https://github.com/getsentry/sentry-unity/pull/2429))
1111

12+
### Fixes
13+
14+
- When targeting Windows or Linux with Mono as the scripting backend, to prevent crashes, the native SDK's debug logger integration is disabled. ([#2445](https://github.com/getsentry/sentry-unity/pull/2445))
15+
1216
### Features
1317

1418
- Added PlayStation Native Support. The SDK now automatically syncs the scope - tags, breadcrumbs, context - to the native layer, so native crashes have the same rich context as managed events. ([#2433](https://github.com/getsentry/sentry-unity/pull/2433))

src/Sentry.Unity.Native/SentryNativeBridge.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,16 @@ is RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxServer
7777
}
7878
else
7979
{
80-
options.DiagnosticLogger.LogDebug($"{(_logger is null ? "Setting a" : "Replacing the")} native logger");
81-
_logger = options.DiagnosticLogger;
82-
sentry_options_set_logger(cOptions, new sentry_logger_function_t(nativeLog), IntPtr.Zero);
80+
if (options.UnityInfo.IL2CPP)
81+
{
82+
options.DiagnosticLogger.LogDebug($"{(_logger is null ? "Setting a" : "Replacing the")} native logger");
83+
_logger = options.DiagnosticLogger;
84+
sentry_options_set_logger(cOptions, new sentry_logger_function_t(nativeLog), IntPtr.Zero);
85+
}
86+
else
87+
{
88+
options.DiagnosticLogger.LogInfo("Passing the native logs back to the C# layer is not supported on Mono - skipping native logger.");
89+
}
8390
}
8491

8592
options.DiagnosticLogger?.LogDebug("Initializing sentry native");

0 commit comments

Comments
 (0)