What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

yiliang
Hi,

I have 2 applications. One application (application A) creates a window, and sends the window ID to another application (application B). application B has a gstreamer video pipeline that uses xvimagesink to display the video as overlay in the window using the window ID provided by application A. I am sorry if it sounds a little confusing. This is to separate UI from pipeline.

Following function is used to configure xvimagesink with window ID:

    gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvimagesink), winId);

Most of time it works fine, but sometimes I encounter the following problem, and the application B is terminated:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  3 (X_GetWindowAttributes)
  Resource id in failed request:  0x400016f
  Serial number of failed request:  32
  Current serial number in output stream:  33

After some debugging, I found the error was generated in function gst_xvimagesink_set_xwindow_id() when it called the following function:

XGetWindowAttributes

Could anyone give some hint how to fix this problem?

Thanks,
Yiliang
Reply | Threaded
Open this post in threaded view
|

Re: What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

Luciana Fujii Pontello
On Sat, 2010-02-27 at 17:23 -0800, yiliang wrote:

> Hi,
>
> I have 2 applications. One application (application A) creates a window, and
> sends the window ID to another application (application B). application B
> has a gstreamer video pipeline that uses xvimagesink to display the video as
> overlay in the window using the window ID provided by application A. I am
> sorry if it sounds a little confusing. This is to separate UI from pipeline.
>
> Following function is used to configure xvimagesink with window ID:
>
>     gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvimagesink), winId);
>
> Most of time it works fine, but sometimes I encounter the following problem,
> and the application B is terminated:
>
> X Error of failed request:  BadWindow (invalid Window parameter)
>   Major opcode of failed request:  3 (X_GetWindowAttributes)
>   Resource id in failed request:  0x400016f
>   Serial number of failed request:  32
>   Current serial number in output stream:  33
>
> After some debugging, I found the error was generated in function
> gst_xvimagesink_set_xwindow_id() when it called the following function:
>
> XGetWindowAttributes
>
> Could anyone give some hint how to fix this problem?

Are you using gdk threads_enter() right before set_xwindow_id and
threads_leave() right after?

I do something similar to what you're doing, but had no problems until
now.

Luciana Fujii
Holoscópio Tecnologia - http://holoscopio.com

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

yiliang
Hi Luciana,

No, I did not use these functions.

Yiliang

On Mon, Mar 1, 2010 at 11:38 AM, Luciana Fujii Pontello <[hidden email]> wrote:
On Sat, 2010-02-27 at 17:23 -0800, yiliang wrote:
> Hi,
>
> I have 2 applications. One application (application A) creates a window, and
> sends the window ID to another application (application B). application B
> has a gstreamer video pipeline that uses xvimagesink to display the video as
> overlay in the window using the window ID provided by application A. I am
> sorry if it sounds a little confusing. This is to separate UI from pipeline.
>
> Following function is used to configure xvimagesink with window ID:
>
>     gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvimagesink), winId);
>
> Most of time it works fine, but sometimes I encounter the following problem,
> and the application B is terminated:
>
> X Error of failed request:  BadWindow (invalid Window parameter)
>   Major opcode of failed request:  3 (X_GetWindowAttributes)
>   Resource id in failed request:  0x400016f
>   Serial number of failed request:  32
>   Current serial number in output stream:  33
>
> After some debugging, I found the error was generated in function
> gst_xvimagesink_set_xwindow_id() when it called the following function:
>
> XGetWindowAttributes
>
> Could anyone give some hint how to fix this problem?

Are you using gdk threads_enter() right before set_xwindow_id and
threads_leave() right after?

I do something similar to what you're doing, but had no problems until
now.

Luciana Fujii
Holoscópio Tecnologia - http://holoscopio.com

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

Luciana Fujii Pontello
Well... then look it up and use them. It might solve your problem.

I should have made it clear that these functions are needed, or at least
I understand them to be.

Luciana Fujii

On Mon, 2010-03-01 at 15:11 -0800, Yiliang Bao wrote:

> Hi Luciana,
>
> No, I did not use these functions.
>
> Yiliang
>
> On Mon, Mar 1, 2010 at 11:38 AM, Luciana Fujii Pontello
> <[hidden email]> wrote:
>         On Sat, 2010-02-27 at 17:23 -0800, yiliang wrote:
>        
>         Are you using gdk threads_enter() right before set_xwindow_id
>         and
>         threads_leave() right after?
>        
>         I do something similar to what you're doing, but had no
>         problems until
>         now.
>        
>         Luciana Fujii
>        
>         Holoscópio Tecnologia - http://holoscopio.com



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

Jan Schmidt-6
In reply to this post by yiliang

You should ensure in Application A, that you call XSync, or
gdk_display_sync (gdk_display_get_default()) - otherwise by the time
Application B accesses the Window XID, it might not yet actually exist
in the X server, leading to the crash.

- Jan.

On Sat, 2010-02-27 at 17:23 -0800, yiliang wrote:

> Hi,
>
> I have 2 applications. One application (application A) creates a window, and
> sends the window ID to another application (application B). application B
> has a gstreamer video pipeline that uses xvimagesink to display the video as
> overlay in the window using the window ID provided by application A. I am
> sorry if it sounds a little confusing. This is to separate UI from pipeline.
>
> Following function is used to configure xvimagesink with window ID:
>
>     gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvimagesink), winId);
>
> Most of time it works fine, but sometimes I encounter the following problem,
> and the application B is terminated:
>
> X Error of failed request:  BadWindow (invalid Window parameter)
>   Major opcode of failed request:  3 (X_GetWindowAttributes)
>   Resource id in failed request:  0x400016f
>   Serial number of failed request:  32
>   Current serial number in output stream:  33
>
> After some debugging, I found the error was generated in function
> gst_xvimagesink_set_xwindow_id() when it called the following function:
>
> XGetWindowAttributes
>
> Could anyone give some hint how to fix this problem?
>
> Thanks,
> Yiliang
>


--
Jan Schmidt <[hidden email]>


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

Tristan Matthews-2
2010/3/2 Jan Schmidt <[hidden email]>

You should ensure in Application A, that you call XSync, or
gdk_display_sync (gdk_display_get_default()) - otherwise by the time
Application B accesses the Window XID, it might not yet actually exist
in the X server, leading to the crash.


I'm working on the same kind of problem but I've noticed that Application B will sometimes create a window for a split second, i'm guessing right before the set_xwindow_id call. Can this be avoided? I know this API has changed recently. I'm using Ubunty 8.04, with glib1.2.10 and the following gstreamer releases installed:

gstreamer 0.10.25
gstreamer-plugin-base 0.10.25
gst-plugin-good 0.10.17
gst-plugin-bad 0.10.17
gst-plugin-ugly 0.10.13
gst-ffmpeg 0.10.10.9

Here's my code:

bool handleBusMsg(GstMessage *message)
{
 if (!gst_structure_has_name(message->structure, "prepare-xwindow-id"))
        return false;

    gdk_threads_enter();
    gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(GST_MESSAGE_SRC(message)), getXWindow());
    gdk_threads_leave();
}

 Thanks,
 Tristan

- Jan.

On Sat, 2010-02-27 at 17:23 -0800, yiliang wrote:
> Hi,
>
> I have 2 applications. One application (application A) creates a window, and
> sends the window ID to another application (application B). application B
> has a gstreamer video pipeline that uses xvimagesink to display the video as
> overlay in the window using the window ID provided by application A. I am
> sorry if it sounds a little confusing. This is to separate UI from pipeline.
>
> Following function is used to configure xvimagesink with window ID:
>
>     gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvimagesink), winId);
>
> Most of time it works fine, but sometimes I encounter the following problem,
> and the application B is terminated:
>
> X Error of failed request:  BadWindow (invalid Window parameter)
>   Major opcode of failed request:  3 (X_GetWindowAttributes)
>   Resource id in failed request:  0x400016f
>   Serial number of failed request:  32
>   Current serial number in output stream:  33
>
> After some debugging, I found the error was generated in function
> gst_xvimagesink_set_xwindow_id() when it called the following function:
>
> XGetWindowAttributes
>
> Could anyone give some hint how to fix this problem?
>
> Thanks,
> Yiliang
>


--
Jan Schmidt <[hidden email]>


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Tristan Matthews
email: [hidden email]
web: http://tristanswork.blogspot.com

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

Tristan Matthews-2
2010/3/2 Tristan Matthews <[hidden email]>
2010/3/2 Jan Schmidt <[hidden email]>
Here's my code:

bool handleBusMsg(GstMessage *message)
{
 if (!gst_structure_has_name(message->structure, "prepare-xwindow-id"))
        return false;

    gdk_threads_enter();
    gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(GST_MESSAGE_SRC(message)), getXWindow());
    gdk_threads_leave();
}


I should add, getXWindow() returns the xid which has been provided by Application A (the destination), and that this code lives in Application B (the source).

 
 Thanks,
 Tristan

- Jan.

