Repository navigation
fix: Use async-safe NSException monitor logging - #9324
Conversation
Size Analysis1 component analyzed iOS Builds
|
📲 Install BuildsiOS
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d9571ee | 1225.67 ms | 1259.02 ms | 33.35 ms |
| 88e0b6e | 1212.93 ms | 1251.27 ms | 38.33 ms |
| f0e2408 | 1224.53 ms | 1260.51 ms | 35.98 ms |
| 8a8e812 | 1233.65 ms | 1257.19 ms | 23.54 ms |
| c8c3374 | 1232.96 ms | 1263.46 ms | 30.50 ms |
| b0aa013 | 1208.48 ms | 1244.00 ms | 35.52 ms |
| 1cba5c4 | 1230.28 ms | 1271.48 ms | 41.20 ms |
| f6e658b | 1203.39 ms | 1238.34 ms | 34.95 ms |
| 89ccfc2 | 1210.78 ms | 1245.02 ms | 34.24 ms |
| 545ca7e | 1233.89 ms | 1269.30 ms | 35.41 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d9571ee | 24.14 KiB | 1.39 MiB | 1.36 MiB |
| 88e0b6e | 24.14 KiB | 1.38 MiB | 1.36 MiB |
| f0e2408 | 24.14 KiB | 1.39 MiB | 1.36 MiB |
| 8a8e812 | 24.14 KiB | 1.38 MiB | 1.36 MiB |
| c8c3374 | 24.14 KiB | 1.38 MiB | 1.36 MiB |
| b0aa013 | 24.14 KiB | 1.38 MiB | 1.36 MiB |
| 1cba5c4 | 24.14 KiB | 1.38 MiB | 1.36 MiB |
| f6e658b | 24.14 KiB | 1.38 MiB | 1.35 MiB |
| 89ccfc2 | 24.14 KiB | 1.38 MiB | 1.36 MiB |
| 545ca7e | 24.14 KiB | 1.39 MiB | 1.36 MiB |
Previous results on branch: test/nsexception-logging-regression
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5607a7e | 1227.06 ms | 1260.29 ms | 33.23 ms |
| 7cb0c72 | 1234.61 ms | 1262.02 ms | 27.41 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5607a7e | 24.14 KiB | 1.38 MiB | 1.36 MiB |
| 7cb0c72 | 24.14 KiB | 1.39 MiB | 1.36 MiB |
supervacuus
left a comment
There was a problem hiding this comment.
Purely from a fix perspective, this LGTM.
I am not sure how you handle log regressions in this SDK, but replacing SENTRY_LOG_DEBUG with SENTRY_ASYNC_SAFE_LOG_DEBUG (and *WARN respectively) leads to a regression in the sense that the latter is controlled by a compile-time definition that is currently hardcoded to log level ERROR, meaning all logs in this function are compiled out with this PR, so instead of logging async-safe, we are not logging at all.
This can be fine, of course, but I think it's worth raising in a review.
- remark that options no longer control the NSException-monitor logger in the changelog - allocate and free the buffer for the stack trace outside the thread suspension - remove the remaining unsafe log calls from sentrycrashcm_nsexception_initStackCursor - log the trapped exception with name and reason (if available) after we have access to the crash context
|
All raised concerns were resolved in 1141c51 |
supervacuus
left a comment
There was a problem hiding this comment.
Approving, but @philprime, please have another look. I leave the merge up to you.
|
LGTM too. Thanks for taking this over! |
Use async-safe logging throughout the NSException crash monitor to avoid deadlocking on stdout while other threads are suspended. Log the exception pointer instead of invoking Objective-C description formatting.
Add a regression test that verifies monitor shutdown never invokes the normal SDK log output callback. Initialize logging before capturing shutdown messages and isolate capture from background SDK initialization.
Verification
Related CI failure: https://github.com/getsentry/sentry-cocoa/actions/runs/38266180787/job/114868927446?pr=9251
Closes #9331