After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 788367 - Using GtkSocket and GtkPlug result in flickering while drawing
Using GtkSocket and GtkPlug result in flickering while drawing
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: X11
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-09-30 08:01 UTC by Rene Hansen
Modified: 2018-05-02 19:10 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Rene Hansen 2017-09-30 08:01:17 UTC
Hi Gtk team,

Steps to Reproduce:
Create a GtkWindow with a GtkSocket child and a GtkPlug with a GtkDrawingArea attached and connected both. Continuously draw on the GtkDrawingArea by creating an idle callback. 

Actual results:
The GtkWindow starts flickering constantly.

Additional info:
A demo app can be found here: https://github.com/rehans/GtkSocketPlugDemo

While this demo works on Ubuntu 16.04 (tested on 3 PCs) with
libgtk-3-0:amd64  3.18.9-1ubuntu3.3  amd64  GTK+ graphical user interface library

it starts flickering constantly on Ubuntu 17.04 with
libgtk-3-0:amd64  3.22.11-0ubuntu3  amd64  GTK+ graphical user interface library

The Raspberry PI 3 with (Debian Stretch installed) shows the same behavior like Ubuntu 17.04 with libgtk-3-0:armhf  3.22.11-1+rpi3  armhf  GTK+ graphical user interface library

The issue is discussed in further detail on the mailing list: https://mail.gnome.org/archives/gtk-list/2017-September/msg00112.html

René
Comment 1 Eric Cashon 2017-10-03 21:48:37 UTC
Hi Rene,

In gdkwindow.c there is a condition in two places(gdk_window_begin_draw_frame() and gdk_window_end_draw_frame())

if (gdk_window_has_native (window) && gdk_window_is_toplevel (window))

that the drawing area in the plug doesn't pass. The first condition can be made true by using gdk_window_ensure_native() either in the application code or it could be set in gtkwidget.c, gtk_widget_render(). Something like

if (is_double_buffered)
    {
      GtkWidget *top = gtk_widget_get_ancestor (widget, GTK_TYPE_PLUG);
      if (top != NULL)
          gdk_window_ensure_native (window);

for gdk_window_is_toplevel it seems a little more difficult to pass. If I use gdk_window_ensure_native() and ignore gdk_window_is_toplevel() the test code with the plug and drawing area draws without flicker. 

This is as far as I have got on this one. Have made some progress but have a ways to go before figuring it out. 

Eric
Comment 2 Eric Cashon 2017-10-05 19:39:25 UTC
If the two lines in gdkwindow.c

    if (gdk_window_has_native (window) && gdk_window_is_toplevel (window))

get changed to 

    if (gdk_window_has_native (window) && window->toplevel_window_type == -1)

and the GdkWindow is set to native with 

    gtk_widget_show_all(plug);  
    GdkWindow *win=gtk_widget_get_window(drawing_area);
    gdk_window_ensure_native(win);

in the application, then the double buffering works with the drawing area in the plug with minimal code changes.

Is (window->toplevel_window_type == -1) a suitable replacement for (gdk_window_is_toplevel (window))?

Eric
Comment 3 GNOME Infrastructure Team 2018-05-02 19:10:21 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/927.