Skip to content

fix: Disable app hang and watchdog termination tracking in Notification Service Extensions#7818

Merged
itaybre merged 9 commits into
mainfrom
fix/nse-app-hang-watchdog-disabled
Apr 29, 2026
Merged

fix: Disable app hang and watchdog termination tracking in Notification Service Extensions#7818
itaybre merged 9 commits into
mainfrom
fix/nse-app-hang-watchdog-disabled

Conversation

@itaybre

@itaybre itaybre commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds notificationService (com.apple.usernotifications.service) to SentryExtensionType and to the list of extension types where app hang tracking is disabled
  • Adds an extension detection guard to SentryWatchdogTerminationTrackingIntegration.init (it was the only integration missing this check)
  • Adds tests for all new behaviour in SentryExtensionTypeTests, SentryHangTrackingIntegrationTests, and SentryWatchdogTerminationTrackingIntegrationTests

Fixes #7808

Details

Notification Service Extensions have no user-facing run loop, so they should behave like widgets/intents/actions/share extensions and not run app hang or watchdog termination tracking. Two gaps existed:

  1. SentryExtensionDetector.disabledAppHangTypes did not include com.apple.usernotifications.service, so SentryHangTrackingIntegration would install itself inside an NSE.
  2. SentryWatchdogTerminationTrackingIntegration performed no extension check at all, unlike every other hang-related integration.

Both issues caused Sentry's own internal work (battery-state breadcrumb I/O, JSON serialisation) on the main thread to be flagged as fatal hangs in NSE processes.

How Tested

  • Ran SentryExtensionTypeTests, SentryHangTrackingIntegrationTests/testInstall_runningInNotificationServiceExtension_shouldNotInstall, and the three new SentryWatchdogTerminationIntegrationTests — all pass.

Checklist

  • I reviewed the code
  • Added tests

@itaybre itaybre added the ready-to-merge Use this label to trigger all PR workflows label Apr 21, 2026
@sentry

sentry Bot commented Apr 21, 2026

Copy link
Copy Markdown

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.11.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.471%. Comparing base (434f72a) to head (1c6eb87).
⚠️ Report is 12 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7818       +/-   ##
=============================================
+ Coverage   85.443%   85.471%   +0.027%     
=============================================
  Files          487       487               
  Lines        29327     29335        +8     
  Branches     12678     12679        +1     
=============================================
+ Hits         25058     25073       +15     
+ Misses        4219      4212        -7     
  Partials        50        50               
Files with missing lines Coverage Δ
Sources/Swift/Helper/SentryExtensionDetector.swift 73.529% <100.000%> (+0.802%) ⬆️
Sources/Swift/Helper/SentryExtensionType.swift 100.000% <100.000%> (ø)
...SentryWatchdogTerminationTrackingIntegration.swift 88.311% <100.000%> (+0.811%) ⬆️

... and 5 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 434f72a...1c6eb87. Read the comment docs.

@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1223.31 ms 1264.77 ms 41.45 ms
Size 24.14 KiB 1.13 MiB 1.11 MiB

@philprime philprime left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe we have sample notification extensions for all the other cases. Can you create one for this case too?

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ac8a2d2. Configure here.

Comment thread Sources/Swift/Helper/SentryExtensionDetector.swift
@itaybre itaybre enabled auto-merge (squash) April 28, 2026 17:27

@philprime philprime left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, tested using the Push Notification Console and a device token on a real device. Sentry is triggered and the event is sent

@itaybre itaybre merged commit c958e9d into main Apr 29, 2026
208 of 209 checks passed
@itaybre itaybre deleted the fix/nse-app-hang-watchdog-disabled branch April 29, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App Hang and Watchdog Termination tracking should be disabled in Notification Service Extensions

2 participants