Closed Bug 1623584 Opened 4 years ago Closed 4 years ago

[WAYLAND][VA-API] Playing Youtube 4k60 videos leads to tremendous CPU usage and picture stays still (as long as media.ffvpx.enable is true)

Categories

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

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME
Tracking Status
firefox-esr68 --- unaffected
firefox74 --- unaffected
firefox75 --- disabled
firefox76 --- disabled

People

(Reporter: popovic.marko, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: nightly-community)

Attachments

(1 file)

(deleted), text/plain
Details
Attached file LOG (deleted) —

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

Steps to reproduce:

Using widget.wayland-dmabuf-vaapi.enabled flag under firefox and running with environment variables: GDK_BACKEND=wayland MOZ_LOG="PlatformDecoderModule:5" LIBVA_DRIVER_NAME=i965 makes CPU go bonkers, just as high as not using VAAPI at all, so I'm wondering if my setup is even using it properly.
Running:
Fedora 32 beta, Gnome 3.36.0 wayland / Mutter 3.36.0
Intel i7-8550u and Intel UHD 620 graphics, NO DUAL GPUs
Attachment: LOG

vainfo:
libva info: VA-API version 1.6.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.6 (libva 2.6.1)
vainfo: Driver version: Intel i965 driver for Intel(R) Kaby Lake - 2.4.0
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileH264MultiviewHigh : VAEntrypointVLD
VAProfileH264MultiviewHigh : VAEntrypointEncSlice
VAProfileH264StereoHigh : VAEntrypointVLD
VAProfileH264StereoHigh : VAEntrypointEncSlice
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileNone : VAEntrypointVideoProc
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileVP8Version0_3 : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointEncSlice
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileVP9Profile0 : VAEntrypointEncSlice
VAProfileVP9Profile2 : VAEntrypointVLD

Actual results:

CPU usage is incredibly high, video renders only a few frames and then picture goes still for quite a while until rendering a few frames again.

Expected results:

I guess Ihtel UHD620 should be able to playback 4k60 without much stress with it's hardware decoders. vainfo says that it supports vp9, h264 and hevc.

Please also attach your about:support after playing a video. Thanks!

OS: Unspecified → Linux
Hardware: Unspecified → x86_64

It looks like VAAPI is indeed used on your system:

[AVHWDeviceContext @ 0x7ff490c4c240] VAAPI driver: Intel i965 driver for Intel(R) Kaby Lake - 2.4.0.

