PlaybackController seeking after playback started on slow devices causing glitch
Created by: fvalleeHbbTV
Environment
-
The MPD passes the DASH-IF Conformance Tool on http://dashif.org/conformance.html -
The stream has correct Access-Control-Allow-Origin headers (CORS) -
There are no network errors such as 404s in the browser console when trying to play the stream -
The issue observed is not mentioned on https://github.com/Dash-Industry-Forum/dash.js/wiki/FAQ -
The issue occurs in the latest reference client on http://reference.dashif.org/dash.js/ and not just on my page
- Link to playable MPD file: https://dash.akamaized.net/dash264/TestCases/1a/sony/SNE_DASH_SD_CASE1A_REVISED.mpd
- Dash.js version: 2.8.0 (or older)
- Browser name/version: chromium
- OS name/version: linux
Steps to reproduce
Start playback (autoplay) using a static mpd (SNE_DASH_SD_CASE1A_REVISED from the ref player) Playback starts (a few ms) then restart at 0 (then works fine). There could be a noticeable audio/video glitch due to the seek (depends of performances / media).
It can't be reproduced using a regular computer - issue is timing/performance related (maybe x86 can be slowed down to reproduce). Issue reproduced with several mpd.
This is an issue with the Playback controller. If the device is a little bit (or very) slow, the onBytesAppended callback (BYTES_APPENDED_END_FRAGMENT event) can be processed after the start of playback . Please refer to logs : logs.txt
"Requesting seek to time: 0" in logs comes from https://github.com/Dash-Industry-Forum/dash.js/blob/378bcf564d2775795af444fb69a365875ea2e8d5/src/streaming/controllers/PlaybackController.js#L667
When one video and one audio segment have been appended, the playback controller is seeking to the common earlier time. Usually (x86), this is processed BEFORE playback starts (=playing event) but if the device is slow it can be after : "[PlaybackController] Native video element event: playing " in the attached logs is ~150ms before the seek (but I've seen cases where 'playing' is ~500ms before the seek).
I guess the seek could be skipped in some cases or the play() called in the PlaybackController::initialize() function could be delayed but it seems a bit tricky. As usual, any comment or feedback welcome. Thanks!