Skip to content

Conversation

jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Sep 18, 2025

📜 Description

WIP: Prevent the Cocoa SDK from capturing managed .NET exceptions.

First, if a managed Mono/CoreCLR runtime is detected based on previously installed Mach exception ports, we avoid overriding the port to let the managed runtime keep its null exception port for EXC_BAD_ACCESS and EXC_ARITHMETIC.

Secondly, when running within a managed runtime, Cocoa SDK's signal handler invokes the previously installed signal handlers to give the managed runtime first a chance to convert it into a managed exception, and redirect execution into the managed runtime’s exception handling machinery, so that managed code can catch and process the exception as if it were a normal .NET exception.

💡 Motivation and Context

Fixes a long-standing issue with redundant crash events with Sentry.NET on iOS:

💚 How did you test it?

  1. Manually with Sentry.Samples.Maui in Sentry.NET:
  2. With the newly developed Sentry .NET integration test for iOS:

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 55.00000% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.606%. Comparing base (e70670c) to head (ed98b04).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ash/Recording/Monitors/SentryCrashMonitor_Signal.c 3.030% 32 Missing ⚠️
...ording/Monitors/SentryCrashMonitor_MachException.c 76.470% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6193       +/-   ##
=============================================
- Coverage   86.697%   86.606%   -0.092%     
=============================================
  Files          436       436               
  Lines        37076     37151       +75     
  Branches     17390     17420       +30     
=============================================
+ Hits         32144     32175       +31     
- Misses        4890      4931       +41     
- Partials        42        45        +3     
Files with missing lines Coverage Δ
...SentryCrash/Recording/Tools/SentryCrashCPU_arm64.c 100.000% <100.000%> (ø)
...entryCrash/Recording/Tools/SentryCrashCPU_x86_64.c 100.000% <100.000%> (ø)
...ording/Monitors/SentryCrashMonitor_MachException.c 41.747% <76.470%> (+2.021%) ⬆️
...ash/Recording/Monitors/SentryCrashMonitor_Signal.c 55.681% <3.030%> (-11.215%) ⬇️

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e70670c...ed98b04. Read the comment docs.

jpnurmi added a commit to getsentry/sentry-dotnet that referenced this pull request Sep 18, 2025
This reverts "Use pre-built version of sentry-cocoa SDK (#3727)"
commit d179ec9 and restores the
modules/sentry-cocoa Git module checked out at:
getsentry/sentry-cocoa#6193
@jpnurmi jpnurmi force-pushed the jpnurmi/mono-interop branch from e4be364 to 2f90356 Compare September 18, 2025 11:35
@jpnurmi jpnurmi force-pushed the jpnurmi/mono-interop branch from 2f90356 to ed98b04 Compare September 18, 2025 11:46
Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1232.57 ms 1259.68 ms 27.11 ms
Size 23.75 KiB 975.29 KiB 951.55 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7c7ac56 1225.90 ms 1250.22 ms 24.33 ms
8ea5293 1242.70 ms 1262.25 ms 19.55 ms
35c962f 1207.61 ms 1235.90 ms 28.29 ms
aa98fe8 1227.69 ms 1253.18 ms 25.50 ms
339539a 1219.58 ms 1254.63 ms 35.05 ms
0ac4c65 1236.85 ms 1267.84 ms 30.98 ms
6ee4973 1228.42 ms 1252.26 ms 23.84 ms
b13e93a 1236.24 ms 1247.33 ms 11.08 ms
2e79f5f 1220.53 ms 1249.35 ms 28.82 ms
5ae9ff1 1222.31 ms 1250.96 ms 28.65 ms

App size

Revision Plain With Sentry Diff
7c7ac56 23.75 KiB 902.49 KiB 878.74 KiB
8ea5293 23.75 KiB 852.24 KiB 828.49 KiB
35c962f 23.75 KiB 854.77 KiB 831.02 KiB
aa98fe8 23.75 KiB 891.01 KiB 867.26 KiB
339539a 23.75 KiB 968.24 KiB 944.50 KiB
0ac4c65 23.75 KiB 968.24 KiB 944.50 KiB
6ee4973 23.75 KiB 896.53 KiB 872.79 KiB
b13e93a 23.75 KiB 855.37 KiB 831.62 KiB
2e79f5f 23.75 KiB 928.87 KiB 905.12 KiB
5ae9ff1 23.74 KiB 971.82 KiB 948.08 KiB

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Sep 18, 2025

Screen.Recording.2025-09-18.at.11.54.52.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant