-
-
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
Draft
philprime
wants to merge
18
commits into
main
Choose a base branch
from
philprime/disable-live-activity-widgets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
|
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d1c4916 | 1216.66 ms | 1244.73 ms | 28.08 ms |
| d1c0538 | 1227.49 ms | 1246.96 ms | 19.47 ms |
| cc02c0d | 1234.69 ms | 1247.15 ms | 12.46 ms |
| 23b6a91 | 1227.73 ms | 1262.93 ms | 35.20 ms |
| ea2e54c | 1207.78 ms | 1218.13 ms | 10.35 ms |
| 6c0b61e | 1194.21 ms | 1218.74 ms | 24.53 ms |
| 83d27f6 | 1233.56 ms | 1259.24 ms | 25.68 ms |
| 1a34ddc | 1217.79 ms | 1242.17 ms | 24.38 ms |
| d05d866 | 1211.78 ms | 1230.96 ms | 19.18 ms |
| bc0a04c | 1226.83 ms | 1255.04 ms | 28.21 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d1c4916 | 23.75 KiB | 981.31 KiB | 957.56 KiB |
| d1c0538 | 23.75 KiB | 928.87 KiB | 905.12 KiB |
| cc02c0d | 23.75 KiB | 912.37 KiB | 888.62 KiB |
| 23b6a91 | 23.75 KiB | 1004.80 KiB | 981.06 KiB |
| ea2e54c | 23.75 KiB | 919.70 KiB | 895.95 KiB |
| 6c0b61e | 23.75 KiB | 1.02 MiB | 1019.10 KiB |
| 83d27f6 | 23.75 KiB | 928.88 KiB | 905.13 KiB |
| 1a34ddc | 23.75 KiB | 919.90 KiB | 896.15 KiB |
| d05d866 | 23.75 KiB | 878.60 KiB | 854.85 KiB |
| bc0a04c | 23.75 KiB | 933.32 KiB | 909.57 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 |
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 |
095f7a8 to
f8693fb
Compare
…e-activity-widgets
…e-activity-widgets
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 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