Bug 261892

Summary: [GStreamer][MSE] video playback uses GstVA, except on YouTube
Product: WebKit Reporter: Johannes Penßel <johannesp>
Component: MediaAssignee: Philippe Normand <philn>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply, mcatanzaro, philn, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
"GST_DEBUG=va*:6 epiphany": log of YT playback
none
playback of vp9 content on YT with GST_DEBUG=3,va*:6,webkit*:6
none
playback of vp9 content from a different source GST_DEBUG=3,va*:6,webkit*:6
none
log with GST_PLUGIN_FEATURE_RANK+=pipewiresink:0
none
log with GST_PLUGIN_FEATURE_RANK+=pulsesink:0 none

Description Johannes Penßel 2023-09-21 10:48:35 PDT
Created attachment 467816 [details]
"GST_DEBUG=va*:6 epiphany": log of YT playback

WebKitGTK 2.42.0 happily plays VAAPI-accelerated video on any website in any HW-supported format, except on YouTube (tested with vp9 and av1). Tested with GNOME Web and Surf, on GNOME 45 in wayland and X11 sessions. If I remove the libraries for the GStreamer av1/vpx software decoders, playback on YT stops working altogether.

For reference, this testcase: https://tools.woolyss.com/html5-audio-video-tester/?u=woolyss.com/f/spring-vp9-vorbis.webm works flawlessly. (verified via intel_gpu_top)

Epiphany 44.0 (installed via flatpak) is not affected, but Epiphany.Devel 45.0 is. Firefox 117.0 works.

environment:
GST_PLUGIN_FEATURE_RANK=vaav1dec:MAX,vah264dec:MAX,vah265dec:MAX,vampeg2dec:MAX,vavp8dec:MAX,vavp9dec:MAX,vacompositor:MAX,vadeinterlace:MAX,vajpegdec:MAX,vapostproc:MAX,vah264lpenc:MAX,vah265lpenc:MAX

other software:
GStreamer 1.22.6
Mesa 23.2-rc3
libva-1.19
intel-media-driver-23.3.4
Comment 1 Philippe Normand 2023-09-22 14:13:54 PDT
GST_DEBUG=3,va*:6,webkit*:6 log please :)
Comment 2 Johannes Penßel 2023-09-25 11:56:08 PDT
Created attachment 467848 [details]
playback of vp9 content on YT with GST_DEBUG=3,va*:6,webkit*:6

With GST_DEBUG=3,va*:6,webkit*:6, the following errors are being logged:

0:00:02.157503867     2 0x55adb427d610 ERROR                default gstpipewirecore.c:91:make_core: (null)
0:00:02.158037939     2 0x55adb427d610 ERROR               pipewire gstpipewiredeviceprovider.c:625:gst_pipewire_device_provider_start:<pipewiredeviceprovider0> Failed to connect
0:00:02.307123798     2 0x55adb427d610 ERROR                GST_BUS gstbus.c:945:gst_bus_add_watch_full_unlocked:<bus95> Tried to add new watch while one was already there

I'm on pipewire 0.3.80 and alsa 1.2.10.
Comment 3 Johannes Penßel 2023-09-25 12:09:33 PDT
Created attachment 467849 [details]
playback of vp9 content from a different source GST_DEBUG=3,va*:6,webkit*:6

For reference, this is a log captured while playing vp9 video from a different website. (with working HW accel)
Comment 4 Philippe Normand 2023-09-27 03:23:36 PDT
Are the pipewire errors always and consistently happening when attempting to play YT videos?
Comment 5 Johannes Penßel 2023-09-27 03:39:47 PDT
Yes, they're happening 100% predictably. Same goes for the flatpak version of GNOME Web 45.
Comment 6 Philippe Normand 2023-09-27 03:52:45 PDT
I guess you don't have PulseAudio and you're using PipeWire directly?

If so, can you add this to GST_PLUGIN_FEATURE_RANK? pipewiresink:0
Comment 7 Johannes Penßel 2023-09-27 04:16:22 PDT
Created attachment 467893 [details]
log with GST_PLUGIN_FEATURE_RANK+=pipewiresink:0

I use pipewire-pulse instead of pulseaudio-daemon, but libpulse is still present on my system. Is that what you mean? Sorry for the confusion. 

Seems like the same pipewire errors are still popping up with GST_PLUGIN_FEATURE_RANK+=pipewiresink:0, unfortunately.
Comment 8 Philippe Normand 2023-09-27 06:40:13 PDT
and with pulsesink:0 ? Should fallback to alsasink if you have that.
Comment 9 Johannes Penßel 2023-09-27 07:39:08 PDT
Created attachment 467899 [details]
log with GST_PLUGIN_FEATURE_RANK+=pulsesink:0

After replacing pipewire's soundserver with pulseaudio-daemon and disabling pipewire gstreamer support, I've finally managed to hit a different error message:

0:00:02.445350936     2 0x55e9c218f610 ERROR                   alsa gstalsadeviceprovider.c:57:add_device:<alsadeviceprovider0> Could not open device hw:0,0 for inspection!

No visible change in behavior otherwise though.

hw:0,0 is just my normal soundcard, which I've had zero issues with so far:

card 0: PCH [HDA Intel PCH], device 0: ALC256 Analog [ALC256 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Comment 10 Philippe Normand 2023-10-07 07:37:30 PDT
I can reproduce this issue here. I think it's a GStreamer bug... For YT vp9 streams, decodebin3 doesn't parse the stream and attempts feed that to a compatible decoder, but vavp9dec requires a parsed stream, so it's not selected.
Comment 11 Philippe Normand 2023-10-07 07:39:12 PDT
Can you try this workaround, downrank every vp9 decoder excepted the va one...

GST_PLUGIN_FEATURE_RANK=vp9dec:0,avdec_vp9:0
Comment 12 Philippe Normand 2023-10-07 07:39:52 PDT
(In reply to Philippe Normand from comment #11)
> Can you try this workaround, downrank every vp9 decoder excepted the va
> one...
> 
> GST_PLUGIN_FEATURE_RANK=vp9dec:0,avdec_vp9:0

That should force decodebin3 to add a parsebin and then vavp9dec should be plugged...
Comment 14 Johannes Penßel 2023-10-07 08:39:05 PDT
(In reply to Philippe Normand from comment #12)
> (In reply to Philippe Normand from comment #11)
> > Can you try this workaround, downrank every vp9 decoder excepted the va
> > one...
> > 
> > GST_PLUGIN_FEATURE_RANK=vp9dec:0,avdec_vp9:0
> 
> That should force decodebin3 to add a parsebin and then vavp9dec should be
> plugged...

That works! Dammit, I thought I had discovered an actual WebKit bug for once... Anyways, thank you very much for your help!
Comment 15 Philippe Normand 2023-10-08 01:09:18 PDT
We shouldn't disable urisourcebin:parse-streams for MSE...
Comment 16 Philippe Normand 2023-10-08 01:14:07 PDT
Pull request: https://github.com/WebKit/WebKit/pull/18825
Comment 17 EWS 2023-10-09 01:54:44 PDT
Committed 269068@main (d14f07282a9d): <https://commits.webkit.org/269068@main>

Reviewed commits have been landed. Closing PR #18825 and removing active labels.
Comment 18 Radar WebKit Bug Importer 2023-10-09 01:55:16 PDT
<rdar://problem/116668157>