www.fgks.org   »   [go: up one dir, main page]

Monday, October 30, 2006

Flash/XComposite crasher in X11

This one has been around for a while: When you enable the XComposite extension in X11 and run your desktop using a 15 or 16bit screen depth, the Flash Player will always crash with this error message:
The program 'firefox' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadMatch (invalid parameter attributes)'.
(Details: serial 115 error_code 8 request_code 143 minor_code 3)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
Segmentation fault (core dumped)
There are two workarounds for this:

  • Set the screen depth to 24bit. If you have enough VRAM available this is a good move anyway since you'll get much better performance and quality in general when using Flash. Other applications probably also benefit, there should be less color banding in general.

  • Set the XLIB_SKIP_ARGB_VISUALS environment variable to 1 in one of your init scripts before X11 is started.

So why have we not fixed this in the past? Well, I've not written the code in question and IMO it's even questionable if it is a bug in Flash, depending on what XMatchVisualInfo API is really supposed to do. The docs really do not provide too much information here. The core of the problem is this code in the Flash Player:
int depth = 0;
int mode = 0;
XVisualInfo vi;
static struct
{
int depth, mode;
} formats[] = {
{ 24, TrueColor},
{ 32, TrueColor},
{ 16, TrueColor},
{ 15, TrueColor},
{ 8, PseudoColor},
{ 0, 0}
};
for (int i=0;formats[i].depth; i++ )
{
if(XMatchVisualInfo(display,
DefaultScreen(display),
formats[i].depth,
formats[i].mode,
&vi;)) {
depth = formats[i].depth;
mode = formats[i].mode;
break;
}
}
If XComposite is turned on and your screen depth is 16bit this loop will break when the depth is 32. That depth is used to create the XImage the Flash Player will use for its backbuffer. The actual crash occurs when XPutImage or XShmPutImage is called. At this point X11 will bail out when given an XImage with a depth of 32bit.

The fix? It's as simple as prepending this code to the above loop:
XWindowAttributes attribs;
if(XGetWindowAttributes(display,window,&attribs;)) {
if(XMatchVisualInfo(display,
DefaultScreen(display),
attribs.depth,
TrueColor,
&vi;) {
depth = attribs.depth;
mode = TrueColor;
}
}
if(!depth){
...
}
Pretty much every distribution has complained about this issue over the past few years, so I am happy that we finally resolved this for good. Is this fix in the current beta of the Flash Player (9.0.21.55)? No, I just changed this Friday, so you'll have to wait for a newer build. It also needs to go through QE before this change gets the final approval.

Labels:

2 Comments:

Anonymous Anonymous said...

This one didn't affect me, but it's awesome to see bugs get fixed =)

Tuesday, October 31, 2006 4:08:00 PM  
Anonymous <a href="http://drugscenterhere.com">ShopMan</a> said...

I like articles like this. Thanks!

Saturday, August 25, 2007 11:48:00 PM  

Post a Comment

<< Home