Bug 118253 - [texmap][GStreamer][GTK] composited video shows tearing
Summary: [texmap][GStreamer][GTK] composited video shows tearing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords:
Depends on: 118471 119386
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-01 10:16 PDT by Víctor M. Jáquez L.
Modified: 2014-04-29 01:55 PDT (History)
8 users (show)

See Also:


Attachments
Update the texture _only_ when it is going to be painted. (7.00 KB, patch)
2013-07-04 04:05 PDT, Víctor M. Jáquez L.
no flags Details | Formatted Diff | Diff
Call glXSwapInterval(1) if available (1.81 KB, patch)
2013-07-04 04:07 PDT, Víctor M. Jáquez L.
no flags Details | Formatted Diff | Diff
opengl trace of a webkit1 session (438.88 KB, text/x-log)
2013-07-04 07:21 PDT, Víctor M. Jáquez L.
no flags Details
Patch (2.31 KB, patch)
2013-07-30 12:09 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Víctor M. Jáquez L. 2013-07-01 10:16:18 PDT
Composited video using nvidia cards (tested on ion and quadro nvs, either nouveau or the closed-source driver) shows a screen tearing artifacts, in non-composited window managers, no matter if the vblank sync configuration is enabled.
Comment 1 Víctor M. Jáquez L. 2013-07-01 10:19:05 PDT
I experimented with glXSwapIntervalEXT and it doesn't improve the tearing issue.
Comment 2 Víctor M. Jáquez L. 2013-07-01 10:22:24 PDT
I'm wondering if we should add some kind of vblank handling as cogl does:

https://git.gnome.org/browse/cogl/tree/cogl/winsys/cogl-winsys-glx.c#n1741
Comment 3 Víctor M. Jáquez L. 2013-07-04 04:05:59 PDT
Created attachment 206071 [details]
Update the texture _only_ when it is going to be painted.
Comment 4 Víctor M. Jáquez L. 2013-07-04 04:07:48 PDT
Created attachment 206073 [details]
Call glXSwapInterval(1) if available
Comment 5 Víctor M. Jáquez L. 2013-07-04 07:21:09 PDT
Created attachment 206086 [details]
opengl trace of a webkit1 session

The FB Context is created without double buffer!
Comment 6 Martin Robinson 2013-07-04 09:20:24 PDT
Comment on attachment 206073 [details]
Call glXSwapInterval(1) if available

View in context: https://bugs.webkit.org/attachment.cgi?id=206073&action=review

> Source/WebCore/platform/graphics/glx/GLContextGLX.cpp:155
> +        glXSwapInterval = reinterpret_cast<PFNGLXSWAPINTERVALSGIPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXSwapIntervalSGI")));

Something like this belongs in OpenGLShims.

> Source/WebCore/platform/graphics/glx/GLContextGLX.cpp:253
> +    if (m_window) {
> +        bool ret = glXMakeCurrent(sharedX11Display(), m_window, m_context);
> +        if (glXSwapInterval)
> +            glXSwapInterval(1);
> +        XSync(sharedX11Display(), False);
> +        return ret;
> +    }

