dotnet / dotnet/runtime

When VS debugger is attached, exception handling causes all threads to pause up to 200ms! (makes debugging timing-sensitive code impossible).

Open
#122,344 8 comments 0 reactions 1 assignee Claimed by @thaystg View on GitHub
area-Diagnostics-mono tenet-performance
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

throw-catch can take up to 200ms with VS debugger attached to a MAUI Android app and up to 10ms when debugging under Windows. When debugger is not attached, throw-catch takes ~0ms as expected. See the attached MAUI test app Test1() to run & show throw-catch latency.

Furthermore Test2() shows that thread1 stops running while thread2 is throwing exceptions. So it seems that the entire process is suspended for up to 200ms when 1 thread throws 1 exception while the VS debugger is attached!

MAUI sample app:
[MauiAppSlowExceptions.zip](https://github.com/user-attachments/files/24057559/MauiAppSlowExceptions.zip)

### Configuration

.net 10
latest VS 2026 preview
several Android phones tested.

### Regression?

This used to be much faster but I don't know with specifically which .Net or VS versions. As it is now, it makes it impossible to debug timing-sensitive code.

### Analysis

I don't know if this is a VS or runtime problem but am reporting it here.
I suspect that there is some round-trip traffic between runtime/Android and VS and that during this time the runtime is suspended instead of continuing to run as expected. The measure values are very jittery (100ms to 200ms) and I suspect that is due to the remote VS debugger connection to Android.
I only tested this with a MAUI app since then I can run the test on several platforms. I expect but am not sure that a native windows app will have similar issues.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.