-
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
Improve background behavior (timers, refreshes, control center) #182
Comments
Our background behavior is probably sub-optimal, as the detailed feedback from one of our users seems to confirm. We should probably:
In particular, there is no need for too many now playing info refreshes, as the player is able to infer the playback position based on the player rate. See WWDC 501 for more information. |
We should rewrite our control center implementation so that changes are minimized. In doing so, we should use the new API available on iOS 12 and tvOS, see #176. |
To minimize the need for control center updates, it suffices to provide rate information so that the device can guess the current playback position, based on the last position it was provided. This information can only be updated when playback state changes, or simply when the rate changes, which should be sufficient for the system to properly interpolate positions. This works fine for on-demand streams, but is tricky for DVR streams whose window changes and should be updated every now and then. We should find a way to have this need covered, while still avoiding unnecessary updates keeping activity in background unnecessarily. Here is an idea:
If done correctly, the associated background activity can probably be eliminated. Some updates will probably not occur for paused DVR streams while the app is inactive, but this a small price to pay to reduce background activity to a minimum. Another idea would be to have periodic time observers implemented using
The advantage of keeping our time observers is that they are associated with the controller and will not die with Letterbox view and controller can then also listen to these changes, which might help us in completely eliminating their periodic time observers. |
SRG Media Player was updated to reduce the need for periodic observers. These can now be eliminated in most cases where constant monitoring of playback is not required, replaced with either notifications or KVO. Most The answer might be delivered by #181. Doing the same as for
|
Here is a procedure to hopefully reliably compare battery usage of various Letterbox versions:
Such a run provides battery drain rate in mAh / h as well as a matching trace for Instruments. It should be repeated with Letterbox versions to compare (attempting to start with similar mAh values by charging the device again first), as well as the following content types:
Following setups should be investigated:
|
Forum VOD, 1h foreground playback, screen always on at min brightness, iPhone 7:
Forum AOD, 1h foreground playback, screen locked, iPhone 7:
|
One behavior that should be monitored more closely: What is the system reported background activity for a paused livestream / on-demand stream? |
A vanilla application (with no use of audio) will stop
NSTimer
s when the application is sent to the background.If audio is playing, if the application has the background audio capability enabled, and if the audio session is properly configured to
AVAudioSessionCategoryPlayback
, timers will not be paused when the application is sent to the background.As we are using several timers in Letterbox (e.g. for analytics heartbeat purposes), and since we have recently removed audio session management entirely, it would be very interesting to have a look at Letterbox behavior in general, especially in long-running background sessions.
The text was updated successfully, but these errors were encountered: