getsentry / getsentry/sentry-dotnet
Sentry.Maui iOS ( .Net ): iOS App crashes on HTTP 5xx response when Native Swizzling is enabled
- Dominant language
- C#
- Stars
- 770
- Forks
- 248
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 51
Description
### Package
Sentry.Maui
### .NET Flavor
.NET
### .NET Version
9.0.312
### OS
iOS
### OS Version
26+
### Development Environment
Rider 2025.x (macOS)
### Other Error Monitoring Solution
No
### Other Error Monitoring Solution Name
_No response_
### SDK Version
5.15.0
### Self-Hosted Sentry Version
_No response_
### Workload Versions
maui 9.0.x
### UseSentry or SentrySdk.Init call
.UseSentry(options =>
{
options.Dsn = "[-- ADD DNS ENTRY HERE --]";
options.StackTraceMode = StackTraceMode.Enhanced;
options.IsGlobalModeEnabled = true;
#if IOS
//var appInfo = new iOSAppInfo();
options.Release = $"iOS 1.0";
// options.Native.EnableSwizzling = false;
// options.Native.EnableNetworkBreadcrumbs = false;
// options.Native.EnableNetworkTracking = false;
// options.Native.EnableTracing = false;
#endif
#if ANDROID
var appInfo = new DroidAppInfo();
options.Release = $"Android {appInfo.AppVersion}";
options.Android.SuppressSegfaults = true;
#endif
#if DEBUG
options.Environment = "Debug";
// Use debug mode if you want to see what the SDK is doing.
// Debug messages are written to stdout with Console.Writeline,
// and are viewable in your IDE's debug console or with 'adb logcat', etc.
// options.Debug = true;
#endif
#if RELEASE_TEST
options.Environment = "Release-Test";
#endif
#if RELEASE_UAT
options.Environment = "Release-UAT";
#endif
#if RELEASE
options.Environment = "Production";
options.SampleRate = .25f;
#endif
})
### Github Repo that reproduces issue
- [Sentry Sandbox repo](https://github.com/HomeroLara/SentrySandbox)
### Steps to Reproduce
1. In the MauiProgram.cs of the Github Repo listed above, in the UseSentry() block add your DNS entry
2. Build and deploy to a iOS device or simulator
3. Once the app launches, tap on the 'Click me' button -> this will crash the app.
4. Go back to the UseSentry() block in the MauiProgram.cs file & uncomment the 'options.Native.EnableSwizzling = false;' line.
5. Build and deploy to a iOS device or simulator
6. Tap on the 'Click me' button -> the app does not crash
### Expected Result
The app should not crash with default setting of EnableSwizzling. Having to disable Swizzling can have limitations for bug tracking.
### Actual Result
App crashes because of native Swizzling.
Attached is the stack trace that led me to Sentry.Maui.
Please let me know if you have any questions.
### Github Repo that reproduces issue
- [Sentry Sandbox repo](https://github.com/HomeroLara/SentrySandbox)
### Here is what I think is happening:
- A 5xx triggers a retry, and the retry cancels a network request that's already finished and cleaned up. Normally cancelling a dead request does nothing — Apple's code just ignores it.
- Sentry's swizzling makes it stop ignoring it. Sentry hooks itself into that cancel and reaches into the request object, which no longer exists. The app reads freed memory and crashes.
Thanks.
[stack_trace.txt](https://github.com/user-attachments/files/31565155/stack_trace.txt)
Contributor guide
Research direction
Reproduce the crash from the Sentry Sandbox repo using the UseSentry block in MauiProgram.cs, first with native swizzling enabled and then disabled. Read stack_trace.txt and trace the failure through the Sentry.Maui iOS swizzling path. Done means the 5xx response no longer crashes the app with default swizzling while native tracking remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, ios
- Domain
- mobile-dev, observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100