Skip to content

Fix Daemon on XWayland#659

Closed
necessarily-equal wants to merge 1 commit intoDaemonEngine:masterfrom
necessarily-equal:fix-xwayland
Closed

Fix Daemon on XWayland#659
necessarily-equal wants to merge 1 commit intoDaemonEngine:masterfrom
necessarily-equal:fix-xwayland

Conversation

@necessarily-equal
Copy link
Copy Markdown
Contributor

@necessarily-equal necessarily-equal commented Jul 27, 2022

Fixes #658

@necessarily-equal
Copy link
Copy Markdown
Contributor Author

necessarily-equal commented Jul 27, 2022

Alternatively there is this patch

diff --git a/src/engine/sys/sdl_glimp.cpp b/src/engine/sys/sdl_glimp.cpp
index 1500e7cd..f14662d0 100644
--- a/src/engine/sys/sdl_glimp.cpp
+++ b/src/engine/sys/sdl_glimp.cpp
@@ -522,8 +522,14 @@ static bool GLimp_DetectAvailableModes()
 
        if ( SDL_GetWindowDisplayMode( window, &windowMode ) < 0 )
        {
+               // we can't use SDL_GetWindowWMInfo yet, so we can't use
+               // that and use getenv instead.
+               if (Q_stricmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)
+               {
+                       return true; // don't fail as this is normal on XWayland.
+               }
                logger.Warn("Couldn't get window display mode: %s", SDL_GetError() );
-               return true;
+               return false;
        }
 
        for ( i = 0; i < SDL_GetNumDisplayModes( display ); i++ )

@illwieckz
Copy link
Copy Markdown
Member

By doing that you fix one issue but bring back others (including segmentation faults).

One issue is described in the code itself here:

When calling GLimp_CreateContext() some drivers may provide a valid
context that is unusable while GL_CheckErrors() catches nothing.
For example 3840×2160 is too large for the Radeon 9700 and
the Mesa r300 driver may print this error when the requested
resolution is higher than what is supported by hardware:

r300: Implementation error: Render targets are too big in r300_set_framebuffer_state, refusing to bind framebuffer state!

The engine would later make a segfault when calling GL_SetDefaultState
from tr_init.cpp if we don't do anything.
Hopefully it looks like SDL_GetWindowDisplayMode can raise this error:

Couldn't find display mode match

so we catch this SDL error when calling GLimp_DetectAvailableModes()
and force a safe lower resolution before we start to draw to prevent
an engine segfault when calling GL_SetDefaultState().

It looks like what you get is a variant of the issue described in PR #644 (now replaced by PR #657).

@illwieckz
Copy link
Copy Markdown
Member

If we're gonna make this test return true, we better revert the whole function to a void one.

The purpose of this function being a bool one and this test returning false was to catch this precise “Couldn't find display mode match” error and to prevent a segfault (so it was 100% done on purpose to return false there and abort).

@necessarily-equal What happens if you run latest master on Wayland, including the just merged:

Does it return to a safe resolution?

Note that this is not a fix for the issue you experience, but it would help to understand more what's going on.

@illwieckz
Copy link
Copy Markdown
Member

@necessarily-equal can you add this simple comment above the return true; line

/* FIXME: returning true means the engine will crash if the window size is larger than what the GPU can do,
but we need to not fail to open window that are not using native screen resolutions even if the GPU can handle it. */

I assume it's better to give everyone the ability to open a window with an arbitrary size than preventing a crash that is only likely to happens on some obsolete hardware if the user tries to use an higher resolution than his GPU can do (which is expected to be already larger than his screen, so not something he wants).

We can do better things after 0.53, 0.52 didn't catch the said crash so not catching this crash in 0.53 isn't a regression, while preventing the creation of arbitrary window sizes is a regression.

@necessarily-equal
Copy link
Copy Markdown
Contributor Author

necessarily-equal commented Jul 27, 2022 via email

@illwieckz
Copy link
Copy Markdown
Member

merged as ba35389

@illwieckz illwieckz closed this Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.53.0/sync Daemon broke on XWayland

2 participants