-
-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Option for uncaught NSExceptions on macOS #4471
base: main
Are you sure you want to change the base?
Conversation
Add a new option, enableReportingUncaughtExceptions, for reporting uncaught exceptions on macOS. AS SwiftUI applications on macOS can't easily set a Principal class in the Info.plist, especially when using the NSApplicationDelegate, our existing solution of the SentryCrashExceptionApplication doesn't work for them. This new option fixes that problem.
@@ -5,8 +5,7 @@ import Sentry | |||
class AppDelegate: NSObject, NSApplicationDelegate { | |||
|
|||
func applicationDidFinishLaunching(_ aNotification: Notification) { | |||
UserDefaults.standard.register(defaults: ["NSApplicationCrashOnExceptions": true]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to using the SentryCrashExceptionApplication
in the Info.plist file.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4471 +/- ##
=============================================
- Coverage 91.818% 91.790% -0.029%
=============================================
Files 610 611 +1
Lines 68230 68240 +10
Branches 24493 24494 +1
=============================================
- Hits 62648 62638 -10
- Misses 5489 5510 +21
+ Partials 93 92 -1
... and 7 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
51ffd8c | 1234.40 ms | 1246.22 ms | 11.82 ms |
b15521e | 1224.44 ms | 1251.13 ms | 26.68 ms |
3297d6e | 1195.69 ms | 1212.35 ms | 16.65 ms |
c6773e5 | 1222.48 ms | 1240.02 ms | 17.54 ms |
39a4941 | 1210.69 ms | 1219.83 ms | 9.14 ms |
ecd9ecd | 1241.28 ms | 1260.35 ms | 19.07 ms |
5269d20 | 1230.18 ms | 1252.64 ms | 22.46 ms |
cbf6225 | 1221.73 ms | 1251.20 ms | 29.47 ms |
3de9971 | 1224.38 ms | 1245.33 ms | 20.95 ms |
add9550 | 1221.20 ms | 1250.04 ms | 28.84 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
51ffd8c | 21.58 KiB | 418.69 KiB | 397.11 KiB |
b15521e | 21.58 KiB | 573.18 KiB | 551.60 KiB |
3297d6e | 21.58 KiB | 418.44 KiB | 396.86 KiB |
c6773e5 | 20.76 KiB | 435.25 KiB | 414.49 KiB |
39a4941 | 22.84 KiB | 402.63 KiB | 379.79 KiB |
ecd9ecd | 20.76 KiB | 420.23 KiB | 399.47 KiB |
5269d20 | 21.58 KiB | 714.41 KiB | 692.83 KiB |
cbf6225 | 20.76 KiB | 425.77 KiB | 405.00 KiB |
3de9971 | 21.58 KiB | 574.17 KiB | 552.59 KiB |
add9550 | 21.58 KiB | 418.37 KiB | 396.79 KiB |
Previous results on branch: feat/uncaught-ns-exceptions
Startup times
Revision | Plain | With Sentry | Diff |
---|---|---|---|
a3b8d95 | 1245.37 ms | 1258.92 ms | 13.55 ms |
27158ef | 1213.46 ms | 1239.08 ms | 25.62 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
a3b8d95 | 21.90 KiB | 707.97 KiB | 686.06 KiB |
27158ef | 21.90 KiB | 707.97 KiB | 686.07 KiB |
Sorry @philipphofmann, I will only be able to review this on Monday |
📜 Description
Add a new option, enableReportingUncaughtExceptions, for reporting uncaught exceptions on macOS. AS SwiftUI applications on macOS can't easily set a Principal class in the Info.plist, especially when using the NSApplicationDelegate, our existing solution of the SentryCrashExceptionApplication doesn't work for them. This new option fixes that problem.
💡 Motivation and Context
A customer reported the current setup doesn't work for them when using
NSApplicationDelegate
.💚 How did you test it?
Unit tests and manually with the simulator. I compared the new way (
enableReportingUncaughtExceptions
) with the old way ofSentryCrashExceptionApplication
and all three tests worked the same way. Report exception seems a bit broken, but that was already the case before. We should look at this individually.Simulator tests
I added three different ways for reporting NSExcption.
raise()
on it.NSApplication.shared.reportException(exception)
macOS-SwiftUI
Raise
https://sentry-sdks.sentry.io/issues/6016580829/events/1cfac198b76944878b21610eac25b941/?project=5428557
Report
https://sentry-sdks.sentry.io/issues/6016587329/events/ebefcb69480243cebbc4b42ba15519e6/?project=5428557
NSRange
https://sentry-sdks.sentry.io/issues/6016594158/events/31eabb811c0d47aeaa8d997d087f878b/?project=5428557
macOS-Swift
Raise
https://sentry-sdks.sentry.io/issues/6016621535/events/3fcff45068e3481486617c4eb447d818/?project=5428557
Report
https://sentry-sdks.sentry.io/issues/6016587329/events/3c402084c01442eea986fc8cd6476ec7/?project=5428557
NSRange
https://sentry-sdks.sentry.io/issues/6016756316/events/21241a61000c4e278aa6908f26b35ddf/?project=5428557
Xcode Crash Reports
Xcode Crash Report Raise
Xcode Crash Report Report
Xcode Crash Report NSRange
📝 Checklist
You have to check all boxes before merging:
sendDefaultPII
is enabled.🔮 Next steps