Skip to content

Conversation

itaybre
Copy link
Contributor

@itaybre itaybre commented May 27, 2025

📜 Description

Add a new method to collect crashes on _crashOnException and report the stacktrace from the exception instead of the current thread

💡 Motivation and Context

Exception captured on _crashOnException do no collect the proper stacktraces/
Fixes: #5058

💚 How did you test it?

On macOS App

📝 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.

TODO:

  • Update changelog
  • Add test case

Copy link
Contributor

github-actions bot commented May 27, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 6d8ab6c

Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.946%. Comparing base (9c9b0a8) to head (6d8ab6c).
Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #5306       +/-   ##
=============================================
- Coverage   85.957%   85.946%   -0.011%     
=============================================
  Files          394       394               
  Lines        34217     34219        +2     
  Branches     14796     14800        +4     
=============================================
- Hits         29412     29410        -2     
+ Misses        4763      4761        -2     
- Partials        42        48        +6     
Files with missing lines Coverage Δ
Sources/Sentry/SentryClient.m 98.459% <ø> (ø)
Sources/Sentry/SentrySDK.m 88.095% <ø> (ø)
Sources/Sentry/SentryStacktraceBuilder.m 78.125% <100.000%> (-0.337%) ⬇️

... 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 9c9b0a8...6d8ab6c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

github-actions bot commented May 27, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1226.18 ms 1239.35 ms 13.16 ms
Size 23.76 KiB 838.07 KiB 814.31 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7bc3c0d 1261.16 ms 1278.38 ms 17.22 ms
881a955 1222.94 ms 1246.26 ms 23.32 ms
c83ffd9 1235.15 ms 1256.92 ms 21.77 ms
885c76b 1227.37 ms 1248.21 ms 20.84 ms
88aed1e 1227.83 ms 1245.27 ms 17.43 ms
c75412c 1224.90 ms 1254.27 ms 29.37 ms
326b7eb 1252.86 ms 1259.56 ms 6.70 ms
07ea386 1228.86 ms 1255.31 ms 26.45 ms
8ef07fb 1231.45 ms 1243.98 ms 12.53 ms
8f397a7 1219.12 ms 1236.67 ms 17.55 ms

App size

Revision Plain With Sentry Diff
7bc3c0d 20.76 KiB 427.36 KiB 406.59 KiB
881a955 22.85 KiB 407.63 KiB 384.78 KiB
c83ffd9 21.58 KiB 573.16 KiB 551.57 KiB
885c76b 22.31 KiB 775.27 KiB 752.96 KiB
88aed1e 22.30 KiB 829.53 KiB 807.22 KiB
c75412c 22.31 KiB 775.27 KiB 752.95 KiB
326b7eb 20.76 KiB 432.31 KiB 411.55 KiB
07ea386 22.30 KiB 747.52 KiB 725.22 KiB
8ef07fb 21.58 KiB 707.42 KiB 685.84 KiB
8f397a7 20.76 KiB 420.55 KiB 399.79 KiB

Previous results on branch: itaybre/crash_on_exception

Startup times

Revision Plain With Sentry Diff
8280f74 1225.12 ms 1251.00 ms 25.87 ms
9c37143 1211.76 ms 1244.86 ms 33.10 ms
ee78418 1247.53 ms 1268.06 ms 20.53 ms
25d4149 1220.37 ms 1242.23 ms 21.86 ms
1885f9a 1226.58 ms 1248.65 ms 22.06 ms
4b1ac68 1236.14 ms 1256.84 ms 20.69 ms
9fc9a23 1237.35 ms 1264.80 ms 27.45 ms
2a51821 1222.06 ms 1234.18 ms 12.12 ms
f5ba7c1 1220.90 ms 1245.17 ms 24.28 ms

App size

Revision Plain With Sentry Diff
8280f74 23.76 KiB 821.69 KiB 797.93 KiB
9c37143 23.76 KiB 837.52 KiB 813.76 KiB
ee78418 23.76 KiB 821.47 KiB 797.71 KiB
25d4149 23.76 KiB 836.50 KiB 812.74 KiB
1885f9a 23.76 KiB 821.48 KiB 797.72 KiB
4b1ac68 23.76 KiB 837.51 KiB 813.75 KiB
9fc9a23 23.76 KiB 831.33 KiB 807.57 KiB
2a51821 23.76 KiB 822.94 KiB 799.18 KiB
f5ba7c1 23.76 KiB 837.99 KiB 814.23 KiB

@itaybre itaybre marked this pull request as ready for review May 27, 2025 21:21
Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good progress, left some comments.

@philipphofmann I would appreciate a review of you as well.

Copy link
Member

@armcknight armcknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works and LGTM, just some small suggestions from me.

@maxpoi
Copy link

maxpoi commented May 30, 2025

Hi, quick question. Is this only working with SentryApplication? Can "options.enableUncaughtNSExceptionReporting" also benefits from this? Many thanks.

- (void)_crashOnException:(NSException *)exception
{
    [SentrySDK captureException:exception];
    [SentrySDK captureCrashOnException:exception];
    abort();
}

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this. I added a few comments.

@philipphofmann
Copy link
Member

FYI, @itaybre I think after merging this PR we could easily tackle #741 and #3907.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for including most of the feedback. I gave this another round.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @itaybre. LGTM

@itaybre itaybre merged commit 426a2d3 into main Jun 5, 2025
79 of 81 checks passed
@itaybre itaybre deleted the itaybre/crash_on_exception branch June 5, 2025 17:21
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.

Sentry catches wrong stacktrace of NSException
5 participants