Skip to content

feat: Track low power mode in device context#7777

Merged
itaybre merged 5 commits intomainfrom
feat/low-power-mode-context
Apr 20, 2026
Merged

feat: Track low power mode in device context#7777
itaybre merged 5 commits intomainfrom
feat/low-power-mode-context

Conversation

@itaybre
Copy link
Copy Markdown
Contributor

@itaybre itaybre commented Apr 6, 2026

Summary

  • Adds low_power_mode boolean to the device context, available on all event types
  • Observes NSProcessInfoPowerStateDidChangeNotification in SentryCrashIntegration to keep the scope's device context in sync, ensuring the value is persisted for crashes and watchdog terminations
  • Also reads the value at capture time in SentryExtraContextProvider for non-crash events
  • Gated with @available(macOS 12.0, *) since the macOS deployment target is 10.14; available unconditionally on iOS, tvOS, watchOS, and visionOS

Test plan

  • Added testLowPowerMode and testLowPowerModeDisabled tests for SentryExtraContextProvider
  • All existing SentryExtraContextProviderTests pass
  • All existing SentryCrashIntegrationTests pass (31 tests)
  • Builds successfully on iOS and macOS

Fixes: #5322

Add `low_power_mode` boolean to the device context so it's
available on all event types including crashes and watchdog
terminations. The value is kept in sync via the
NSProcessInfoPowerStateDidChange notification on the scope,
and also read at capture time in SentryExtraContextProvider.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 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 ✨

  • 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
  • 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 2026

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

Generated by 🚫 dangerJS against 0fced7d

@itaybre itaybre added the ready-to-merge Use this label to trigger all PR workflows label Apr 6, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 6, 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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 6, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.150%. Comparing base (3c74b55) to head (0fced7d).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...egrations/SentryCrash/SentryCrashIntegration.swift 77.419% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7777       +/-   ##
=============================================
- Coverage   85.437%   85.150%   -0.287%     
=============================================
  Files          487       487               
  Lines        29226     29261       +35     
  Branches     12645     12650        +5     
=============================================
- Hits         24970     24916       -54     
- Misses        4206      4294       +88     
- Partials        50        51        +1     
Files with missing lines Coverage Δ
...Utils/Sources/TestSentryNSProcessInfoWrapper.swift 90.000% <100.000%> (+1.111%) ⬆️
...rces/Swift/Helper/SentryExtraContextProvider.swift 100.000% <100.000%> (ø)
Sources/Swift/Helper/SentryProcessInfo.swift 34.615% <ø> (-57.693%) ⬇️
...egrations/SentryCrash/SentryCrashIntegration.swift 93.529% <77.419%> (-3.593%) ⬇️

... and 11 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 3c74b55...0fced7d. Read the comment docs.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1221.47 ms 1259.00 ms 37.53 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: feat/low-power-mode-context

Startup times

Revision Plain With Sentry Diff
adab352 1228.71 ms 1262.20 ms 33.50 ms
bda24a3 1228.45 ms 1258.63 ms 30.18 ms

App size

Revision Plain With Sentry Diff
adab352 24.14 KiB 1.13 MiB 1.11 MiB
bda24a3 24.14 KiB 1.13 MiB 1.11 MiB

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 with some additional comments to consider

Comment thread Sources/Swift/Helper/SentryExtraContextProvider.swift
Comment thread Sources/Swift/Integrations/SentryCrash/SentryCrashIntegration.swift Outdated
@itaybre itaybre enabled auto-merge (squash) April 20, 2026 19:09
@itaybre itaybre merged commit 77a335b into main Apr 20, 2026
206 of 208 checks passed
@itaybre itaybre deleted the feat/low-power-mode-context branch April 20, 2026 19:16
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.

Detect low power mode

2 participants