Open Bug 1843679 Opened 1 year ago Updated 7 months ago

[ AMD Radeon RX 6650XT ] YouTube video stops playing for seconds

Categories

(Core :: Audio/Video: Playback, defect)

Firefox 117
defect

Tracking

()

UNCONFIRMED

People

(Reporter: lilydjwg, Unassigned)

References

(Blocks 2 open bugs, )

Details

Attachments

(1 file)

204.02 KB, application/octet-stream
Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0

Steps to reproduce:

  • enable VAAPI
  • watch a YouTube video

Actual results:

It stops playing randomly for about 5 seconds. Audio continues, and Firefox is responsible. It happens about once per video. All videos I've checked is using vp9 codec. It happens with both media.ffvpx.enabled set to true and false.

I'm not sure if it happens to other sites. This didn't happen for the same video with mpv as far as I've tested.

Expected results:

I'm on Arch Linux, wayfire Wayland, using an AMD Radeon RX 6650XT card.

The Bugbug bot thinks this bug should belong to the 'Core::Audio/Video: Playback' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Audio/Video: Playback
Product: Firefox → Core

It happens for an av1 video too.

Oops, I forgot to say my display card. It's AMD Radeon RX 6650 XT.

Same issue on AMD Ryzen 7 PRO 6850HS with Radeon Graphics integrated GPU: the video freezes about 5 seconds while audio and other stuff works fine, then continues as normal. From what I can tell this happens only on VP9 videos using VAAPI, never on H264 and AV1. Also, It can happens multiple times per video, even consecutively.

Versions:

mesa 23.1.3-2
ffmpeg-git 6.1.r111115.g8e21f32fe7-1
firefox 115.0.2-1
Severity: -- → S3

@lilydjwg, is this a regression for you?

I just notice this, when jumping(?)/navigating forward and backward in a video.

I'm not sure if it's a regression or it's because I bought an AMD display card. A bisect would take a lot of time and videos to run....

Maybe you can see something in the logging of MOZ_LOG="PlatformDecoderModule:5 Dmabuf:1" nightly, cf https://firefox-source-docs.mozilla.org/networking/http/logging.html#using-about-logging.¹

Though about:logging didn’t work so well for me the one time I tried it, and I set the environment variable MOZ_LOG directly.

Though about:logging didn’t work so well for me the one time I tried it, and I set the environment variable MOZ_LOG directly.

What happened? It should always work when using it with the Firefox Profiler.

Besides, the correct syntax is:

MOZ_LOG="PlatformDecoderModule:5,Dmabuf:1" nightly

with a , and not a space in between log modules.

It would be great to catch logs of this happening. Even better if using the Firefox Profiler, because we have lots of little markers (that we usually use for performance measurements) that will make it super clear that nothing happens for 5 seconds or so.

Thanks all for helping to diagnose this in any case, let me know if about:logging or the profiler itself doesn't work.

Attached file firefox.log.zst

This file is produced using MOZ_LOG="PlatformDecoderModule:5,Dmabuf:1" and playing a YouTube vp9 video, during which the video freeze for seconds several times. Though I cannot tell from the logs whats goes wrong by myself.

Maybe Martin can spot something in the log.

I'm using about:logging and I do not see any logs during the issue happening except one line saying Flushing old log files.

Summary: YouTube video stops playing for seconds → [ AMD Radeon RX 6650XT ] YouTube video stops playing for seconds

Log looks ok. Can you try mpv player in VA-API mode?
Run
mpv --hwdec=vaapi test_clip
on terminal (test_clip can be also youtube URL).
Thanks.

Flags: needinfo?(lilydjwg)

I've tried mpv for a problematic video (I've always been using mpv with vaapi on) and there was no issue. Maybe luck plays a part. I'll try a few more times.

I did reproduced the video freeze on both Firefox and MPV using vaapi, with the same local video file downloaded from [1]. The freeze range from half second to 5 seconds, and appears at different timestamp between each run. Sometimes it freezes at a old frame from a few seconds back. In all cases audio and UI are normal.

However, mpv don't seem to notice the freeze, as it didn't print anything related:

yjc@yjc-hpeb ~/Videos % mpv --no-config --vo=gpu-next --gpu-api=vulkan --hwdec=vaapi 'Hit Marks [Effects] [B-P4ysHSjCg].webm'
 (+) Video --vid=1 (*) (vp9 1920x1080 59.940fps)
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
Using hardware decoding (vaapi).
AO: [pipewire] 48000Hz stereo 2ch floatp
VO: [gpu-next] 1920x1080 vaapi[nv12]
(Paused) AV: 00:00:23 / 00:04:49 (8%) A-V:  0.000 Dropped: 23

Exiting... (Quit)

(Those dropped frames come from switching windows, not when video freezes.) It doesn't freeze at all when --hwdec=vaapi is dropped.

I am using KDE Wayland, and both Firefox and MPV run in Wayland mode.

Software versions:

linux 6.4.5.arch1-1
mesa 23.1.4-2
libva-mesa-driver 23.1.4-2
libva 2.19.0-1
firefox 115.0.2-1
mpv 1:0.36.0-1
ffmpeg-git 6.1.r111115.g8e21f32fe7-1
kwin 5.27.6-1

[1] https://www.youtube.com/watch?v=B-P4ysHSjCg

Good! Please report that at Mesa issue tracker (https://gitlab.freedesktop.org/mesa/mesa/-/issues) and link the issue here.
Thanks.

(In reply to Martin Stránský [:stransky] (ni? me) from comment #15)

Good! Please report that at Mesa issue tracker (https://gitlab.freedesktop.org/mesa/mesa/-/issues) and link the issue here.
Thanks.

It is already reported as https://gitlab.freedesktop.org/mesa/mesa/-/issues/8044 6 month ago but still unresolved :(

Maybe we can only wait for AMD engineers to sort this out.

Can you attach the downloaded video where the freeze happens? Use google drive or so. I have similar gfx card (6600 TX) so I can try it.
Thanks.

Flags: needinfo?(ye.jingchen)

(In reply to Martin Stránský [:stransky] (ni? me) from comment #17)

Can you attach the downloaded video where the freeze happens? Use google drive or so. I have similar gfx card (6600 TX) so I can try it.
Thanks.

Of course: https://drive.google.com/file/d/1IOJHYPoNvXCzqy4tR7A0WKS7BBESn7Mx/view?usp=drive_link

Flags: needinfo?(ye.jingchen)

I haven't seen this issue again for days. Perhaps a system update fixes it for me, maybe kernel from 6.3.11 to 6.4.6.

Flags: needinfo?(lilydjwg)

(In reply to lilydjwg from comment #19)

I haven't seen this issue again for days. Perhaps a system update fixes it for me, maybe kernel from 6.3.11 to 6.4.6.

Thank you for the update. For completeness please also list your Mesa version. Was Firefox also updated in the meantime?

mesa has been updated from 23.1.3 to 23.1.4 and my Firefox Nightly has been updated too.

Tested the clip on on Fedora 38 / mesa-23.1.4 / AMD 6600 XT and I don't see that either.

Can someone that can repro get us media logs (that also includes various performance data) using those instructions: https://paul.cx/public/about-logging-presentation.webm? Don't forget to share the profile and post it here.

https://bugzilla.mozilla.org/show_bug.cgi?id=1520894#c46 shows very expensive memcpy calls down in gallium, I wonder if we're seeing the same thing.

Reposting what I had in issue 1520894:

I tested with https://www.youtube.com/watch?v=Fmdb-KmlzD8 setting it to 4K. With this I could reliably reproduce the issue, with it stuttering significantly every few seconds. Its not a new issue for me, and has been happening basically since I got this laptop, so for some 7 or 8 months. The issue is especially bad with high bitrate video. Turning down to a lower resolution, like 480p, reduces frequency of the stuttering significantly, though it is still there.

Profile on Firefox stable: https://share.firefox.dev/3YcbtiN
Profile on a freshly downloaded Firefox nighty: https://share.firefox.dev/3DCjPGQ
Nightly media log using the above instructions for about:logging https://share.firefox.dev/3ODhgL34
Here's one with stack trace enabled: https://share.firefox.dev/3qcgmf0

If I download the video with yt-dlp and play it with Celluloid or MPV, it plays fine. In fact I can also play it fine if I open the downloaded video file in Firefox. I have only noticed this on YouTube, not when watching conference recordings or other "normal videos", so a thought that comes to mind is that it may be somehow related to HLS/DASH. That may just be barking up the wrong tree though.

(In reply to James Frost from comment #24)

If I download the video with yt-dlp and play it with Celluloid or MPV, it plays fine. In fact I can also play it fine if I open the downloaded video file in Firefox. I have only noticed this on YouTube, not when watching conference recordings or other "normal videos", so a thought that comes to mind is that it may be somehow related to HLS/DASH. That may just be barking up the wrong tree though.

Yes, you're right. You see dmabuf buffer relocation. i.e. dmabuf is copied via CPU which is extremely slow. I wonder why radeon drivers does that.
This looks like Mesa radeon driver bug. Can you try to play the affected video directly by mpv from youtube and check if you see it too?

mpv --hwdec=vaapi youtube_url
Flags: needinfo?(git)

Running mpv --hwdec=vaapi https://www.youtube.com/watch?v=Fmdb-KmlzD8 does indeed reproduce the stuttering, though it is far less frequent and less consistent than inside Firefox.

Is there a good way to directly profile the video driver? All the stats I can find inside of MPV don't show any out of the ordinary when the stuttering occurs.

Flags: needinfo?(git)

James, if you want to profile mpv, you can install the debug symbols (that depends on your disto), and then use https://github.com/mstange/samply, that allows to profile native programs, but outputs in the same interface as the Firefox Profiler -- you can then upload or get a gzipped profile as usual.

Flags: needinfo?(git)

(In reply to James Frost from comment #26)

Running mpv --hwdec=vaapi https://www.youtube.com/watch?v=Fmdb-KmlzD8 does indeed reproduce the stuttering, though it is far less frequent and less consistent than inside Firefox.

Is there a good way to directly profile the video driver? All the stats I can find inside of MPV don't show any out of the ordinary when the stuttering occurs.

If you see that with mvp please report it at https://gitlab.freedesktop.org/mesa/mesa/-/issues and CC me there. I can provide background info based on Firefox profile.

Thanks.

I've seen this on 7840hs too.
I think setting media.hardware-video-decoding.enabled to false helped - at least I haven't seen the issue after that, but the issue hasn't happen too often anyhow.

Clear a needinfo that is pending on an inactive user.

Inactive users most likely will not respond; if the missing information is essential and cannot be collected another way, the bug maybe should be closed as INCOMPLETE.

For more information, please visit BugBot documentation.

Flags: needinfo?(git)

Maybe not that helpful for diagnosing what the problem is, but I've not had the issue for a few months now. Still on Fedora 38, but maybe a mesa update fixed it.

(In reply to James Frost from comment #32)

Maybe not that helpful for diagnosing what the problem is, but I've not had the issue for a few months now. Still on Fedora 38, but maybe a mesa update fixed it.

*Fedora 39.

Thanks for the update, if anybody still sees anything of the sort after system updates, don't hesitate to follow https://paul.cx/public/about-logging-presentation.webm and attach a profile here, maybe there are multiple problems.

I tried this video in comment 29 on a Framework 16 running Fedora 39 and can't reproduce it.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: