Skip to content

feat: Hang tracker using runloop observer#7464

Merged
philprime merged 11 commits intomainfrom
hangTrackerAbstraction2
Feb 27, 2026
Merged

feat: Hang tracker using runloop observer#7464
philprime merged 11 commits intomainfrom
hangTrackerAbstraction2

Conversation

@noahsmartin
Copy link
Copy Markdown
Contributor

@noahsmartin noahsmartin commented Feb 15, 2026

Converts the watchdog tracker to use a runloop observer. This avoids a CADisplayLink constantly spinning the main runloop. The hang tracker class is generic enough to be used for other use cases that are currently using display links.

Closes #7470

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 15, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • Hang tracker using runloop observer by noahsmartin in #7464

Bug Fixes 🐛

  • (profiling) Remove launch profiling logs in sandboxed environments breaking CLI tools by philprime in #7294
  • Preserve NSException reason over unrelated crash_info_message by philprime in #7515

Documentation 📚

  • (ci) Add Cirrus Labs runner documentation by itaybre in #7522
  • Deprecate CocoaPods support in README by itaybre in #7526

Internal Changes 🔧

  • (ci) Update CI configurations to use runner concurrency groups by itaybre in #7511
  • Don't swiftlint generated sample code by 43jay in #7524
  • Remove unused .oclint config by philipphofmann in #7542
  • Remove unused .nvmrc by philipphofmann in #7540
  • Remove empty .gitmodules file by philipphofmann in #7538

Other

  • Fix optional chaining for window property access by benjaminpeters in #7508

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 15, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against c850e00

@noahsmartin noahsmartin force-pushed the hangTrackerAbstraction2 branch from 5d87757 to 504fe19 Compare February 15, 2026 02:28
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 93.60000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.923%. Comparing base (b1994b3) to head (c850e00).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...SentryWatchdogTerminationTrackingIntegration.swift 83.333% 5 Missing ⚠️
Sources/Swift/HangTracker.swift 96.774% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7464       +/-   ##
=============================================
+ Coverage   85.272%   85.923%   +0.650%     
=============================================
  Files          479       480        +1     
  Lines        28620     28742      +122     
  Branches     12444     12504       +60     
=============================================
+ Hits         24405     24696      +291     
+ Misses        4168      3998      -170     
- Partials        47        48        +1     
Files with missing lines Coverage Δ
Sources/Swift/SentryDependencyContainer.swift 97.183% <100.000%> (+0.013%) ⬆️
Sources/Swift/SentryExperimentalOptions.swift 80.000% <100.000%> (+5.000%) ⬆️
Sources/Swift/HangTracker.swift 96.774% <96.774%> (ø)
...SentryWatchdogTerminationTrackingIntegration.swift 87.500% <83.333%> (-1.631%) ⬇️

... and 13 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 b1994b3...c850e00. Read the comment docs.

@noahsmartin noahsmartin added the ready-to-merge Use this label to trigger all PR workflows label Feb 15, 2026
@noahsmartin noahsmartin force-pushed the hangTrackerAbstraction2 branch 5 times, most recently from 4c15468 to 9804e83 Compare February 15, 2026 03:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 15, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1219.84 ms 1244.64 ms 24.80 ms
Size 24.14 KiB 1.12 MiB 1.09 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
f38f4e9 1221.50 ms 1242.64 ms 21.14 ms
d69379c 1211.30 ms 1234.77 ms 23.47 ms
2d59844 1208.98 ms 1245.25 ms 36.27 ms
1357911 1222.84 ms 1258.38 ms 35.54 ms
b984142 1222.18 ms 1257.77 ms 35.59 ms
aa58669 1218.51 ms 1258.55 ms 40.04 ms
5ca545a 1219.06 ms 1244.59 ms 25.53 ms
3bf0d3f 1202.12 ms 1237.23 ms 35.11 ms
93ef486 1220.22 ms 1244.96 ms 24.74 ms
fee8669 1220.50 ms 1231.84 ms 11.34 ms

App size

Revision Plain With Sentry Diff
f38f4e9 24.14 KiB 1.10 MiB 1.07 MiB
d69379c 24.14 KiB 1.11 MiB 1.09 MiB
2d59844 24.14 KiB 1.09 MiB 1.06 MiB
1357911 24.14 KiB 1.07 MiB 1.04 MiB
b984142 24.14 KiB 1.11 MiB 1.09 MiB
aa58669 24.14 KiB 1.10 MiB 1.07 MiB
5ca545a 24.14 KiB 1.06 MiB 1.04 MiB
3bf0d3f 24.14 KiB 1.04 MiB 1.02 MiB
93ef486 24.14 KiB 1.06 MiB 1.04 MiB
fee8669 24.14 KiB 1.10 MiB 1.08 MiB

Previous results on branch: hangTrackerAbstraction2

Startup times

Revision Plain With Sentry Diff
80dcd49 1215.90 ms 1248.20 ms 32.30 ms
9381615 1199.08 ms 1229.09 ms 30.01 ms
29c1d77 1224.26 ms 1260.20 ms 35.94 ms
c7d530c 1221.96 ms 1259.06 ms 37.11 ms
3488362 1205.75 ms 1244.83 ms 39.08 ms
052a331 1226.04 ms 1263.20 ms 37.16 ms
1ea2069 1224.09 ms 1255.49 ms 31.40 ms
555ec8a 1227.52 ms 1260.31 ms 32.78 ms
a286479 1227.00 ms 1259.46 ms 32.46 ms
c961e27 1212.32 ms 1252.95 ms 40.64 ms

App size

Revision Plain With Sentry Diff
80dcd49 24.14 KiB 1.12 MiB 1.10 MiB
9381615 24.14 KiB 1.12 MiB 1.09 MiB
29c1d77 24.14 KiB 1.12 MiB 1.09 MiB
c7d530c 24.14 KiB 1.12 MiB 1.10 MiB
3488362 24.14 KiB 1.12 MiB 1.09 MiB
052a331 24.14 KiB 1.12 MiB 1.09 MiB
1ea2069 24.14 KiB 1.12 MiB 1.09 MiB
555ec8a 24.14 KiB 1.12 MiB 1.09 MiB
a286479 24.14 KiB 1.12 MiB 1.10 MiB
c961e27 24.14 KiB 1.12 MiB 1.10 MiB

Comment thread Sources/Swift/HangTracker.swift
@noahsmartin noahsmartin force-pushed the hangTrackerAbstraction2 branch 2 times, most recently from d96e106 to 7bc3d16 Compare February 17, 2026 00:56
Comment thread Sources/Swift/HangTracker.swift
Comment thread Sources/Swift/HangTracker.swift
Comment thread Sources/Swift/SentryDependencyContainer.swift Outdated
Comment thread Sources/Swift/HangTracker.swift
Comment thread Sources/Swift/HangTracker.swift
@philipphofmann
Copy link
Copy Markdown
Member

@noahsmartin, as the PR description states WIP, I converted this to a draft PR so it clearly signals it's not ready for review. Feel free to make it ready for review once it's ready 😃

@philipphofmann philipphofmann marked this pull request as draft February 17, 2026 09:04
@noahsmartin noahsmartin marked this pull request as ready for review February 17, 2026 15:29
@philipphofmann
Copy link
Copy Markdown
Member

@cursoragent review

@philipphofmann
Copy link
Copy Markdown
Member

@claude review

@cursor

This comment was marked as outdated.

Comment thread Sources/Swift/HangTracker.swift
@noahsmartin noahsmartin force-pushed the hangTrackerAbstraction2 branch from 32d11ec to 873f1aa Compare February 17, 2026 16:10
Comment thread Sources/Swift/HangTracker.swift
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copilot AI review requested due to automatic review settings February 24, 2026 18:36
@noahsmartin noahsmartin force-pushed the hangTrackerAbstraction2 branch from 66a955f to 27df776 Compare February 24, 2026 18:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/Swift/SentryDependencyContainer.swift Outdated
Comment thread Sources/Swift/HangTracker.swift
Comment thread Sources/Swift/HangTracker.swift
Comment thread Tests/SentryTests/Integrations/ANR/HangTrackerTests.swift
Comment thread Sources/Swift/HangTracker.swift Outdated
Comment thread Sources/Swift/HangTracker.swift Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread Tests/SentryTests/Integrations/ANR/HangTrackerTests.swift Outdated
Comment thread Tests/SentryTests/Integrations/ANR/HangTrackerTests.swift Outdated
Copilot AI review requested due to automatic review settings February 25, 2026 01:42
@noahsmartin noahsmartin force-pushed the hangTrackerAbstraction2 branch from 5530258 to a324e68 Compare February 25, 2026 01:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/Swift/HangTracker.swift
Comment thread Tests/SentryTests/Integrations/ANR/HangTrackerTests.swift Outdated
Comment thread Tests/SentryTests/Integrations/ANR/HangTrackerTests.swift Outdated
Comment thread Tests/SentryTests/Integrations/ANR/HangTrackerTests.swift Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the [Cursor dashboard](https://www.cursor.com/dashboard?tab=bugbot).

Comment thread Tests/SentryTests/Integrations/ANR/HangTrackerTests.swift Outdated
Comment thread Tests/SentryTests/Integrations/ANR/HangTrackerTests.swift Outdated
@noahsmartin noahsmartin force-pushed the hangTrackerAbstraction2 branch from a324e68 to 1c6a7f6 Compare February 25, 2026 02:19
Copy link
Copy Markdown
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

@noahsmartin please review and resolve all open comments so we can merge it. I am uncertain which ones you already addressed

Copy link
Copy Markdown
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

LGTM, it's experimental now so we can iterate on it 👍 Thank you for tackling this. I'll add the CHANGELOG.md and update the public API json so we can get this done

@philprime philprime enabled auto-merge (squash) February 27, 2026 10:01
@philprime philprime merged commit 5dcea74 into main Feb 27, 2026
209 checks passed
@philprime philprime deleted the hangTrackerAbstraction2 branch February 27, 2026 11:23
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.

feat: Hang tracker using runloop observer

5 participants