Skip to content

fix: Add foreground state to app context in app hang events#7801

Merged
denrase merged 6 commits intomainfrom
fix/app-hang-foreground-context
Apr 21, 2026
Merged

fix: Add foreground state to app context in app hang events#7801
denrase merged 6 commits intomainfrom
fix/app-hang-foreground-context

Conversation

@denrase
Copy link
Copy Markdown
Collaborator

@denrase denrase commented Apr 14, 2026

📜 Description

Set app.in_foreground and app.is_active when creating new app hang events in SentryHangTrackingIntegration, so persisted and fatal app hangs always carry the expected foreground context.

💡 Motivation and Context

Closes #5725

💚 How did you test it?

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

Set app.in_foreground and app.is_active when creating new app hang events in SentryHangTrackingIntegration, so persisted and fatal app hangs always carry the expected foreground context.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 14, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 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 ✨

  • Track low power mode in device context by itaybre in #7777

Bug Fixes 🐛

  • (breadcrumbs) Unsubscribe to system event during background to avoid reporting breadcrumbs with wrong timestamps on return to foreground by denrase in #7803
  • (replay) Keep replayType as buffer for Session Replay triggered by an error by romtsn in #7804
  • Add foreground state to app context in app hang events by denrase in #7801
  • Copy mutable collections before passing to scope observers by antonis in #7807
  • Detect development builds via provisioning profile entitlement by denrase in #7702

Internal Changes 🔧

Deps

  • Bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.25.2 to 2.25.4 by dependabot in #7811
  • Bump actions/create-github-app-token from 3.0.0 to 3.1.1 by dependabot in #7812
  • Bump ruby/setup-ruby from 1.299.0 to 1.302.0 by dependabot in #7813
  • Bump peter-evans/create-pull-request from 8.1.0 to 8.1.1 by dependabot in #7791
  • Bump actions/upload-artifact from 7.0.0 to 7.0.1 by dependabot in #7790
  • Bump actions/upload-pages-artifact from 4.0.0 to 5.0.0 by dependabot in #7789
  • Bump actions/github-script from 8.0.0 to 9.0.0 by dependabot in #7793

🤖 This preview updates automatically when you update the PR.

@denrase denrase marked this pull request as ready for review April 14, 2026 13:01
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.441%. Comparing base (77a335b) to head (5aa0212).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7801       +/-   ##
=============================================
+ Coverage   85.434%   85.441%   +0.007%     
=============================================
  Files          487       487               
  Lines        29261     29269        +8     
  Branches     12671     12658       -13     
=============================================
+ Hits         24999     25008        +9     
+ Misses        4212      4210        -2     
- Partials        50        51        +1     
Files with missing lines Coverage Δ
...t/Integrations/SentryHangTrackingIntegration.swift 93.661% <100.000%> (+0.378%) ⬆️

... 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 77a335b...5aa0212. Read the comment docs.

Comment thread CHANGELOG.md Outdated
@itaybre itaybre added the ready-to-merge Use this label to trigger all PR workflows label Apr 20, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 20, 2026

📲 Install Builds

iOS

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

⚙️ sentry-cocoa Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1216.88 ms 1248.04 ms 31.17 ms
Size 24.14 KiB 1.13 MiB 1.11 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0e4b033 1203.74 ms 1249.71 ms 45.97 ms
bbee1ba 1197.79 ms 1215.42 ms 17.63 ms
59981b9 1207.25 ms 1240.71 ms 33.46 ms
64a365a 1225.60 ms 1255.49 ms 29.89 ms
93d7fdf 1225.77 ms 1259.79 ms 34.02 ms
e03f459 1222.56 ms 1255.94 ms 33.37 ms
ffac605 1217.10 ms 1256.91 ms 39.81 ms
2f4ddaa 1227.26 ms 1260.04 ms 32.78 ms
778dadf 1207.69 ms 1246.09 ms 38.40 ms
daf8b80 1233.78 ms 1259.44 ms 25.66 ms

App size

Revision Plain With Sentry Diff
0e4b033 24.14 KiB 1.11 MiB 1.09 MiB
bbee1ba 24.14 KiB 1.11 MiB 1.09 MiB
59981b9 24.14 KiB 1.09 MiB 1.06 MiB
64a365a 24.14 KiB 1.09 MiB 1.06 MiB
93d7fdf 24.14 KiB 1.11 MiB 1.08 MiB
e03f459 24.14 KiB 1.11 MiB 1.09 MiB
ffac605 24.14 KiB 1.13 MiB 1.10 MiB
2f4ddaa 24.14 KiB 1.04 MiB 1.02 MiB
778dadf 24.14 KiB 1.04 MiB 1.02 MiB
daf8b80 24.14 KiB 1.11 MiB 1.09 MiB

Previous results on branch: fix/app-hang-foreground-context

Startup times

Revision Plain With Sentry Diff
b5960db 1214.80 ms 1250.19 ms 35.40 ms

App size

Revision Plain With Sentry Diff
b5960db 24.14 KiB 1.13 MiB 1.11 MiB

@denrase denrase changed the title fix: Ensure app hangs have foreground app context fix: Add foreground state to app context in app hang events Apr 21, 2026
denrase and others added 3 commits April 21, 2026 10:33
Co-authored-by: Philip Niedertscheider <phil.niedertscheider@sentry.io>
…y/sentry-cocoa into fix/app-hang-foreground-context
@denrase denrase enabled auto-merge (squash) April 21, 2026 08:34
@denrase denrase merged commit 7b14762 into main Apr 21, 2026
206 of 208 checks passed
@denrase denrase deleted the fix/app-hang-foreground-context branch April 21, 2026 08:54
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.

Ensure app hangs have is_foreground true

3 participants