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
Black screen on SDL2-enabled OpenTTD, Sway and SDL_VIDEODRIVER=wayland #8029
Comments
First off, we'll probably want to check this isn't some system/SDL issue we can't solve - can you run any SDL2 application? |
I've checked another SDL2-application, JA2-Stracciatella, and there is no black screen or other problems. No issues with Aquaria-OSE as well. P.S. Every time I've checked that they run in Wayland mode |
Maybe using |
Here is output with wayland driver
Pretty similar to x11 driver:
|
Without any developers having a wayland setup to test with, I'm afraid you're going to have to debug this yourself for now, or find someone else who can help |
I've found that use of sdl driver's parameter no_thread fixes this issue. The only change in output with -d driver=2 is |
I can reporduce the issue on Sway. After recompiling |
I looked into this a bit. A few things worth mentioning: SDL uses X11 over wayland, as they themselves do not consider wayland backend driver stable enough to be used by default. See https://bugzilla.libsdl.org/show_bug.cgi?id=3948 . Luckily, the X11 backend works just fine on Wayland. Mainly as reason they give a patch like https://bugzilla.libsdl.org/show_bug.cgi?id=5194 has not landed yet. There is a lot of activity going on there, so who knows, sometime soon. Till that time, you will notice that the SDL window has no decoration (you cannot resize, no title, no minimize/maximize button, etc). This makes it impracticable to use for a game like OpenTTD. These are problems SDL appear to be fixing, so it is better for us to hold on this. The next problem we currently have with Wayland, is that rendering fails. This is because for Wayland, SDL uses EGL. And it appears that the context is created in the main thread, while we render in the draw thread. This is why |
…eo driver When the wayland SDL video driver is used, an EGL context is created in the main thread. It is not allowed to update this context from another thread, which is exactly what our draw-thread is trying. The other solution would be to move all of SDL into the draw-thread, but that would introduce a whole scala of different problems. The wayland SDL backend is significantly faster than the X11 SDL backend, but there is a performance hit nevertheless.
…eo driver When the wayland SDL video driver is used, an EGL context is created in the main thread. It is not allowed to update this context from another thread, which is exactly what our draw-thread is trying. The other solution would be to move all of SDL into the draw-thread, but that would introduce a whole scala of different problems. The wayland SDL backend is significantly faster than the X11 SDL backend, but there is a performance hit nevertheless.
When the wayland SDL video driver is used, an EGL context is created in the main thread. It is not allowed to update this context from another thread, which is exactly what our draw-thread is trying. The other solution would be to move all of SDL into the draw-thread, but that would introduce a whole scala of different problems. The wayland SDL backend is significantly faster than the X11 SDL backend, but there is a performance hit nevertheless.
Is the performance hit big enough, that you could maybe add a recommendation to not use the Wayland back-end? Is the actual solution, figuring out how to draw on a separate thread, when using EGL contexts? |
There are two things here.
No. That would be a huge change in all our video drivers (and all the problems that comes with such endeavor), one not worth taking at this point in time for a single SDL video driver that should not be the default on any system :) |
@TrueBrain BTW, statement about not recommendation of Wayland from SDL2 is not valid anymore, according to https://www.phoronix.com/news/SDL2-Prefers-Wayland and libsdl-org/SDL#4306 |
Version of OpenTTD
1.10.0-RC1
Expected result
Title screen is shown
Actual result
Black screen, but sound of train could be heard
Steps to reproduce
Compile OpenTTD with SDL2, run it with SDL_VIDEODRIVER=wayland ./openttd under Sway-1.4.0
P.S. Same problem on Weston-8.0.0
The text was updated successfully, but these errors were encountered: