diff --git a/src/Sentry.Unity/ScreenshotEventProcessor.cs b/src/Sentry.Unity/ScreenshotEventProcessor.cs index d9416205c..c00d2b705 100644 --- a/src/Sentry.Unity/ScreenshotEventProcessor.cs +++ b/src/Sentry.Unity/ScreenshotEventProcessor.cs @@ -27,6 +27,9 @@ public SentryEvent Process(SentryEvent @event) if (Interlocked.CompareExchange(ref _isCapturingScreenshot, 1, 0) == 0) { _options.LogDebug("Starting coroutine to capture a screenshot."); + // Capture must run on the main thread after WaitForEndOfFrame (ReadPixels needs a complete frame), but the + // event processor pipeline is synchronous and may run on any thread - blocking here would deadlock when + // called from the main thread. So we capture in a coroutine and ship the screenshot as a separate envelope. _sentryMonoBehaviour.QueueCoroutine(CaptureScreenshotCoroutine(@event)); }