Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes when $DISPLAY isn't :0.0 #724

Closed
pubby opened this issue Oct 19, 2014 · 10 comments
Closed

Crashes when $DISPLAY isn't :0.0 #724

pubby opened this issue Oct 19, 2014 · 10 comments

Comments

@pubby
Copy link

pubby commented Oct 19, 2014

When I try to run a SFML program from a different X screen (DISPLAY=:0.1) I get this error:

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  78 (X_CreateColormap)
  Serial number of failed request:  64
  Current serial number in output stream:  66

This means I can only run SFML programs on one monitor of my multi-monitor setup.

Also, when I try to run a SFML program when $DISPLAY is blank (such as from a tmux session not connected to X) I get a segfault. This isn't a huge issue, but I'd much prefer it to exit gracefully with an error rather than crashing.

Backtrace:

0x00007ffff79c50a8 in ?? () from /usr/lib/libsfml-window.so.2
(gdb) backtrace
#0  0x00007ffff79c50a8 in ?? () from /usr/lib/libsfml-window.so.2
#1  0x00007ffff79c120d in ?? () from /usr/lib/libsfml-window.so.2
#2  0x00007ffff79c17f7 in sf::GlResource::GlResource() () from /usr/lib/libsfml-window.so.2
#3  0x00007ffff79c2d5e in sf::Window::Window() () from /usr/lib/libsfml-window.so.2
#4  0x00007ffff77a5299 in sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) () from /usr/lib/libsfml-graphics.so.2
@Bromeon
Copy link
Member

Bromeon commented Oct 19, 2014

When I try to run a SFML program from a different X screen (DISPLAY=:0.1) I get this error [...] This means I can only run SFML programs on one monitor of my multi-monitor setup.

Yes, SFML currently provides no support for multi-monitor setups... This is something we plan to improve in a future version. Concerning this specific X11 error, I'm not sure what the exact reason why it fails is.

Also, when I try to run a SFML program when $DISPLAY is blank (such as from a tmux session not connected to X) I get a segfault.

An error message is output, see #508. Please make sure you use the latest GitHub revision when reporting problems, it doesn't make to investigate things that have been fixed meanwhile :)

@eXpl0it3r
Copy link
Member

I've no idea how X11 works, but even if SFML doesn't provide an API to define where to open window, shouldn't it work if you define it directly with the WM settings? I probably misunderstand what DISPLAY does...

@MarioLiebisch
Copy link
Member

I don't think any program should crash just because it doesn't handle potential multi-monitor setups. So sounds like X11's fault, unless SFML is indeed doing something wrong somewhere. It doesn't really matter whether SFML respects that setting, it should at least work. :)

@eXpl0it3r
Copy link
Member

@pubby Can you please provide more information? Otherwise I'll have to close this issue.

@pubby
Copy link
Author

pubby commented Dec 30, 2014

@eXpl0it3r The problem is that even if you define what display to use directly SFML crashes if its not the zero-th display. This is how you do that:

DISPLAY=:0.1
./tutorial_program

@jcowgill
Copy link
Contributor

I managed to reproduce this using Xephyr by running Xephyr :1 -screen 500x500 -screen 500x500 which creates two screens on :1.0 and :1.1

I had a small look at this and I think that GlxContext::selectBestVisual is returning visuals for the wrong screen. Currently the XCB port (#694) fixes this since it only considers visuals from the default screen instead of all screens.


@pubby My multi monitor setup using RandR (which seems to be what most WMs are using these days) works fine with SFML. Is there a good reason for using the old multiple xorg screens way which I can't see?

@eXpl0it3r
Copy link
Member

The XCB branch has been merged, as such this issue could be reinvestigated.

@TankOs
Copy link
Member

TankOs commented Jan 7, 2015

@pubby, can you try latest master?

@TankOs TankOs self-assigned this Jan 8, 2015
@binary1248
Copy link
Member

Bump.

@pubby can you confirm that this is still an issue with the xcb changes? If not, then there is no point in keeping this issue open.

@binary1248
Copy link
Member

I couldn't reproduce this on master, even when running multiple TTYs using DISPLAY=:0.0, DISPLAY=:1.0 etc.

If no connection to the X server can be established, an error message is emitted and the application aborts as expected.

I'm closing this issue for now. If you have more information that can help us reproduce the issue, feel free to provide it here.

DrMcCoy added a commit to DrMcCoy/SFML that referenced this issue Oct 26, 2018
On an X set-up with multiple monitors running separate X screens (as
opposed to merging them into one large X screen using Xinerama), the
selected X visual needs to be one for the screen where the colormap,
window, and other X resources are created. In fact, all these need to
match, and the GL context as well.

Most of the SFML windowing and graphics code uses (X)DefaultScreen()
for that, which is fine. Combined with XOpenDisplay(NULL), this will
create the window on the screen (and monitor) selected by the DISPLAY
enviroment variable. :0.0 will be the first monitor, :0.1 the second,
etc.

However, XGetVisualInfo() will return visuals for *all* screens, not
just the default one. They seem to be ordered by screen number, but I
don't think the standard makes any guarantees there.

If the visual doesn't match up with the screen, this will abort with
an X error. BadMatch, in many cases.

This means that in addition to other filtering,
GlxContext::selectBestVisual() needs to filter the visuals by screen
number, otherwise SFML won't work at all on any screens but the first.

This fixes issue SFML#724.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants