Repository navigation
Description
Package
Sentry.Maui
.NET Flavor
.NET
.NET Version
10.0.303
OS
Android
OS Version
No response
Development Environment
Visual Studio v18.x
Other Error Monitoring Solution
No
Other Error Monitoring Solution Name
No response
SDK Version
6.9.0
Self-Hosted Sentry Version
No response
UseSentry or SentrySdk.Init call
.UseSentry(options =>
{
options.Dsn = "https://[ENTER YOUR DSN]";
options.Debug = true;
options.AttachScreenshot = true;
});
Steps to Reproduce
Calling SentrySdk.CaptureException or throwing exception from the Android UI thread freezes the application indefinitely when:
options.AttachScreenshot = true;
The call never returns and normal exception-handling flow cannot continue.
Disabling screenshot attachment completely avoids the problem:
options.AttachScreenshot = false;
Minimal reproduction
Configure Sentry in a .NET MAUI 10.0.90 application:
builder.UseSentry(options =>
{
options.Dsn = "...";
options.Debug = true;
options.AttachScreenshot = true;
});
Capture a handled exception from the UI thread, such as from a button command:
private void CaptureTestException()
{
try
{
throw new InvalidOperationException("Sentry screenshot test");
}
catch (Exception ex)
{
SentryId eventId = SentrySdk.CaptureException(ex);
// This line is never reached on Android.
Debug.WriteLine(eventId);
}
}
Regression checks
The same Android behavior was reproduced with both Sentry.Maui 6.5.0 and 6.8.0 while using MAUI 10.0.90.
The application previously submitted Android events with screenshots successfully when using earlier MAUI 10.0.x releases. The behavioral change appears to begin with MAUI 10.0.90.
Downgrading only Sentry does not resolve the problem.
Suspected root cause
Sentry’s MAUI screenshot attachment still treats Android screenshot capture as synchronously completed.
In Sentry.Maui 6.9.0, ScreenshotAttachmentContent contains:
var screen = Screenshot.Default
.CaptureAsync()
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();
return screen
.OpenReadAsync(ScreenshotFormat.Jpeg)
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();
Source Sentry ScreenshotAttachment.cs
The accompanying comment says Android’s MAUI implementation returns Task.FromResult. That assumption is no longer valid in MAUI 10.0.90.
MAUI PR #35384 changed Android screenshot capture to use PixelCopy.Request: PR #35384
The PixelCopy completion callback is posted through a handler associated with Looper.MainLooper.
This produces the following deadlock when CaptureException runs on the UI thread:
- Sentry calls Screenshot.CaptureAsync().
- Sentry synchronously blocks using GetAwaiter().GetResult().
- MAUI waits for the PixelCopy callback.
- The callback is scheduled on the Android main looper.
- The main thread cannot process the callback because it is blocked inside Sentry.
- CaptureException never returns.
Suggested correction
Please update the Sentry.Maui screenshot attachment implementation so it does not synchronously block the Android UI thread while waiting for MAUI’s asynchronous PixelCopy screenshot capture.
The existing source comment claiming Android screenshot capture returns Task.FromResult should also be updated because it no longer reflects MAUI 10.0.90 behavior.
Expected Result
Expected result
SentrySdk.CaptureException should return without blocking the Android UI thread, and the exception should be queued with its screenshot attachment.
Actual Result
On Android:
SentrySdk.CaptureException never returns.
The UI thread remains blocked.
The application appears completely frozen.
No subsequent error handling or navigation executes.
On iOS, CaptureException returns successfully and the event includes a screenshot.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Aug 17, 2026
NET-788
jamescrosswell commentedon Aug 19, 2026
@MichaelShapiro thanks for the report.
Confirmed and reproduced.
The primary cause is that MAUI's
RenderUsingPixelCopyAsynchas changed (in dotnet/maui@c2b81f9) from this:To this:
Sentry blocks on it:
sentry-dotnet/src/Sentry.Maui/Internal/ScreenshotAttachment.cs
Line 56 in f02bc53
The main thread is inside GetResult(), so Android's Looper.MainLooper never drains... so
OnPixelCopyFinishednever runs = deadlock.Emergency workaround
For the time being you either have to disable screenshot capture or, otherwise, the best you can do is:
That basically drops any attempt to capture screenshots on the MainUI thread... which will still be most of them. It will leave intact any screenshot capture by the sentry-java SDK though - so you might get a few.
Brainstorming
PixelCopy.Request, so blocking the caller is safe.MichaelShapiro commentedon Aug 19, 2026
@jamescrosswell I ended up doing this:
and I had to convert all call sites to async calling of course. Maybe there is a better, but I wanted to preserve screen capture. I'm surprised no one reported it yet -seems like a problem :(
jamescrosswell commentedon Aug 19, 2026
Ah, that's a good solution. You might want to couple it with my suggestion since Unhandled exceptions would still deadlock.
There's also a chance that the screenshot you get doesn't exactly represent the screen at the time of the exception now, since the capture happens async... but overall, I think you preserve more information with this solution 👍🏻
MAUI 10.0.90 is pretty recent... I've created a tracking issue in the MAUI repo:
The only way I can think of working around it in Sentry involves duplicating (and maintaining) a bunch of the MAUI code in our repo - so would definitely rather get this fixed upstream, if possible.
jamescrosswell commentedon Aug 26, 2026
Looks like this has been addressed in .NET:
Presumably that fix will be included in the 10.0.12 release. I don't think there's anything for us to do in this repo then @MichaelShapiro.
MichaelShapiro commentedon Aug 27, 2026
thank you!
dartasen commentedon Sep 8, 2026
Fix seems to be part of the SR10.1 release (although not mentionned in the changelog) : dotnet/maui@10.0.100...10.0.101