On Sat, 2010-02-27 at 17:23 -0800, yiliang wrote:
> Hi,
>
> I have 2 applications. One application (application A) creates a window, and
> sends the window ID to another application (application B). application B
> has a gstreamer video pipeline that uses xvimagesink to display the video as
> overlay in the window using the window ID provided by application A. I am
> sorry if it sounds a little confusing. This is to separate UI from pipeline.
>
> Following function is used to configure xvimagesink with window ID:
>
>     gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvimagesink), winId);
>
> Most of time it works fine, but sometimes I encounter the following problem,
> and the application B is terminated:
>
> X Error of failed request:  BadWindow (invalid Window parameter)
>   Major opcode of failed request:  3 (X_GetWindowAttributes)
>   Resource id in failed request:  0x400016f
>   Serial number of failed request:  32
>   Current serial number in output stream:  33
>
> After some debugging, I found the error was generated in function
> gst_xvimagesink_set_xwindow_id() when it called the following function:
>
> XGetWindowAttributes
>
> Could anyone give some hint how to fix this problem?
>
> Thanks,
> Yiliang
>


--
Jan Schmidt <[hidden email]>


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Tristan Matthews
email: [hidden email]
web: http://tristanswork.blogspot.com



--
Tristan Matthews
email: [hidden email]
web: http://tristanswork.blogspot.com

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

yiliang
Thank you all for the suggestions. I have tested both approaches.

1. Use gdk_display_sync (gdk_display_get_default())

Application A (which has the window) is written using QT. Here is the procedure:

1). Application A calls uiWindow.show() to display window,
2). Call gdk_display_sync (gdk_display_get_default()) right after show(),
3). Get windowId, and send to Application B,
4). Application B call gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(m_sinkPreview), windowId);

With or without step 2), Application B can crash.

2. Use gdk_threads_enter and gdk_threads_leave

I did as suggested by Matthews and Luciana, in application B. This works.

Thanks again,
Yiliang

On Tue, Mar 2, 2010 at 12:28 PM, Tristan Matthews <[hidden email]> wrote:
2010/3/2 Tristan Matthews <[hidden email]>
2010/3/2 Jan Schmidt <[hidden email]>
Here's my code:

bool handleBusMsg(GstMessage *message)
{
 if (!gst_structure_has_name(message->structure, "prepare-xwindow-id"))
        return false;

    gdk_threads_enter();
    gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(GST_MESSAGE_SRC(message)), getXWindow());
    gdk_threads_leave();
}


I should add, getXWindow() returns the xid which has been provided by Application A (the destination), and that this code lives in Application B (the source).

 
 Thanks,
 Tristan

- Jan.

On Sat, 2010-02-27 at 17:23 -0800, yiliang wrote:
> Hi,
>
> I have 2 applications. One application (application A) creates a window, and
> sends the window ID to another application (application B). application B
> has a gstreamer video pipeline that uses xvimagesink to display the video as
> overlay in the window using the window ID provided by application A. I am
> sorry if it sounds a little confusing. This is to separate UI from pipeline.
>
> Following function is used to configure xvimagesink with window ID:
>
>     gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvimagesink), winId);
>
> Most of time it works fine, but sometimes I encounter the following problem,
> and the application B is terminated:
>
> X Error of failed request:  BadWindow (invalid Window parameter)
>   Major opcode of failed request:  3 (X_GetWindowAttributes)
>   Resource id in failed request:  0x400016f
>   Serial number of failed request:  32
>   Current serial number in output stream:  33
>
> After some debugging, I found the error was generated in function
> gst_xvimagesink_set_xwindow_id() when it called the following function:
>
> XGetWindowAttributes
>
> Could anyone give some hint how to fix this problem?
>
> Thanks,
> Yiliang
>


--
Jan Schmidt <[hidden email]>


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Tristan Matthews
email: [hidden email]
web: http://tristanswork.blogspot.com



--
Tristan Matthews
email: [hidden email]
web: http://tristanswork.blogspot.com

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

yiliang
Hi,

I come back to this question again. Now gst_x_overlay_set_xwindow_id is guarded according to some friends' suggestions. However, I still ran into the same problem, but much less frequent. Is there anything else I should do?

    gdk_threads_enter();
    gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(m_sinkPreview), winId);
    gdk_threads_leave();

Thanks,
Yiliang
Reply | Threaded
Open this post in threaded view
|

Re: What could cause the error in xvimagesink (XGetWindowAttributes): X Error of failed request?

skrk_536
Hi Yiliang,

I am facing the same issue that you have posted.  Is that issue resolved?  If yes, how did you solve it.

Thanks in advance