The X11 apps on egl will crash when mesa 20.0.2 is configured as multiple platform support while "x11" is not the first one
Hi all,
When mesa is configured with argument "-Dplatforms=wayland,x11,drm,surfaceless", in meson.build, the "wayland" is the first element of "platforms" and the "egl_native_platform" will be "wayland", then in src/egl/meson.build, _EGL_NATIVE_PLATFORM will be assigned to be _EGL_NATIVE_WAYLAND. And in the commit 86d3a346 ("egl: fix _EGL_NATIVE_PLATFORM fallback"), the function _eglNativePlatformDetectNativeDisplay delete the return value _EGL_PLATFORM_X11 when detecting "wayland" and "gbm" failed, this will result that in _eglGetNativePlatform the platform type will be _EGL_NATIVE_PLATFORM which is equal to be _EGL_NATIVE_WAYLAND.
So when an X11 app using egl: x_dpy = XOpenDisplay(NULL); ... dpy = eglGetDisplay((EGLNativeDisplayType) x_dpy); eglGetDisplay will run into crash because libEGL.so detected the wrong platform type.
There maybe 3 solutions:
-
In Documents, notify the users to put "x11" as the first in "-Dplatforms" when they want to use libEGL running in X11 system.
-
Change meson.build by applying the patch in attached file "1.patch"1.patch
-
revert the commit the commit 86d3a346 ("egl: fix _EGL_NATIVE_PLATFORM fallback").
BTW, maybe "haiku" has the same issue but I have no platform to test it. And this x11 issue can be reproduced at many boards.