-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop timers in background #199
Comments
It is possible to KV-observe the This is probably an excellent approach. |
Most of the involved work must be made in SRG Media Player, for which I created a dedicated issue. |
I updated the following libraries on
For most of them, I only added a tolerance to timers by default (in all cases, we have no strict requirement about the execution timing and can let the system optimize timer execution). |
Time updates (e.g. slider range) are more demanding for DVR streams than for on-demand ones, since the start and end window times change continuously. Previously, we were refreshing control center time range information with each chunk. Since partial I removed such updates. With each Letterbox metadata periodic update, the information will be refreshed anyway. This greatly improves the activity profile of Letterbox and should therefore have a positive energy impact. |
This is a follow-up of issue #182. Though some work has already been done to reduce background activity, there is a remaining issue with timers.
We do not use
AVPlayer
time observers in SRG Media Player so that updates are also received when playback is paused (mostly for DVR streams with a sliding window). We useNSTimer
instead, but those are still active in background, unlike periodic time observers that are smarter:They are not active in background if no playback is active.(Actually this is the same forNSTimer
. If the app is sent to the background timers are suspended. An exception is if background audio is enabled and a content is being played, which is exactly like periodic time observers)I currently see two possibilities to solve this issue:
AVPlayer
time observers.In all cases, it might still be helpful to have a timer class which automatically pauses and resumes updates when the app moves to / from background. This way we could also eliminate all other background refreshes from Letterbox (e.g. metadata) and, more generally, from Play.
Such a timer could be part of another generic core library. We could also put common duplicate code there as well, offering a solution to #198.
The text was updated successfully, but these errors were encountered: