Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Target `net9.0` on Sentry.Google.Cloud.Functions to avoid conflict with Sentry.AspNetCore ([#4039](https://github.com/getsentry/sentry-dotnet/pull/4039))
- Changed default value for `SentryOptions.EnableAppHangTrackingV2` to `false` ([#4042](https://github.com/getsentry/sentry-dotnet/pull/4042))
- Missing MAUI `Shell` navigation breadcrumbs on iOS ([#4006](https://github.com/getsentry/sentry-dotnet/pull/4006))
- Prevent application crashes when capturing screenshots on iOS ([#4069](https://github.com/getsentry/sentry-dotnet/pull/4069))

### Features

Expand Down
16 changes: 16 additions & 0 deletions src/Sentry.Maui/Internal/ScreenshotAttachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ public ScreenshotAttachmentContent(SentryMauiOptions options)
}

public Stream GetStream()
{
try
{
return GetStreamInternal();
}
catch (Exception ex)
{
// See https://github.com/getsentry/sentry-dotnet/issues/3880#issuecomment-2640159466
_options.LogError("Failed to capture screenshot", ex);
// Return empty stream since calling code may assume a non-null return value
// E.g. https://github.com/getsentry/sentry-dotnet/blob/db5606833a4b0662c6bea0663cca10cb05fb5157/src/Sentry/Protocol/Envelopes/EnvelopeItem.cs#L332-L333
return new MemoryStream();
}
}

private Stream GetStreamInternal()
{
var stream = Stream.Null;
// Not including this on Windows specific build because on WinUI this can deadlock.
Expand Down
Loading