Does it make sense to call this even if we are running under a composited window manager?
Comment 7 Martin Robinson 2013-07-04 09:21:39 PDT
You've got a couple different patches here, but none of them are up for review. If you want them reviewed, I recommend making this patch a meta bug and creating one dependent bug for each patch.
Comment 8 Víctor M. Jáquez L. 2013-07-04 15:46:27 PDT
(In reply to comment #7)
> You've got a couple different patches here, but none of them are up for review. If you want them reviewed, I recommend making this patch a meta bug and creating one dependent bug for each patch.

I didn't ask for review because those patches don't solve the problem. I uploaded them a as reference of what I have tried.
Comment 9 Xabier Rodríguez Calvar 2013-07-08 07:38:18 PDT
I am having trouble with both WebKit and direct gst-launch. I have an Intel 915 and I tried with GStreamer 1.0.4, 1.0.7 and today's master with same tearing result.

I am adding CCing Sebastian in case he can shed some light.
Comment 10 Sebastian Dröge (slomo) 2013-07-09 00:05:14 PDT
If you see tearing it most probably is caused by doing rendering during vsync. To get around that you should synchronize all drawing operations with vsync, i.e. make sure that the drawing operation is started and finished before the next vsync.

Something like glXSwapInterval(1) should do that though.
Comment 11 Sebastian Dröge (slomo) 2013-07-09 00:07:21 PDT
Ideally you would have a render loop that renders everything right before the vsync, and separate to that the uploading of the textures. So the render loop would always see finished textures, and always takes the latest of all textures and then immediately renders them.

This is also the way how we want to change the GStreamer video sinks in the future.
Comment 12 Víctor M. Jáquez L. 2013-07-10 03:03:37 PDT
mozilla related info:

https://bugzilla.mozilla.org/show_bug.cgi?id=689419
Comment 13 Víctor M. Jáquez L. 2013-07-12 01:37:01 PDT
Gtk+-3.8 offers API for vblank sync

https://developer.gnome.org/gdk3/stable/gdk3-GdkFrameClock.html

Cogl has it's own means for vblank sync

https://git.gnome.org/browse/cogl/tree/cogl/winsys/cogl-winsys-glx.c#n1880
Comment 14 Zan Dobersek 2013-07-30 12:00:29 PDT
This issue is fixed when using GTK+ 3.8, likely due to support for the Window Manager frame synchronization protocol.
https://mail.gnome.org/archives/gtk-list/2013-March/msg00019.html

I'll upload the patch that bumps the Jhbuild versions of the GTK+ and Glib packages.
Comment 15 Zan Dobersek 2013-07-30 12:03:04 PDT
(In reply to comment #14)
> I'll upload the patch that bumps the Jhbuild versions of the GTK+ and Glib packages.

Err, GTK+ and Gdk-Pixbuf.
Comment 16 Zan Dobersek 2013-07-30 12:09:03 PDT
Created attachment 207754 [details]
Patch
Comment 17 Zan Dobersek 2013-07-31 05:40:56 PDT
Comment on attachment 207754 [details]
Patch

Clearing flags on attachment: 207754

Committed r153518: <http://trac.webkit.org/changeset/153518>
Comment 18 Zan Dobersek 2013-07-31 05:41:03 PDT
All reviewed patches have been landed.  Closing bug.
Comment 19 WebKit Commit Bot 2013-08-01 02:10:47 PDT
Re-opened since this is blocked by bug 119386
Comment 20 Zan Dobersek 2013-08-01 02:15:15 PDT
(In reply to comment #19)
> Re-opened since this is blocked by bug 119386

Rolling out the Jhbuild dependency bump. The bump wasn't required by the layout tests and is causing problems with the increased Pando dependency, but do note that the fix is still valid - when using GTK+ >= 3.8, the screen tearing is no longer present.
Comment 21 Zan Dobersek 2013-08-01 02:32:25 PDT
Closing as fixed as per comment #20.
Comment 22 Xabier Rodríguez Calvar 2013-08-04 02:10:55 PDT
(In reply to comment #21)
> Closing as fixed as per comment #20.

I applied the patch and compiled WebKit with "Tools/Scripts/build-webkit --gtk --enable-webkit2 --disable-gtk-doc --enable-introspection=no --no-svg" and run the example with "Tools/Scripts/run-launcher --gtk --enable-accelerated-compositing=TRUE url" in GNOME Classic and I still can see the tearing. It's less noticeable, but it is still there. I think we should reopen this.
Comment 23 Zan Dobersek 2013-08-05 00:28:35 PDT
Reopening.
Comment 24 Víctor M. Jáquez L. 2013-08-05 02:04:46 PDT
(In reply to comment #22)
> (In reply to comment #21)
> > Closing as fixed as per comment #20.
> 
> I applied the patch and compiled WebKit with "Tools/Scripts/build-webkit --gtk --enable-webkit2 --disable-gtk-doc --enable-introspection=no --no-svg" and run the example with "Tools/Scripts/run-launcher --gtk --enable-accelerated-compositing=TRUE url" in GNOME Classic and I still can see the tearing. It's less noticeable, but it is still there. I think we should reopen this.

Confirming using a Nvidia gpu, the tearing is still there.
Comment 25 Martin Robinson 2013-08-05 02:11:45 PDT
(In reply to comment #24)

> Confirming using a Nvidia gpu, the tearing is still there.

Can you guys confirm whether you are seeing this with the version of GTK+ that reported to have fixed this issue?
Comment 26 Víctor M. Jáquez L. 2013-08-05 02:31:18 PDT
(In reply to comment #25)
> (In reply to comment #24)
> 
> > Confirming using a Nvidia gpu, the tearing is still there.
> 
> Can you guys confirm whether you are seeing this with the version of GTK+ that reported to have fixed this issue?

$ jh run ldd WebKitBuild/Debug/.libs/libwebkitgtk-3.0.so.0.19.3  | grep libgtk

libgtk-3.so.0 => /home/sicom/WebKit/WebKitBuild/Dependencies/Root/lib/libgtk-3.so.0 (0xb2b16000)

$ ls -la /home/sicom/WebKit/WebKitBuild/Dependencies/Root/lib/libgtk-3.so.0

lrwxrwxrwx. 1 sicom sicom 19 Aug  4 12:17 /home/sicom/WebKit/WebKitBuild/Dependencies/Root/lib/libgtk-3.so.0 -> libgtk-3.so.0.800.2

libgtk+-3.8.2
Comment 27 Zan Dobersek 2013-08-05 05:48:49 PDT
(In reply to comment #24)
> (In reply to comment #22)
> > I applied the patch and compiled WebKit with "Tools/Scripts/build-webkit --gtk --enable-webkit2 --disable-gtk-doc --enable-introspection=no --no-svg" and run the example with "Tools/Scripts/run-launcher --gtk --enable-accelerated-compositing=TRUE url" in GNOME Classic and I still can see the tearing. It's less noticeable, but it is still there. I think we should reopen this.
> 
> Confirming using a Nvidia gpu, the tearing is still there.

What drivers are you using?

FWIW, I got no tearing after upgrading to 3.8 and using the Nvidia blob.
Comment 28 Víctor M. Jáquez L. 2013-08-05 06:02:15 PDT
(In reply to comment #27)
> (In reply to comment #24)
> > (In reply to comment #22)
> > > I applied the patch and compiled WebKit with "Tools/Scripts/build-webkit --gtk --enable-webkit2 --disable-gtk-doc --enable-introspection=no --no-svg" and run the example with "Tools/Scripts/run-launcher --gtk --enable-accelerated-compositing=TRUE url" in GNOME Classic and I still can see the tearing. It's less noticeable, but it is still there. I think we should reopen this.
> > 
> > Confirming using a Nvidia gpu, the tearing is still there.
> 
> What drivers are you using?

I'm using the closed nvidia blob as well.

> 
> FWIW, I got no tearing after upgrading to 3.8 and using the Nvidia blob.
Comment 29 Zan Dobersek 2013-08-29 01:07:28 PDT
I've retested this yesterday. With a fresh build and using the default set of dependencies (i.e. GTK+ 3.6) I got no tearing (even though I experienced it about a month back, when upgrading to GTK+ 3.8 fixed the issue for me).

I've tested with both nouveau and the Nvidia blob drivers on an Nvidia system, and with the i915 driver on an Intel system. I was using Ubuntu 13.04 in all cases.

Can anyone else still reproduce this? I'm hoping this has been somehow fixed recently by changes in the WebKit tree.
Comment 30 Zan Dobersek 2013-09-05 06:53:13 PDT
To expand on comment #29, I also tested a build of a month-old revision (from around the time when r153518 landed -- comment #17), and while I was able to reproduce the tearing back then, I couldn't reproduce it this time.

This is turning quite odd on my part, so I'd like to gather information about what software people still experiencing the problem are using.

Specifically, I'm interested in the following:
- distribution being used, along with the version,
- the X system version being used if it differs from the version the distribution provides by default,
- the graphics driver being used, along with the version.

With this information I would hopefully be able to (again) reproduce the tearing on my hardware. Thanks in advance!
Comment 31 Víctor M. Jáquez L. 2013-10-09 10:53:25 PDT
(In reply to comment #30)

Using r157159, GTK+ 3.8.2, debug build, GtkLaunch, and I still see the tearing in scenes with high movement.

> To expand on comment #29, I also tested a build of a month-old revision (from around the time when r153518 landed -- comment #17), and while I was able to reproduce the tearing back then, I couldn't reproduce it this time.
> 
> This is turning quite odd on my part, so I'd like to gather information about what software people still experiencing the problem are using.
> 
> Specifically, I'm interested in the following:
> - distribution being used, along with the version,

Fedora17

> - the X system version being used if it differs from the version the distribution provides by default,

xorg-x11-server-Xorg-1.12.4-7.fc17.i686

> - the graphics driver being used, along with the version.

NVIDIA Driver version 304.88

> 
> With this information I would hopefully be able to (again) reproduce the tearing on my hardware. Thanks in advance!
Comment 32 Víctor M. Jáquez L. 2013-12-03 00:55:29 PST
Confirming what Zan Dobersek said in comment #20:

Using Fedora20, with 

xorg-x11-server-Xorg-1.14.4-5.fc20.i686
gtk3-devel-3.10.5-1.fc20.i686
nvidia version 304.108

And there is _NOT_ tearing.

Recent developments in Xorg and GTK+ added frame displaying control, avoiding the tearing effect.

Hence, I'm closing this bug.
Comment 33 Xabier Rodríguez Calvar 2014-04-28 01:29:24 PDT
(In reply to comment #32)
> Confirming what Zan Dobersek said in comment #20:
> 
> Using Fedora20, with 
> 
> xorg-x11-server-Xorg-1.14.4-5.fc20.i686
> gtk3-devel-3.10.5-1.fc20.i686
> nvidia version 304.108

I am using xserver 1:7.7+7 in my Debian testing with the internal jhbuild dependencies in GNOME 3.8.4 in Flashback mode and I still see tearing. Víctor was with me so he can confirm it.

I think we should reopen this.
Comment 34 Martin Robinson 2014-04-28 08:44:58 PDT
(In reply to comment #33)
I am using xserver 1:7.7+7 in my Debian testing with the internal jhbuild dependencies in GNOME 3.8.4 in Flashback mode and I still see tearing. Víctor was with me so he can confirm it.
> 
> I think we should reopen this.

1:7.7+7 is less than 1.14.4-5 right? Have you tried with a more recent version of Xorg?
Comment 35 Xabier Rodríguez Calvar 2014-04-28 09:15:34 PDT
(In reply to comment #34)
> (In reply to comment #33)
> I am using xserver 1:7.7+7 in my Debian testing with the internal jhbuild dependencies in GNOME 3.8.4 in Flashback mode and I still see tearing. Víctor was with me so he can confirm it.
> > 
> > I think we should reopen this.
> 
> 1:7.7+7 is less than 1.14.4-5 right?

I am not sure, though it doesn't seem to. Any way to check it?

> Have you tried with a more recent version of Xorg?

Nope, it's the one that I have.
Comment 36 Zan Dobersek 2014-04-29 01:33:45 PDT
(In reply to comment #33)
> (In reply to comment #32)
> > Confirming what Zan Dobersek said in comment #20:
> > 
> > Using Fedora20, with 
> > 
> > xorg-x11-server-Xorg-1.14.4-5.fc20.i686
> > gtk3-devel-3.10.5-1.fc20.i686
> > nvidia version 304.108
> 
> I am using xserver 1:7.7+7 in my Debian testing with the internal jhbuild dependencies in GNOME 3.8.4 in Flashback mode and I still see tearing. Víctor was with me so he can confirm it.
> 
> I think we should reopen this.

What graphics card? Driver?
Comment 37 Xabier Rodríguez Calvar 2014-04-29 01:46:13 PDT
(In reply to comment #36)
> What graphics card? Driver?

Intel Sandybridge with the i915.
Comment 38 Zan Dobersek 2014-04-29 01:55:33 PDT
I'll try and reproduce this.

I think Victor and I were both using the Nvidia blob drivers when this got fixed on its own by using a combination of newer versions of GTK+ and the X server.