protonscr

Steam Overlay crashes Godot games when using OpenGL 2.1 context (regression in Mesa 21.1+)

steamclosed overlay
ValveSoftware/steam-for-linux#8122 · opened 2021-10-03 by akien-mga · updated 2021-11-25 · 9 comments · github
1 matching comments, n / p to jump
Aakien-mga 2021-10-03 github

Your system information

  • Steam client version (build number or date): Beta client built Oct 1, 2021 at 21:32:23
  • Distribution (e.g. Ubuntu): Mageia 9 x86_64
  • Opted into Steam client beta?: Yes
  • Have you checked for system updates?: Yes

Please describe your issue in as much detail as possible:

I'm the maintainer of the open source Godot Engine. We found that Godot games using our OpenGL 2.1 renderer ("GLES2" in Godot's API, as it also maps to OpenGL ES 2.0 on mobile and WebGL 1.0 on web) are triggering a segfault in graphics drivers via the Steam Overlay.

The segfault terminates the whole process. Games using our OpenGL 3.3 renderer work fine with the Steam Overlay. Disabling the Steam Overlay, or running the games outside Steam, also works fine.

The segfault happens on a call to glXSwapBuffers() one or two seconds after the game starts, around the time where the Steam Overlay would show its bottom-right corner presence notification.

Here's a gdb backtrace of such a crash using Intel Iris Mesa 21.2.3 drivers and a debug build of Godot's 3.x branch (as of commit https://github.com/godotengine/godot/commit/06e02606996d062f978cc9b71ff2962d10c0431d):

(gdb) bt
#0  0x00007ffff3cbe678 in _mesa_PushAttrib () from /usr/lib64/dri/iris_dri.so
#1  0x00007ffff7f9c922 in ?? () from /home/akien/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so
#2  0x00007ffff7fab308 in ?? () from /home/akien/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so
#3  0x00007ffff7fad09d in ?? () from /home/akien/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so
#4  0x00007ffff7f9b0fe in glXSwapBuffers () from /home/akien/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so
#5  0x0000000001794678 in ContextGL_X11::swap_buffers (this=0x6bd7ab0) at platform/x11/context_gl_x11.cpp:61
#6  0x00000000017a49f3 in OS_X11::swap_buffers (this=0x7fffffffb9f0) at platform/x11/os_x11.cpp:3461
#7  0x00000000029ea092 in RasterizerGLES2::end_frame (this=0x6d0b760, p_swap_buffers=true) at drivers/gles2/rasterizer_gles2.cpp:461
#8  0x000000000426c26e in VisualServerRaster::draw (this=0x6c1dff0, p_swap_buffers=true, frame_step=0.01666666753590107) at servers/visual/visual_server_raster.cpp:110
#9  0x00000000042b57bb in VisualServerWrapMT::draw (this=0x6d665e0, p_swap_buffers=true, frame_step=0.01666666753590107) at servers/visual/visual_server_wrap_mt.cpp:90
[#10](/issue/ValveSoftware/steam-for-linux/10) 0x00000000017e0bfb in Main::iteration () at main/main.cpp:2200
[#11](/issue/ValveSoftware/steam-for-linux/11) 0x00000000017a5ad7 in OS_X11::run (this=0x7fffffffb9f0) at platform/x11/os_x11.cpp:3641
[#12](/issue/ValveSoftware/steam-for-linux/12) 0x000000000179381f in main (argc=1, argv=0x7fffffffc338) at platform/x11/godot_x11.cpp:55

The issue appears to be reproducible on multiple distros with both Intel and AMD Mesa drivers, ~and proprietary Nvidia drivers~ (edit: unconfirmed).

See https://github.com/godotengine/godot/issues/53352 for the corresponding Godot bug report.

Godot is open source, so you can easily compile it from source to debug how Godot's GL context triggers an issue in gameoverlayrenderer.so. See Compiling Godot for Linux, the issue should be reproducible with both the 3.3 (current stable) and 3.x (next OpenGL release) branches.

Steam games exhibiting the issue:

Steps for reproducing this issue:

  1. Export a simple Godot project using the GLES2 (OpenGL 2.1) renderer
  2. Add it to your Steam library as a non-Steam game (alternatively, pick a published game using Godot's GLES2 renderer)
  3. Run it with the Steam Overlay enabled

https://github.com/godotengine/godot/issues/53352#issue-1014357858 includes a zip for such a simple Godot project, that can be exported with e.g. Godot 3.3.4 for Linux. Alternatively, just putting a Godot editor binary (including compiled from source with debug symbols) in the project folder is sufficient to run the project, so this can be used to test the crash too.

Aakien-mga 2021-10-03 github

Some additional details about the Godot part of the stacktrace:

When checking Godot source code, make sure to use either the 3.x or 3.3 branch. The master branch uses Vulkan exclusively so it doesn't trigger this specific issue.

The relevant code for the Linux/X11 platform port is in https://github.com/godotengine/godot/tree/3.x/platform/x11

And specifically the OpenGL 2.1 context is created here using glxCreateNewContext: https://github.com/godotengine/godot/blob/33a42160a02645a6b58874ca008813527e474680/platform/x11/context_gl_x11.cpp#L169-L172

I'm not very familiar with this code but it seems pretty close to the official Khronos tutorial for GLX context creation: https://www.khronos.org/opengl/wiki/Tutorial:_OpenGL_3.0_Context_Creation_(GLX)


Edit: Further debugging, I tested a Windows build with Proton, and it crashes too when using the GLES2 renderer (this can be forced on the command line with --video-driver GLES2).

So the common denominator here would be the actual GLES2 renderer, and not the Linux/X11 GLX context creation.

Aakien-mga 2021-10-12 github

I went through some Godot games I had installed and found a number of other ones which use GLES2 and are now crashing. Updated the OP with more examples.

I had some existing play time in some of these games so it seems like the crash is a regression from either the Steam Overlay, or Mesa (though I've had crashes confirmed on Nvidia too).

This is pretty critical as developers are already uncomfortable enough around providing Linux support (whether natively, which Godot handles well for them, or via Proton). If the Steam Overlay crashes their games it makes it harder to encourage them to support Linux/SteamOS as it appears unreliable and risky.


Edit: Here's evidence that this was already happening as of late August 2021 with Luck be a Landlord: https://steamcommunity.com/app/1404850/discussions/0/3037102935222977730/

Edit 2: I couldn't confirm that this happens with Nvidia proprietary drivers in the end, so this might be a Mesa-related issue. Could be related to issues discussed in #7889 (though the conclusion of that one seems to point at a radeonsi regression, while I can also reproduce the bug with iris).

Aakien-mga 2021-10-12 github

Here's an updated reproducer with a Godot binary (3.3.3-stable), so that it can be tested right away. It includes the most minimal Godot project that would still create a window.

I also took a GL API trace with the included run.sh script, and the trace is included in the zip (I used apitrace 10.0).

gles2_crash_steam_overlay.zip

Aakien-mga 2021-11-11 github

As per https://github.com/godotengine/godot/issues/53352#issuecomment-966265471 the bug seems to happen with Mesa 21.2.5 on Debian Sid, but not Mesa 20.3.5 in Debian 11, so this appears to have been triggered by a Mesa change.

Edit: Additionally, this seems reproducible with llvmpipe too (LIBGL_ALWAYS_SOFTWARE=1 %command%).

Edit 2: Tested in a Fedora 34 VM on VirtualBox, which includes Mesa 21.1.6, and the crash happens there too. So the regression happened between 20.3.5 and 21.1.6.

Edit 3: I built Mesa 21.0.0 on my Fedora 34 VM (specifically https://src.fedoraproject.org/rpms/mesa/c/d0fc8d9e3e975b10b96034936ee712114ad654df?branch=rawhide) and it seems to work fine, so the regression might be in 21.1.0. That's my next test.

Edit 4: Mesa 21.1.0 crashes.

Aakien-mga 2021-11-11 github

I've tested a few Mesa versions on a Fedora 34 VM, and found that Mesa 21.1.0 (release notes) seems to be the first stable release where the bug happens. Mesa 21.0.0 runs Godot OpenGL 2.1 projects + Steam Overlay without issue. I haven't tried 21.0.x maintenance releases, so I don't know if the 21.1 regression might have been cherry-picked to 21.0.x.

Ttarceri 2021-11-12 github

Thanks. I've bisected the regression in Mesa and created an issue here: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5621

Aakien-mga 2021-11-12 github

Amazing, thanks a lot! I see you already found a fix candidate too.

Do you know if there would be any chance to get it included in 21.3.0 (doubt so since it's at RC 5 already) or 21.3.1?

Ttarceri 2021-11-12 github

It will definitely be in 21.3.1 I can try for 21.3.0 but may not make it. It should also get back ported to 21.2.6.

Aakien-mga 2021-11-18 github

@tarceri's fix made it in 21.3.0 :tada: https://gitlab.freedesktop.org/mesa/mesa/-/commit/5275563df4086d85f83cf08b9c4c3e734a49c534

I just got the update on Mageia Cauldron and I can confirm the fix, tested with Ex-Zodiac Demo, Luck Be a Landlord, and Hack Grid. All start fine with OpenGL 2.1 on Mesa 21.3.0.

So this is issue can be closed as fixed upstream.

To summarize for affected users, Mesa version between 21.1.0 and 21.2.5 are affected.
The fix is available in:

  • Mesa 21.3.0 and later
  • Mesa 21.2.6

If your distro Mesa maintainers can't upgrade, you can ask them to cherry-pick https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13773.

Launch lines