(In reply to Laurențiu Nicola from comment #2)

It looks like VAAPI is indeed used on your system:

[AVHWDeviceContext @ 0x7ff490c4c240] VAAPI driver: Intel i965 driver for Intel(R) Kaby Lake - 2.4.0.

Hmm what could then be the cause for huge CPU usage and basically still picture in videos?

Blocks: 1619258

Could you try installing intel-media-driver? There are currently two drivels, one providing i965_drv_video.so, the other iHD_drv_video.so. The later is the more modern one, only supporting newer hardware, you have the former one installed.

(In reply to Robert Mader [:rmader] from comment #4)

Could you try installing intel-media-driver? There are currently two drivels, one providing i965_drv_video.so, the other iHD_drv_video.so. The later is the more modern one, only supporting newer hardware, you have the former one installed.

No change after installing the intel-media-driver, even did the reboot, CPU usage is still over the top and still only a few frames show up.

I think you also need to remove the LIBVA_DRIVER_NAME=i965, just in case you're still using it.

(In reply to Laurențiu Nicola from comment #6)

I think you also need to remove the LIBVA_DRIVER_NAME=i965, just in case you're still using it.

I actually even replaced it with iHD and left it blank. The result is basically the same in every case.

Did you try lower resolutions / fps? Maybe the hardware (or the driver) simply does not support 4k@60fps. Maybe also try other players like mpv - if it doesn't work there, there's likely little we can do in firefox.

(In reply to Robert Mader [:rmader] from comment #8)

Did you try lower resolutions / fps? Maybe the hardware (or the driver) simply does not support 4k@60fps. Maybe also try other players like mpv - if it doesn't work there, there's likely little we can do in firefox.

Works beautifully under both MPV and even Windows with DXVA. Hardware is super recent so if this one doesn't support 4k60fps then what hardware does?

Just tested myself, it's using about 95% CPU in the content process, plus some 40% in the main process for an 1080p60 VP9 video. Not sure if that's good or bad.

(In reply to Laurențiu Nicola from comment #10)

Just tested myself, it's using about 95% CPU in the content process, plus some 40% in the main process for an 1080p60 VP9 video. Not sure if that's good or bad.

I guess that's basically what vaapi aims to solve, that's tremendous CPU usage for a 1080p60 video.

For reference, same video downloaded from youtube (Costa Rica 4k60fps) uses 4-8% of the CPU while playback with MPV.

Same CPU usage without VAAPI. It works better for me on H.264 video, but even the the CPU usage is much higher than in mpv.

(In reply to Laurențiu Nicola from comment #13)

Same CPU usage without VAAPI. It works better for me on H.264 video, but even the the CPU usage is much higher than in mpv.

Obviously the fact that FF has to buffer the video and such will lead to always a bit higher CPU usage than with mpv which only reads it from the disk, but 4-8% compared to 60+% and even not reaching smooth playback seems to be bugged to me, definitely not correct behavior.

(In reply to Marko from comment #14)

(In reply to Laurențiu Nicola from comment #13)

Same CPU usage without VAAPI. It works better for me on H.264 video, but even the the CPU usage is much higher than in mpv.

Obviously the fact that FF has to buffer the video and such will lead to always a bit higher CPU usage than with mpv which only reads it from the disk, but 4-8% compared to 60+% and even not reaching smooth playback seems to be bugged to me, definitely not correct behavior.

NVM lol, even when buffering from youtube celluloid rarely reaches above 6% of the CPU usage.

(In reply to Marko from comment #9)

Works beautifully under both MPV and even Windows with DXVA. Hardware is super recent so if this one doesn't support 4k60fps then what hardware does?

That's good to know. In that case I think all we can do is wait atm - this is still in alpha status and far from complete. There are likely lots of issues to be solved on the way, from failing VAAPI decoding, depending on the setup, over webrender issues etc etc. Martin Stranksy is working on it - but until it works flawless (and thus can be activated by default) it's still a couple of releases out :)

In other words, the current status is that it works to a certain degree on some hardware, to be increased over time.

(In reply to Robert Mader [:rmader] from comment #16)

(In reply to Marko from comment #9)

Works beautifully under both MPV and even Windows with DXVA. Hardware is super recent so if this one doesn't support 4k60fps then what hardware does?

That's good to know. In that case I think all we can do is wait atm - this is still in alpha status and far from complete. There are likely lots of issues to be solved on the way, from failing VAAPI decoding, depending on the setup, over webrender issues etc etc. Martin Stranksy is working on it - but until it works flawless (and thus can be activated by default) it's still a couple of releases out :)

In other words, the current status is that it works to a certain degree on some hardware, to be increased over time.

I know, I just wanted to put this out there so we have things documented :) I'm here to test and report since I cannot contribute code because I'm not a dev! For the meantime we stick to copying links to good ol' mpv and hope that Firefox will one day reach such efficiency with hardware video decoding playback :) or at least come close.

Oof, please disregard (most of) my comments. My iGPU does not support VP9. On my system, mpv uses a bit less than 90% CPU on the same video.

(In reply to Laurențiu Nicola from comment #18)

Oof, please disregard (most of) my comments. My iGPU does not support VP9. On my system, mpv uses a bit less than 90% CPU on the same video.

Don't worry mine does support both VP9, H264 and HEVC, so I'll be able to test any improvements on the front. Same video in mpv only takes less than 6% CPU power so I have a nice comparison.

Bug 1619258 only fixed VP9 hardware decoding for media.ffvpx.enabled=false which uses system FFmpeg like in H.264 case. media/ffvpx (stripped down copy of FFmpeg) currently lacks VAAPI-based decoders.

(In reply to Jan Beich from comment #20)

Bug 1619258 only fixed VP9 hardware decoding for media.ffvpx.enabled=false which uses system FFmpeg like in H.264 case. media/ffvpx (stripped down copy of FFmpeg) currently lacks VAAPI-based decoders.

THANK YOU, that did the trick :D indeed when flaging that false VP9 4k60 video decodes perfectly, cpu usage around 5% on main thread and 9-10% on the secondary which already paints miles different picture!

(In reply to Marko from comment #21)

(In reply to Jan Beich from comment #20)

Bug 1619258 only fixed VP9 hardware decoding for media.ffvpx.enabled=false which uses system FFmpeg like in H.264 case. media/ffvpx (stripped down copy of FFmpeg) currently lacks VAAPI-based decoders.

THANK YOU, that did the trick :D indeed when flaging that false VP9 4k60 video decodes perfectly, cpu usage around 5% on main thread and 9-10% on the secondary which already paints miles different picture!

So you can close this issue? ;)

Summary: [WAYLAND][VA-API] Playing Youtube 4k60 videos leads to tremendous CPU usage and picture stays still even with VAAPI turned on → [WAYLAND][VA-API] Playing Youtube 4k60 videos leads to tremendous CPU usage and picture stays still (as long as media.ffvpx.enable is true)

https://phabricator.services.mozilla.com/D65536

I feel that the better solution would be to integrate the vaapi code into our copy of ffmpeg. then this decision to block the ffvpx PDM wouldn't be needed.

And system ffmpeg on distribution like Suse, disable h264 by default.
However, our ffvpx only allows for vp8 and vp9

Bugbug thinks this bug is a regression, but please revert this change in case of error.

Keywords: regression
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression

Closing then, Thanks for the help here.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: