Detect low power mode
Problem Statement
Particularly for performance related issues it would be helpful to see in the issue context if the device was in low power mode. Additionally low power mode state changes could be a useful breadcrumb
Solution Brainstorm
Seems pretty straightforward to get the data: https://developer.apple.com/documentation/foundation/processinfo/islowpowermodeenabled
just not sure how it would be piped through
Are you willing to submit a PR?
No response
I guess I never created an issue for this before when we built profiling metrics (cpu, memory, energy usage) but i had a list of similar ones in a private notion doc: thermal/power-mode/memory-pressure state changes.
This would be cool to add to those profiling metrics we already gather, record the timestamps of state changes as breadcrumbs, or some other kind of event/marker.
The app context would be the place to go
https://github.com/getsentry/sentry-cocoa/blob/f96ab191e62125a645c846318e73eb96dc0a5794/Sources/Sentry/SentryClient.m#L736-L747
But the logic in the client only works for non-crash events. For crash events, we would need to store that information somewhere. We can't access that information when we're crashing, so we would need to subscribe to NSProcessInfoPowerStateDidChangeNotification and store that info on the context of the scope, which then serializes that info to SentryCrash via SentryCrashScopeObserver could do the trick.
The SentryCrashWrapper creates the initial app context and puts it to the scope, but that's only for scope that doesn't change:
https://github.com/getsentry/sentry-cocoa/blob/f96ab191e62125a645c846318e73eb96dc0a5794/Sources/Sentry/SentryCrashWrapper.m#L201-L214
When adding this to the app context we should consider if we want to have this indexed (in Sentry) so that it is possible to find issues caused by low power mode (not happening by default).