Skip to content

Commit 6a35504

Browse files
authored
fix: MainThread check checks for Job execution (#2226)
1 parent e41511e commit 6a35504

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Fixes
66

7+
- The check used to verify whether the current thread is the main-thread now includes `JobsUtility.IsExecutingJob` to support running in Burst. ([#2226](https://github.com/getsentry/sentry-unity/pull/2226))
78
- For targeting iOS, the Unity SDK now brings an iOS-only `.xcframework`, reducing package size. ([#2264](https://github.com/getsentry/sentry-unity/pull/2264))
89

910
### Dependencies

src/Sentry.Unity/MainThreadData.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Threading;
3+
using Unity.Jobs.LowLevel.Unsafe;
34
using UnityEngine;
45

56
namespace Sentry.Unity;
@@ -70,7 +71,7 @@ internal static class MainThreadData
7071
public static DateTimeOffset? StartTime { get; set; }
7172

7273
public static bool IsMainThread()
73-
=> MainThreadId.HasValue && Thread.CurrentThread.ManagedThreadId == MainThreadId;
74+
=> !JobsUtility.IsExecutingJob && MainThreadId.HasValue && Thread.CurrentThread.ManagedThreadId == MainThreadId;
7475

7576
// For testing
7677
internal static ISentrySystemInfo? SentrySystemInfo { get; set; }

0 commit comments

Comments
 (0)