Skip to content

Commit

Permalink
Update ScreenshotAttachment.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescrosswell committed Nov 28, 2024
1 parent 6418acf commit 6271ff7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Sentry.Maui/Internal/ScreenshotAttachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public Stream GetStream()
{
var stream = Stream.Null;
// Not including this on Windows specific build because on WinUI this can deadlock.
#if !(__ANDROID__ || __IOS__)
return stream;
#endif
#if (__ANDROID__ || __IOS__)
Stream CaptureScreenBlocking()
{
// This actually runs synchronously (returning Task.FromResult) on the following platforms:
Expand All @@ -60,6 +58,7 @@ Stream CaptureScreenBlocking()
return stream;
}

#endif
#if __IOS__
if (MainThread.IsMainThread)
{
Expand All @@ -75,7 +74,7 @@ Stream CaptureScreenBlocking()
return await screen.OpenReadAsync(ScreenshotFormat.Jpeg).ConfigureAwait(true);
}).ConfigureAwait(false).GetAwaiter().GetResult();
}
#else
#elif __ANDROID__
// Capturing screenshots is not threadsafe on Android
lock (JniLock)
{
Expand Down

0 comments on commit 6271ff7

Please sign in to comment.