Firefox drops huge amount of video frames on 4k+ videos with a longer keyframe interval
Categories
(Core :: Audio/Video: Playback, defect, P1)
Tracking
()
People
(Reporter: nycitykpop, Assigned: alwu)
References
(Blocks 1 open bug)
Details
(Whiteboard: [media-youtube])
Attachments
(6 files)
1.34 MB,
image/png
|
Details | |
24.38 KB,
text/plain
|
Details | |
1.40 MB,
image/png
|
Details | |
1.34 MB,
image/png
|
Details | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
Bug 1692881 - part2 : keep decoded video has at least same amount of duration as decoded audio data.
48 bytes,
text/x-phabricator-request
|
Details | Review |
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0
Steps to reproduce:
Go to YouTube.com
Play UHD 4K Video 1: https://www.youtube.com/watch?v=f0NdOE5GTgo
Play UHD 4K60FPS Video 2: https://www.youtube.com/watch?v=h3fUgOKFMNU
Play Newer UHD 4K60FPS Video 3: https://www.youtube.com/watch?v=ENnWAqufvCI
Actual results:
UHD 4K Video 1 plays fine.
UHD 4K60FPS Video 2 plays fine.
Newer UHD 4K60FPS Video 3 does not play correctly with over half of the frames dropping.
Expected results:
Video 3 should play correctly the same as Video 1 and 2.
Video 3 Freezes multiple times making the video unwatchable unless the video is downgraded to a lesser resolution.
The screenshot shows very fast network speed but over half the frames are dropping.
I have noticed this with other videos as well. It is not just this video.
I have noticed that video 2 is actually newer than video 3 and video 2 plays fine. So the problem is not the newness of the video but something else. They both seem to use the same codecs which makes this seem strange.
Comment 6•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Audio/Video: Playback' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Assignee | ||
Comment 7•3 years ago
|
||
I can reproduce this.
Thank God! I mean I am sorry for this problem, but I was worried it just might only be my system OS.
Reporter | ||
Comment 10•3 years ago
|
||
There are many other videos too not just this one.
I think most of the videos I saw like this seem to be recorded using the same type of device. I could be wrong, but most of them seem to be Kpop fancams which may be recorded using high-end 4K cell phones like the Samsung Galaxy S20 or late-model iPhones.
Reporter | ||
Comment 11•3 years ago
|
||
There is also the possibility that they could be using high-end cameras like RED.
Reporter | ||
Comment 12•3 years ago
|
||
The sideways full-screen recording may be a factor. I have noticed that this type of recording is increasingly becoming more and more popular.
Reporter | ||
Comment 13•3 years ago
|
||
Do you think this could be related to bug 1688947 ? - https://bugzilla.mozilla.org/show_bug.cgi?id=1688947
Assignee | ||
Comment 14•3 years ago
•
|
||
There are two problems,
(1) can we make decoding faster?
Bug 1688947 will probably help if we can utilize GPU as much as we can so that the speed of video decoding can catch up with the speed of playing audio. I noticed that watching same 4K video on Chrome would still cause a lot of dropped frames, but video can be played way more smoothly on Chrome.
Therefore, I think the most critical problem is next one.
(2) the mechanism of synchronizing audio and video
Those dropped video frames happened in VideoSink
where we do the sychronization for audio and video. However, at the time we presented them, they were late than current audio clock so that we dropped them.
By checking the log, you can see those time differences were accumulated from 12812 us
to 940583us
, we finally start another mechanism to skip to the next key frame until the time difference was large enough. However, within those period, we had already made video frozen for several seconds. (I think the improvement here should be doing that earlier) Even if we got new frames, we would also not display them immediately, because those video frames were beyond the current audio clock, so the frozen period was actully really long.
Improving this mechanism should make the result way better, and I need to think about what the best way is to do so.
Comment hidden (obsolete) |
Reporter | ||
Comment 16•3 years ago
|
||
I found another video with excessive frame drops:
https://www.youtube.com/watch?v=v-MW34KSOSM
Reporter | ||
Comment 17•3 years ago
|
||
Excessive frame drops: https://www.youtube.com/watch?v=v-MW34KSOSM
Reporter | ||
Comment 18•3 years ago
|
||
The second video (see screenshot) is from an entirely different channel and most likely filmed with a different device.
Reporter | ||
Comment 19•3 years ago
|
||
I am getting about 5 to 10% frame drops on Linus Tech Tips 4K videos now. I have the new experimental WebAPI: WebGPU enabled. https://www.youtube.com/watch?v=eS4bNKLxEL0
Assignee | ||
Comment 20•3 years ago
|
||
Per comment14, as this issue is related with the mechanism of synchronizing audio and video, which is not easy to be modified. We might need a full evaluation about that design before doing any modification, which won't happen soon. Sorry about that.
In addition, as this issue won't happen on all 4K videos and the workaround for users exists, which is to watch video with lower resolution. So I'm going to change the severity of this bug to S3.
(In reply to Jeffrey G from comment #19)
I am getting about 5 to 10% frame drops on Linus Tech Tips 4K videos now. I have the new experimental WebAPI: WebGPU enabled. https://www.youtube.com/watch?v=eS4bNKLxEL0
Does enaling that help with other videos which have huge dropped frames?
Thank you.
Reporter | ||
Comment 21•3 years ago
|
||
I can't answer the above question because I have reinstalled my system with the new Centos Stream 8 Linux. It could be that because of the good work being done here on this bug I can now play the problem videos stated earlier in this bug report however, I now have a new problem: I am getting a 5% frame drop on ANY YouTube video I watch - even low definition videos:
So, I submitted a new bug: 1695401
https://bugzilla.mozilla.org/show_bug.cgi?id=1695401
I don't know if the new bug I submitted is related to the work being done here.
Reporter | ||
Comment 22•3 years ago
|
||
50% frame drop to 5% frame drop is a huge improvement by the way. Thank you!
Assignee | ||
Comment 24•3 years ago
|
||
Update: I'm working on this again, now I already have some WIP.
Assignee | ||
Comment 25•3 years ago
|
||
Updated some detailed investigation on this document.
Assignee | ||
Comment 26•3 years ago
|
||
If the decoded video MDSM received is already late, then it indicates that video decoding is too slow.
If we keep decoding but in the same speed, it's very likely all following decoded videos would still be behind the clock and need to be discarded.
The reader has its own mechanism to seek to the next keyframe, but that will only happen when the time of next keyframe is behind the given time threshold, which is the current time.
When the video has pretty long keyframe interval (eg. 5s), then that mechanism won't be triggered because the even if the decoded video frames are late, the next keyframe still far exceeds the current time, so the reader doesn't think it's necessary to skip.
Therefore, MDSM should force the reader to seek to the next keyframe directly, because it know both the decoded time of video frames and the current playback time.
Assignee | ||
Comment 27•3 years ago
|
||
MDSM will stop decoding video when it reaches the certain amount of frames, but that will not work well if the video decoding is way too slow than the audio decoding.
In that situation, video should keep decoding as much as possible, in order to catch up with the audio decoding.
But we also don't need to decode video without any constraint, set the duration of decoded video to at least as the same as the decoded audio seems fair and enough.
Depends on D117242
Comment 28•3 years ago
|
||
Pushed by alwu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/db7fd455cc6a part1 : let MDSM detect whether the video decoding is too slow and force to request the next key frame. r=bryce https://hg.mozilla.org/integration/autoland/rev/97fb4c742d68 part2 : keep decoded video has at least same amount of duration as decoded audio data. r=bryce
Comment 29•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/db7fd455cc6a
https://hg.mozilla.org/mozilla-central/rev/97fb4c742d68
Updated•3 years ago
|
Comment 30•3 years ago
|
||
Reproduced the issue on 87.0 under Ubuntu 20.04 by using the links provided in Comment 0. The third link would show the first frame then will remain frozen for the rest of the video (only audio works)
The issue is fixed on 92.0a1 (2021-08-02) and 91.0b9, the video is much more fluent (will still keep freezing every ~3 sec but it will render again the video - as the laptop I was testing on will run 4k 30fps videos fluently but 60fps is a bit too much).
Description
•