Bug 254340

Summary: [GStreamer] Does not use vaapi for video playback
Product: WebKit Reporter: Johannes Penßel <johannesp>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: bugs-noreply, mcatanzaro
Priority: P2    
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
gstreamer logs captured using surf, because epiphany would not produce logs for some reason none

Description Johannes Penßel 2023-03-23 09:55:42 PDT
Created attachment 465554 [details]
gstreamer logs captured using surf, because epiphany would not produce logs for some reason

When playing video content on any WebkitGTK-based browser (tested Epiphany 43.1/44, surf), video hardware acceleration via VAAPI is not used. (intel_gpu_top shows no activity on the "Video" engine) VAAPI playback in Firefox works flawlessly. The issue occurs on Xorg and Wayland (tested on GNOME 44). The webkit-gtk version in use is 2.40.

The flatpak version of Epiphany is also affected. (ffmpeg-full and gstreamer-vaapi runtimes installed, acceleration enabled with $ flatpak run --command=gsettings org.gnome.Epiphany set org.gnome.Epiphany.web:/org/gnome/epiphany/web/ hardware-acceleration-policy 'always')

playback via gstreamer directly is VAAPI-accelerated as expected:
$ gst-play-1.0 --videosink glimagesink https://upload.wikimedia.org/wikipedia/commons/c/c0/Big_Buck_Bunny_4K.webm

installed gstreamer plugins: bad,base,dash,good,gtk,hls,mpeg123,libav,openh264,opus,pulse,soup,taglib,ugly,v4l2,vaapi,vpx,x264

FFmpeg 5.1.2

Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Intel (0x8086)
    Device: Mesa Intel(R) Graphics (ADL GT2) (0x46a6)
    Version: 23.0.0
    Accelerated: yes
    Video memory: 15826MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.6
    Max compat profile version: 4.6
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2

$ uname -a

Linux gentoo 6.2.8-gentoo #1 SMP PREEMPT_DYNAMIC Thu Mar 23 14:15:27 CET 2023 x86_64 12th Gen Intel(R) Core(TM) i5-1240P GenuineIntel GNU/Linux

$ gst-inspect-1.0 vaapi

Plugin Details:
  Name                     vaapi
  Description              VA-API based elements
  Filename                 /usr/lib64/gstreamer-1.0/libgstvaapi.so
  Version                  1.22.1
  License                  LGPL
  Source module            gstreamer-vaapi
  Documentation            https://gstreamer.freedesktop.org/documentation/vaapi/
  Source release date      2023-03-04
  Binary package           gstreamer-vaapi
  Origin URL               https://www.gentoo.org

  vaapiav1dec: VA-API AV1 decoder
  vaapidecodebin: VA-API Decode Bin
  vaapih264dec: VA-API H264 decoder
  vaapih264enc: VA-API H264 encoder
  vaapih265dec: VA-API H265 decoder
  vaapih265enc: VA-API H265 encoder
  vaapijpegdec: VA-API JPEG decoder
  vaapijpegenc: VA-API JPEG encoder
  vaapimpeg2dec: VA-API MPEG2 decoder
  vaapimpeg2enc: VA-API MPEG-2 encoder
  vaapioverlay: VA-API overlay
  vaapipostproc: VA-API video postprocessing
  vaapisink: VA-API sink
  vaapivc1dec: VA-API VC1 decoder
  vaapivp8dec: VA-API VP8 decoder
  vaapivp9dec: VA-API VP9 decoder
  vaapivp9enc: VA-API VP9 encoder

  17 features:
  +-- 17 elements



$ vainfo

Trying display: wayland
libva info: VA-API version 1.18.0
libva info: Trying to open /usr/lib64/va/drivers/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_18
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.18 (libva 2.17.1)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.3 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointFEI
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointFEI
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointFEI
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointFEI
      VAProfileHEVCMain               :	VAEntrypointEncSliceLP
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointEncSliceLP
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointEncSliceLP
      VAProfileVP9Profile1            :	VAEntrypointVLD
      VAProfileVP9Profile1            :	VAEntrypointEncSliceLP
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointEncSliceLP
      VAProfileVP9Profile3            :	VAEntrypointVLD
      VAProfileVP9Profile3            :	VAEntrypointEncSliceLP
      VAProfileHEVCMain12             :	VAEntrypointVLD
      VAProfileHEVCMain12             :	VAEntrypointEncSlice
      VAProfileHEVCMain422_10         :	VAEntrypointVLD
      VAProfileHEVCMain422_10         :	VAEntrypointEncSlice
      VAProfileHEVCMain422_12         :	VAEntrypointVLD
      VAProfileHEVCMain422_12         :	VAEntrypointEncSlice
      VAProfileHEVCMain444            :	VAEntrypointVLD
      VAProfileHEVCMain444            :	VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10         :	VAEntrypointVLD
      VAProfileHEVCMain444_10         :	VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12         :	VAEntrypointVLD
      VAProfileHEVCSccMain            :	VAEntrypointVLD
      VAProfileHEVCSccMain            :	VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          :	VAEntrypointVLD
      VAProfileHEVCSccMain10          :	VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444         :	VAEntrypointVLD
      VAProfileHEVCSccMain444         :	VAEntrypointEncSliceLP
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileHEVCSccMain444_10      :	VAEntrypointVLD
      VAProfileHEVCSccMain444_10      :	VAEntrypointEncSliceLP
Comment 1 Michael Catanzaro 2023-03-23 11:27:51 PDT
gstreamer-vaapi is intentionally blocked because it doesn't work reliably, see bug #240664 and especially bug #197752 for justification for blocking it.

The future solution is the new va element of gstreamer-plugins-bad. See https://blogs.igalia.com/vjaquez/2020/07/10/new-va-api-h-264-decoder-in-gst-plugins-bad/ and https://blogs.igalia.com/vjaquez/2021/12/08/gstva-in-gstreamer-1-20/. Currently that's still disabled by default, but there is some environment variable you can use to uprank it. Hopefully it will become enabled by default soon (maybe in gst 1.24?) because you really shouldn't need to do anything to get hardware decoding. Anyway, copying from that second blog post:

GST_PLUGIN_FEATURE_RANK=vah264dec:MAX,vah265dec:MAX,vampeg2dec:MAX,vavp8dec:MAX,vavp9dec:MAX

Maybe that will work?
Comment 2 Johannes Penßel 2023-03-23 12:09:13 PDT
Turns out that in Gentoo builds of gst-plugins-bad, the va plugin is disabled. With it enabled + the environment variables you suggested, hardware decoding works flawlessly. Thank you and sorry for the unnecessary bug report.