-
-
Notifications
You must be signed in to change notification settings - Fork 372
feat(anr): Disable ANR tracking for widgets, live activities, action, intent and share extensions #6670
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
base: main
Are you sure you want to change the base?
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6670 +/- ##
=============================================
+ Coverage 85.006% 85.022% +0.015%
=============================================
Files 452 454 +2
Lines 27686 27762 +76
Branches 12157 12201 +44
=============================================
+ Hits 23535 23604 +69
- Misses 4105 4114 +9
+ Partials 46 44 -2
... and 8 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| b44bf23 | 1214.60 ms | 1251.75 ms | 37.15 ms |
| b115f82 | 1212.96 ms | 1251.92 ms | 38.96 ms |
| 664c060 | 1215.48 ms | 1244.41 ms | 28.93 ms |
| 939d583 | 1209.96 ms | 1251.09 ms | 41.13 ms |
| f83dcc4 | 1210.88 ms | 1246.22 ms | 35.35 ms |
| f246093 | 1219.75 ms | 1247.35 ms | 27.60 ms |
| 7a8b167 | 1217.49 ms | 1247.67 ms | 30.18 ms |
| ea3f7b6 | 1228.14 ms | 1258.71 ms | 30.57 ms |
| f8cad3c | 1217.94 ms | 1257.96 ms | 40.02 ms |
| 9c75c11 | 1228.42 ms | 1262.81 ms | 34.39 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| b44bf23 | 23.75 KiB | 1022.78 KiB | 999.03 KiB |
| b115f82 | 23.75 KiB | 989.04 KiB | 965.30 KiB |
| 664c060 | 23.74 KiB | 977.41 KiB | 953.67 KiB |
| 939d583 | 23.75 KiB | 1023.82 KiB | 1000.07 KiB |
| f83dcc4 | 23.75 KiB | 1.02 MiB | 1019.11 KiB |
| f246093 | 23.75 KiB | 1022.79 KiB | 999.04 KiB |
| 7a8b167 | 24.14 KiB | 1.01 MiB | 1014.00 KiB |
| ea3f7b6 | 23.75 KiB | 1.01 MiB | 1008.77 KiB |
| f8cad3c | 23.75 KiB | 1.01 MiB | 1016.13 KiB |
| 9c75c11 | 23.74 KiB | 1022.95 KiB | 999.20 KiB |
Previous results on branch: philprime/disable-live-activity-widgets
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 10db8d4 | 1225.04 ms | 1254.57 ms | 29.53 ms |
| 1171923 | 1232.80 ms | 1251.69 ms | 18.90 ms |
| 48849e2 | 1218.48 ms | 1246.26 ms | 27.78 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 10db8d4 | 23.75 KiB | 1.00 MiB | 1003.65 KiB |
| 1171923 | 23.75 KiB | 1.00 MiB | 1001.57 KiB |
| 48849e2 | 23.75 KiB | 1.00 MiB | 1001.61 KiB |
095f7a8 to
f8693fb
Compare
…e-activity-widgets
…e-activity-widgets
Tests/SentryTests/Integrations/ANR/SentryANRTrackingIntegrationTests.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: phil.niedertscheider <phil.niedertscheider@sentry.io>
Co-authored-by: phil.niedertscheider <phil.niedertscheider@sentry.io>
itaybre
left a comment
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.
LGTM, left some comments for discussion
|
While working on this PR I noticed that the |
…r, IntentHandler, and ShareViewController
📜 Description
This PR addresses issue #3901 by automatically disabling App Hang (ANR) tracking for Widgets, Live Activities, (Siri) Intent Extensions, Action Extensions and Share Extensions. These components run in separate processes or sandboxes with different execution characteristics, which can cause false positive app hang reports.
SentryExtensionDetectorto detect the current extension context by readingInfo.plistSentryExtensionTypeenum for extension point identifiers (WidgetKit, Intents, Action, Share extensions)SentryANRTrackingIntegrationto check for extensions before installing ANR trackingSentryInfoPlistWrapperto support reading dictionary values fromInfo.plist💚 How did you test it?
Testing:
SentryExtensionDetectorcovering all extension types and error casesSentryANRTrackingIntegrationverifying correct behavior in extension contextsSentryExtensionTypeenumSample Applications:
To properly test the edge cases I created additional sample apps and extensions. Some of them required newer iOS versions than iOS 15 which is still used by iOS-Swift.
Testing - General
I implemented samples with UI to visualize internal state using available UI, e.g. using a Siri Message Preview or a widget. As the App Hang tracker is disabled by default when a debugger is attached, you have two options to verify behaviour:
sentry-cocoa/Sources/Sentry/SentryBaseIntegration.m
Lines 136 to 140 in 3a3d93b
The easiest way to verify that the changes in this PR actually change anything is removing/commenting disabled extension types in the
SentryExtensionDetector:sentry-cocoa/Sources/Swift/Helper/SentryExtensionDetector.swift
Lines 5 to 12 in 00bb563
Testing - Share Extension
Before:
.sharefrom the disabled app hang types in theSentryExtensionDetectoriOS-Swifton an iOS 18.6 simulator or iOS devicehttps://docs.sentry.ioiOS-Swiftin the list of applicationsSentry Enabled? ✅butANR Disabled? ❌, indicating that we are in the falsey state and still have ANR tracking enabled.share-before.mov
After:
.shareis in the list of disabled app hang types in theSentryExtensionDetectorSentry Enabled? ✅butANR Disabled? ✅, indicating that we are in the truthy state and have ANR tracking disabled.share-after.mov
Testing - Action Extension
.actionfrom the disabled app hang types in theSentryExtensionDetectoriOS-Swifton an iOS 18.6 simulator or iOS devicehttps://docs.sentry.ioiOS-Swift-ActionExtension✅ Sentry is enabledbut❌ ANR Tracking installed, indicating that we are in the falsey state and still have ANR tracking enabled.action-before.mov
After:
.actionis in the list of disabled app hang types in theSentryExtensionDetector✅ Sentry is enabledand✅ ANR Tracking not installed, indicating that we are in the truthy state and have ANR tracking disabled.action-after.mov
Testing - Intent Extension
Important
I was unsuccessful in using the extension in the simulator, but it worked on device. Therefore I recommend using a real device, but it might also work in the simulator
Before:
.intentfrom the disabled app hang types in theSentryExtensionDetectoriOS-Swifton an iOS deviceSentry Enabled? ✅butANR Disabled? ❌Sentry Enabled? ✅butANR Disabled? ❌tooNOTE: iOS sometimes seems to cache the preview but the message after "sending it" should be correct.
intent-before.MP4
After:
.intentis in the list of disabled app hang types in theSentryExtensionDetector...
Sentry Enabled? ✅butANR Disabled? ✅Sentry Enabled? ✅butANR Disabled? ✅toointent-after.MP4
Testing - Widget
For this test we are disabling debugger detection and keep the debugger attached, because it causes a widget refresh on every run.
Before:
.widgetfrom the disabled app hang types in theSentryExtensionDetectorsentry-cocoa/Sources/Sentry/SentryBaseIntegration.m
Lines 136 to 140 in 3a3d93b
iOS-SwiftUI-Widgets-WidgetsExtensionon an iOS simulatorSDK Enabled? ✅butANR Disabled? ❌with the current timestamp (which is important because widgets can be outdated)widget-before.mov
After:
.widgetis in the list of disabled app hang types in theSentryExtensionDetectorSDK Enabled? ✅andANR Disabled? ✅with the current timestamp (which is important because widgets can be outdated)widget-after.mov
Testing - Widget Control
Before:
.widgetfrom the disabled app hang types in theSentryExtensionDetectorsentry-cocoa/Sources/Sentry/SentryBaseIntegration.m
Lines 136 to 140 in 3a3d93b
iOS-SwiftUI-Widgets-WidgetControlon an iOS simulatorX, it indicates ANR tracking is enabled.widget-control-before.mov
After:
.widgetis in the list of disabled app hang types in theSentryExtensionDetectorsentry-cocoa/Sources/Sentry/SentryBaseIntegration.m
Lines 136 to 140 in 3a3d93b
iOS-SwiftUI-Widgets-WidgetControlon an iOS simulator✔️, it indicates ANR tracking is enabled.widget-control-after.mov
Testing - Live Activities
Live Activities are displayed differently on different devices, so I recommend you use an iPhone 16 Pro with an dynamic island to see it there too.
IMPORTANT:
During testing I experience multiple times that Live Activities were not started properly, with the push notification token never showing up. Further investigation showed that the live activity is actually a separate process which is called
WidgetRenderer_Activitiesin combination withchronod. During compile-time some of the extensions seemed to perform only partial rebuilds, causing theses processes to not being able to unarchive the live activities.Furthermore, live activities can be considered special kinds of widgets, therefore they are in the same kind of app extension.
Before:
.widgetfrom the disabled app hang types in theSentryExtensionDetectorsentry-cocoa/Sources/Sentry/SentryBaseIntegration.m
Lines 136 to 140 in 3a3d93b
iOS-SwiftUI-Widgetson an iOS simulatorlive-activity-before.mov
After:
.widgetis in the list of disabled app hang types in theSentryExtensionDetectorlive-activity-after.mov