Bug 173796 - [GStreamer] Browsers that use WebkitGTK play some videos with severe distortion if using VA-API.
Summary: [GStreamer] Browsers that use WebkitGTK play some videos with severe distorti...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 162528 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-06-23 16:35 PDT by Ryan Farmer
Modified: 2018-04-12 01:23 PDT (History)
5 users (show)

See Also:


Attachments
The distortions when I play a video. (1.39 MB, image/png)
2017-06-23 16:35 PDT, Ryan Farmer
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Farmer 2017-06-23 16:35:13 PDT
Created attachment 313758 [details]
The distortions when I play a video.

Description of problem:

Browsers that use WebkitGTK play some videos with severe distortion if using VA-API. I've tried this with Gnome Web and Midori. To make sure it wasn't a problem with Gstreamer, I downloaded a local copy of the video and played it in Totem, and it worked fine.


Version-Release number of selected component (if applicable):

WebkitGTK4 2.16.4-1 as provided by Fedora 26


How reproducible:


Steps to Reproduce:

1. Open Gnome Web or Midori with Gstreamer VA API support, Intel VA API driver, Gstreamer's Bad, Ugly, etc. plug ins...

2. Go to certain videos on Youtube or other sites, such as https://www.youtube.com/watch?v=JccW-mLdNe0

3. Notice bizarre video distortions instead of proper playback.


Additional info:

I've attached a picture that shows what I'm talking about.

If it's important, I'm using an Intel Skylake Mobile Iris 540 graphics chipset and the VA API driver  1.8.2 from RPM Fusion. Mesa version is 17.1.3.

Device: Mesa DRI Intel(R) Iris Graphics 540 (Skylake GT3e)  (0x1926)
vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 1.8.2

This bug report is copied from Red Hat's Bugzilla bug #1464599 at https://bugzilla.redhat.com/show_bug.cgi?id=1464599
Comment 1 Michael Catanzaro 2017-06-23 18:35:53 PDT
Hey Victor, any chance you have time to look into this one?

(Also... is gstreamer1-vaapi intended to be installed by default by distros? Because right now, it's not. It's really not great that we have two different sets of bugs depending on whether this package is installed or not.)
Comment 2 Ryan Farmer 2017-06-23 19:20:21 PDT
Well, it's bad in particular because Fedora won't package Intel's VA API driver so you have to get that from RPM Fusion, so at least on Fedora, it wouldn't matter if you depended on the Gstreamer VA API plug-in, which is in Fedora proper, as the user would hit bug 173799 and melt their laptop without the Intel driver.

I'm assuming that Fedora Legal's opinion of Intel's VA driver is that it violates some US patents?
Comment 3 Víctor M. Jáquez L. 2017-06-26 03:39:54 PDT
It looks like an alignment problem, like if the video sink is not requesting for the video meta to map the frames. And that is required to vaapi because the frame might have offsets.

We would need to review how WebKit code is configured and compiled in fedora 26, because as far as I remember, webkit sink does request for the video meta.
Comment 4 Michael Catanzaro 2017-06-26 07:16:55 PDT
(In reply to Víctor M. Jáquez L. from comment #3)
> We would need to review how WebKit code is configured and compiled in fedora
> 26, because as far as I remember, webkit sink does request for the video
> meta.

Here is the Fedora .spec:

https://src.fedoraproject.org/cgit/rpms/webkitgtk4.git/tree/webkitgtk4.spec?h=f26
Comment 5 Víctor M. Jáquez L. 2017-07-12 10:56:07 PDT
9 Finally I spared some project time to narrow and understand the problem:

a) it only happens in Wayland
b) USE_GSTREAMER_GL should *not* be enabled. This is done by disabling the compositing mode (WEBKIT_DISABLE_COMPOSITING_MODE) in upstream, or by default in downstream.

In Wayland, glupload (from gstreamer-gl) negotiates dmabuf importing with VAAPI, getting zero-copy and correct rendering always.

Without glupload, the negotiation is with system memory mapping to download the buffer. But there are some streams which cannot be copied correctly from the VA context to the wayland/egl texture.

It seems that these streams are those which need a different allocation buffer size for decoding than the presentation buffer size.

The problem is similar with: 

