Last segment doesn't get appended at times if we seek
Created by: KarishmaBagga
Version: 2.0
Steps to repro:
- URL used: http://demo.unified-streaming.com/video/ateam/ateam.ism/ateam.mpd
- If user keeps seeking (its a race condition so the number of seeks required to repro is not deterministic), at times last segment never gets appended
Analysis:
Below are the logs. I added log lines: onMediaFragmentLoaded and Appending in BufferController.js for mediaType 'video' only.
[502994] onMediaFragmentLoaded: 0 quality: 0 Debug.js:108 [503008] Appending: 0 quality: 0 Debug.js:108 [504940] onMediaFragmentLoaded: 1 quality: 0 Debug.js:108 [504950] Appending: 1 quality: 0 Debug.js:108 [509215] onMediaFragmentLoaded: 2 quality: 3 Debug.js:108 [509581] Appending: NaN quality: 3 Debug.js:108 [509591] Appending: 2 quality: 3 Debug.js:108 [509823] Requesting seek to time: 47.41 Debug.js:108 [509831] Seeking to: 47.41 Debug.js:108 [512437] onMediaFragmentLoaded: 3 quality: 3 Debug.js:108 [512446] Appending: 3 quality: 3 Debug.js:108 [515688] onMediaFragmentLoaded: 11 quality: 0 Debug.js:108 [515703] Appending: NaN quality: 0 Debug.js:108 [515725] Appending: 11 quality: 0 Debug.js:108 [516145] Native video element event: seeked Debug.js:108 [516681] onMediaFragmentLoaded: 13 quality: 0 Debug.js:108 [516693] Appending: 13 quality: 0 Debug.js:108 [517302] onMediaFragmentLoaded: 12 quality: 0 Debug.js:108 [517316] Appending: 12 quality: 0 Debug.js:108 [517836] onMediaFragmentLoaded: 14 quality: 0 Debug.js:108 [517851] Appending: 14 quality: 0 Debug.js:108 [519118] onMediaFragmentLoaded: 16 quality: 0 Debug.js:108 [519138] Appending: 16 quality: 0 Debug.js:108 [519249] onMediaFragmentLoaded: 15 quality: 0 Debug.js:108 [519266] Appending: 15 quality: 0 Debug.js:108 [520313] Requesting seek to time: 72.33 Debug.js:108 [520327] Seeking to: 72.33 Debug.js:108 [521650] onMediaFragmentLoaded: 17 quality: 0 Debug.js:108 [521667] Appending: 17 quality: 0 Debug.js:108 [522592] Requesting seek to time: 47.21 Debug.js:108 [522605] Seeking to: 47.21 Debug.js:108 [524832] Native video element event: seeked Debug.js:108 [524887] onMediaFragmentLoaded: 19 quality: 0 Debug.js:108 [524897] Appending: 19 quality: 0 Debug.js:108 [524909] onMediaFragmentLoaded: 18 quality: 0 Debug.js:108 [539086] Requesting seek to time: 78.2 Debug.js:108 [539091] Seeking to: 78.2 Debug.js:108 [540230] Native video element event: seeked Debug.js:108 [540269] onMediaFragmentLoaded: 18 quality: 0 Debug.js:108 [540279] Appending: 18 quality: 0 Debug.js:108 [543867] onMediaFragmentLoaded: 20 quality: 1 Debug.js:108 [543885] Appending: 18 quality: 0 Debug.js:108 [546259] onMediaFragmentLoaded: 21 quality: 0 Debug.js:108 [546720] Appending: NaN quality: 0 Debug.js:108 [546734] Appending: NaN quality: 1 Debug.js:108 [546751] Appending: 20 quality: 1 Debug.js:108 [548359] onMediaFragmentLoaded: 22 quality: 0 Debug.js:108 [548376] Appending: NaN quality: 0 Debug.js:108 [548409] Appending: 21 quality: 0 Debug.js:108 [550172] onMediaFragmentLoaded: 23 quality: 0 Debug.js:108 [550186] Appending: 22 quality: 0 Debug.js:108 [551878] onMediaFragmentLoaded: 24 quality: 1 Debug.js:108 [551897] Appending: 23 quality: 0 Debug.js:108 [552224] onMediaFragmentLoaded: 25 quality: 1 Debug.js:108 [552242] Appending: NaN quality: 1 Debug.js:108 [552273] Appending: 24 quality: 1
Ideally the expected scheduling-appending loop is append-what-was-loaded. To achieve this we have the lock isFragmentLoading which allows only one segment to be loaded at a time. Now in ScheduleController:onPlaybackSeeking, we set isFragmentLoading as false - allowing 2 segments to be loaded simultaneously. In such a case we break our append-what-was-loaded logic and go one behind...on onMediaFragmentLoaded we append what we loaded before this segment. As we see towards the end, fragment 25 was loaded but we go one behind and it never gets appended.