X Client requests fail for GTK based window

0

I have created a simple gstreamer+gtk based application to play video file. "filesrc", "decodebin", "autovideosink", "autoaudiosink" gstreamer elements are used for that.

Main window is created using gtk_window_new(GTK_WINDOW_TOPLEVEL) and drawing area is created using gtk_drawing_area_new(). Drawing window is embedded in main window.

To render on gtk drawing window, its handle is passed to gstreamer video plugin as overlay using gstreamer api gst_video_overlay_set_window_handle() By doing so video is not rendered only audio gets played.

Instead of GTK window if i pass XCreateWindow() handle to gstreamer video plugin as overlay then everything works fine. But i have to create GTK based player.

Now, when i start debugging the issue i have found below details.

  1. "autovideosink" plugin gets blocked on XNextEvent inside mainloop thread(Luckily i have source code and verified using logs)
  2. Then using xtrace utility it was found that most of X Request gets failed(See below) whereas in case of XCreateWindow all such Request gets successful Response.

002:<:000f: 52: Request(1): CreateWindow depth=0x18 window=0x01600001 parent=0x01400007 x=0 y=0 width=640 height=368 border-width=0 class=InputOutput(0x0001) visual=0x00000021 value-list={background-pixel=0x00000000 border-pixel=0x00000000 backing-store=NotUseful(0x00) override-redirect=false(0x00) colormap=CopyFromParent(0x00000000)}

002:<:0010: 24: Request(16): InternAtom only-if-exists=true(0x01) name='_NET_WM_STATE'

002:>:000f:Error 8=Match: major=1, minor=0, bad=20971527

002:<:001d: 8: Request(3): GetWindowAttributes window=0x01600001

002:<:001e: 8: Request(14): GetGeometry drawable=0x01600001

002:>:001d:Error 3=Window: major=3, minor=0, bad=23068673

002:>:001e:Error 9=Drawable: major=14, minor=0, bad=23068673

I have no idea why these requests gets failed for GTK window. Whereas in my old system(ubuntu 14.04) i can run the same player very well. Current system is ubuntu 16.04

Any X Server related configuration setting doing that? Please suggest some solution or any idea how to debug it further to catch the real cause.

linux
gstreamer
x11
gtk3
xlib
asked on Stack Overflow Apr 2, 2018 by Naseeb Panghal • edited Jun 20, 2020 by Community

1 Answer

0

Prototype:

XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valuemask, attributes)

autovideosink mentioned in question is actually imxeglvivsink. imxeglvivsink creates child window with gtk-window as parent(Check second parameter of XCreateWindow api).

Now GDK default Visual used for Parent Windodw(GTK) were different from X default Visual and this is the reason X CreateWindow Request gets failed.

I solved this problem with 2 solutions.

Solution 1: In imxeglvivsink, while creating child window i used 'CopyFromParent' flag for 'visual' parameter of XCreateWindow api. By doing so, Visual for Parent and Child matches and X request CreateWindow gets successful.

I didn't like this solution as i have to replace original imxeglvivsink library with my new library.

Solution 2: My ultimate goal is still same. I have to keep same visual for parent and child window. In this solution i changed Visual of Parent window(GTK) to X Default Visual. I did this change at application level and i don't have any dependency of imxeglvivsink. Code snippet to change GDK visual is below:

static int change_visual(GtkWidget *widget)
{
  int nitems_return;
  Display *x_display = XOpenDisplay(NULL);
  Visual *x_visual = XDefaultVisual(x_display, DefaultScreen(x_display));

  GdkScreen *gdk_screen = gdk_screen_get_default();
  GList *gdk_visual_list = gdk_screen_list_visuals(gdk_screen);
  GList *l;
  for (l = gdk_visual_list; l != NULL; l = l->next)
  {
    Visual *temp = gdk_x11_visual_get_xvisual((GdkVisual *)l->data);
    if(temp->visualid == x_visual->visualid) break;
  }
  //l is pointing the visual which is similar to system x visual. Lets change it.
  gtk_widget_set_visual (widget, (GdkVisual *)l->data);
  return 0;
}

I know i don't take care if visualid don't match inside the for loop. For me i always find GDK visual same to X Default Visual.

answered on Stack Overflow Apr 23, 2018 by Naseeb Panghal

User contributions licensed under CC BY-SA 3.0