https://bugzilla.gnome.org/show_bug.cgi?id=775698 (vaapisink in wl mutter)
https://bugzilla.gnome.org/show_bug.cgi?id=783169 (glimagesink in wl mutter)
https://bugzilla.gnome.org/show_bug.cgi?id=784369 (clutter in wl mutter)
Comment 6 Michael Catanzaro 2017-07-12 11:10:27 PDT
In that case, this bug probably does not need to be prioritized. We're just two months away from releasing 2.18 with GStreamerGL enabled, thanks to Miguel, so it will only affect a non-default configuration that Linux distros will not use.
Comment 7 Víctor M. Jáquez L. 2017-08-02 07:02:05 PDT
*** Bug 162528 has been marked as a duplicate of this bug. ***
Comment 8 Michael Catanzaro 2017-08-14 08:23:20 PDT
Is this redundant with https://bugzilla.gnome.org/show_bug.cgi?id=773453? Can this bug be closed?
Comment 9 Víctor M. Jáquez L. 2017-08-14 08:58:29 PDT
(In reply to Michael Catanzaro from comment #8)
> Is this redundant with https://bugzilla.gnome.org/show_bug.cgi?id=773453?
> Can this bug be closed?

Nope. They are unrelated.
Comment 10 Ryan Farmer 2017-11-05 23:40:43 PST
(In reply to Michael Catanzaro from comment #6)
> In that case, this bug probably does not need to be prioritized. We're just
> two months away from releasing 2.18 with GStreamerGL enabled, thanks to
> Miguel, so it will only affect a non-default configuration that Linux
> distros will not use.

Still going on with Fedora 27 using GNOME Web 3.26.2 and WebkitGTK 2.18.2.
Comment 11 Michael Catanzaro 2017-11-06 06:25:37 PST
(In reply to Ryan Farmer from comment #10)
> Still going on with Fedora 27 using GNOME Web 3.26.2 and WebkitGTK 2.18.2.

Well we do have GStreamerGL enabled there, so the assumption that this does not occur with GStreamerGL enabled must have been wrong.
Comment 12 Ryan Farmer 2017-11-08 14:01:31 PST
(In reply to Michael Catanzaro from comment #11)
> (In reply to Ryan Farmer from comment #10)
> > Still going on with Fedora 27 using GNOME Web 3.26.2 and WebkitGTK 2.18.2.
> 
> Well we do have GStreamerGL enabled there, so the assumption that this does
> not occur with GStreamerGL enabled must have been wrong.

I just tried everything out with Ubuntu 17.10 and this issue doesn't happen with Gstreamer and Intel VA-API support installed. Also, videos that play in Firefox are using significantly less CPU time than they do in Fedora. 

Is something going on in Fedora overall to where Gstreamer is misconfigured with regards to Intel VA-API?

This might not be a strictly Webkit bug.
Comment 13 Michael Catanzaro 2017-11-08 16:15:43 PST
I don't know about Firefox.

For WebKit, it's Ubuntu that's "misconfigured" in this case. They can't enable GStreamerGL because they don't have gst-plugins-bad in main. I put misconfigured in quotes because that is supported, but it's a fallback behavior that we don't test anymore.
Comment 14 Ryan Farmer 2017-11-10 12:01:44 PST
(In reply to Michael Catanzaro from comment #13)
> I don't know about Firefox.
> 
> For WebKit, it's Ubuntu that's "misconfigured" in this case. They can't
> enable GStreamerGL because they don't have gst-plugins-bad in main. I put
> misconfigured in quotes because that is supported, but it's a fallback
> behavior that we don't test anymore.


I don't know that this matters or not, but at least under the Ubuntu on Wayland session, when Web/Epiphany is playing a video, a window entry pops up on the "Ubuntu dock" that is called "OpenGL Renderer". It goes away when I'm not playing a video anymore.
Comment 15 Michael Catanzaro 2017-11-10 13:35:47 PST
Hm, yes, that reminds me, I checked their WebKit package and actually they did not disable GStreamerGL. So my comments above were wrong. I'm not sure how that works: I guess it's not actually a runtime requirement, only a build-time requirement?

(In reply to Ryan Farmer from comment #14) 
> I don't know that this matters or not, but at least under the Ubuntu on
> Wayland session, when Web/Epiphany is playing a video, a window entry pops
> up on the "Ubuntu dock" that is called "OpenGL Renderer". It goes away when
> I'm not playing a video anymore.

Heh, quality. :P
Comment 16 Ryan Farmer 2017-11-18 20:47:07 PST
For what it's worth, I went ahead and tried this again in Ubuntu using the latest git snapshot of Mesa and videos are messed up again. 

Something weird going on in the i965 driver?
Comment 17 Ryan Farmer 2017-11-19 02:00:25 PST
^Add and clarify... "Now it does garbled video under X but not under Wayland.".

:/

So we have a problem that only arises under certain kernel+mesa+x and/or wayland mixtures and on some intel graphics hardware... Almost unbelievable.
Comment 18 Philippe Normand 2018-03-02 04:26:47 PST
Is this still broken Ryan?

Can you test with WebKitGTK 2.19.91 and GStreamer 1.12.4 (or even the upcoming 1.14 (1.13.1) release)?
Comment 19 Ryan Farmer 2018-04-08 00:39:49 PDT
(In reply to Philippe Normand from comment #18)
> Is this still broken Ryan?
> 
> Can you test with WebKitGTK 2.19.91 and GStreamer 1.12.4 (or even the
> upcoming 1.14 (1.13.1) release)?

Seems to work with Ubuntu 18.04 LTS in both the default Xorg session and Wayland.

Web 3.28, WebkitGTK+ 2.20, GStreamer 1.14. 

Actually, video playback _only_ works correctly with the Intel VA-API and GStreamer VA-API packages installed. Trying to play a video without them is a slideshow. 

If Fedora 28 ever gets rid of the issue where GNOME on Wayland falls back to llvmpipe on my Intel Iris 540, I'll try checking over there too.
Comment 20 Ryan Farmer 2018-04-11 20:44:32 PDT
I tested this out on Fedora 28 and the distorted video issue is gone, but Youtube videos crash the Webkit process quite often if you change the resolution while they are playing. That's really a different issue, though.
Comment 21 Philippe Normand 2018-04-12 01:23:59 PDT
(In reply to Ryan Farmer from comment #20)
> I tested this out on Fedora 28 and the distorted video issue is gone, but
> Youtube videos crash the Webkit process quite often if you change the
> resolution while they are playing. That's really a different issue, though.

Hum ok.. Can you open a new bug for this issue?
I'll close this one then. Thanks!