Youtube enters infinite buffering after seeking back to the start position
Categories
(Core :: Audio/Video: Playback, defect, P1)
Tracking
()
People
(Reporter: alwu, Assigned: alwu)
References
(Blocks 1 open bug)
Details
Attachments
(3 files)
This issue is reproducible on my Firefox Release 127 and Nightly 129 on Windows 11.
STR. (reproduce steps video)
- go to https://www.youtube.com/watch?v=fCO7f0SmrDc
- start video in 4K resolution
- seek to the place near the end of buffered range many times, until video buffered range reaches to the end
- seek back to the start position
Expected.
5. video keeps playing and shows the correct current time
Actual.
5. video's current time stuck at 0.00 (or 1.00 depends on where you seek to) and the buffered range won't keep growing. So video enters infinite buffering when reaching the end of buffering.
Here is the media profile I captured on the latest Nightly on Windows 11.
Assignee | ||
Comment 1•8 months ago
|
||
In addition, I found the reproduce steps video
in comment0 sometimes can't start playback successfully on my Firefox Release and Nightly on Windows 11, but that video can start without problem on Chrome. I've filed bug 1904938.
Assignee | ||
Comment 2•8 months ago
|
||
This seems to be an issue in Youtube player, when the buffer size is full, they would reload the entire resource (like bug 1760529) and then their player seems to have a problem to recognize the correct media current time so that the media time on the player won't be updated, so does the buffered range.
Assignee | ||
Comment 3•8 months ago
|
||
I'm still investigating this issue, maybe the problem is in our eviction logic. Will update more details after I figure out what happened.
Assignee | ||
Comment 4•8 months ago
•
|
||
From my observation, there are two problems, (1) on certain situation, our eviction algorithm fails after seeking back to the start position, which causes the buffered data won't be clear properly so that appending would raise an NS_ERROR_DOM_MEDIA_SOURCE_FULL_BUFFER_QUOTA_EXCEEDED_ERR
(2) when Youtube noticed that error, they would try to assign a new source buffer to the media element, which also happens in bug 1760529 as well. Youtube player seems not being able to handle this case properly, so it doesn't update the current time of the player and does not keep appending the data.
Assignee | ||
Comment 5•8 months ago
•
|
||
I've informed Youtube about this bug, and I will improve our eviction algorithm in this bug, and increase our video buffer size to 150 MB in bug 1760529.
Assignee | ||
Comment 6•8 months ago
|
||
I already have a patch for this problem, now I'm working on the test. Will post them once they're ready.
Assignee | ||
Comment 7•8 months ago
|
||
Assignee | ||
Comment 8•8 months ago
|
||
Depends on D215264
Assignee | ||
Comment 9•8 months ago
|
||
Depends on D215265
Assignee | ||
Updated•8 months ago
|
Assignee | ||
Comment 10•8 months ago
|
||
I'm going to write down the analysis of this bug for the future readers. First, this issue is caused by Youtube's player, they should handle the case of buffer full better via trimming the buffer themselves, instead of recreating a new media source. Even if they do so, they should update their player's logic better in order to keep the media time correct in order to append more data. We've reported this issue to Youtube, but no response so far.
My patches here are used to mitigate the buffer full issue by improving our eviction mechanism.
By following the STR mentioned in the comment 0. Before seeking back to the start position, the buffer has been almost full. The data eviction wasn't performed after seeking, so Youtube wasn't able to append more data. This is the problem I'm going to improve in this bug.
We update mEvictable
to know how many data is able to be evicted, and this only applies for the data before the given index, which means that it won't consider future data.
UpdateEvictionIndex()
would be called in multiple places. When we tried to seek to the start position, as the target is not in the buffered range yet, we won't call TrackBuffersManager::Seek()
with a given target time. The manager's seek would only be triggered by resetting the demuxer and that would make us set mNextGetSampleIndex
to the index of keyframe in the old buffered range, which is 0
. As evicting the past data, we always stop at key frame.
As I mentioned above, our eviction would only consider the data before the current index, this call would result in canEvict
will always be zero and nothing would be able to be evicted anymore because lastKeyFrameIndex
was actually the first key frame index, not the last index. But that would be a different story if the seek target is in the buffered range, then the eviction would work as expected.
Therefore, even if the seek target is not in the buffered range, we still need to be able to evict data successfully.
Updated•8 months ago
|
Updated•8 months ago
|
Updated•8 months ago
|
Comment 11•8 months ago
|
||
Comment 12•8 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/930ac66302d7
https://hg.mozilla.org/mozilla-central/rev/aa15765aa458
https://hg.mozilla.org/mozilla-central/rev/b9567c30bbbb
Assignee | ||
Updated•8 months ago
|
Updated•7 months ago
|
Comment 13•7 months ago
•
|
||
(In reply to Alastor Wu [:alwu] from comment #10)
As I mentioned above, our eviction would only consider the data before the current index, this call would result in
canEvict
will always be zero and nothing would be able to be evicted anymore becauselastKeyFrameIndex
was actually the first key frame index, not the last index. But that would be a different story if the seek target is in the buffered range, then the eviction would work as expected.
I'm not understanding how eviction would work differently if the seek target were in the buffered range. lastKeyFrameIndex
and canEvict
would still both be zero, right?
Updated•7 months ago
|
Assignee | ||
Comment 14•7 months ago
|
||
(In reply to Karl Tomlinson (:karlt) from comment #13)
I'm not understanding how eviction would work differently if the seek target were in the buffered range.
lastKeyFrameIndex
andcanEvict
would still both be zero, right?
If seek target is already in the buffered range, then website doesn't need to append more data so no eviction is needed. If seek can be completed, the data would be gradually evicted as the playback moves forward.
Comment 15•7 months ago
|
||
Does this need a Release uplift request?
Assignee | ||
Comment 16•7 months ago
|
||
No, it's not that serious. We can let it ride the train of Fx129.
Updated•7 months ago
|
Comment 17•7 months ago
|
||
I was able to reproduce it only one time on Win11x64 using FF build 129.0a1(20240626153712).
Could not reproduce it on Win11x64 using FF builds 129.0b8 and 130.0a1.
Updated•6 months ago
|
Description
•