_eglNativePlatformDetectNativeDisplay() (called by eglGetDisplay()) detects Wayland by checking if the native display object starts with a pointer to wl_display_interface. Unfortunately wl_display_interface is defined in both libwayland-server.so and libwayland-client.so. libEGL links to both and in all my tests it always picks the one from libwayland-server.so. The wl_display object passed as native display however contains the version from libwayland-client.so so the check fails. There is an old thread about this[1] on the wayland-devel list, but it seems nothing happened since then. [1] https://lists.freedesktop.org/archives/wayland-devel/2014-October/017783.html
eglGetDisplay() is by definition broken on multi-platform implementations, yes. Any reason you cannot use EGL_KHR_platform_wayland?
(In reply to Pekka Paalanen from comment #1) > eglGetDisplay() is by definition broken on multi-platform implementations, > yes. Ugh. It is broken by definition, but Mesa does go to great lengths to try to make it work by auto-detecting: see _eglNativePlatformDetectNativeDisplay() inside src/egl/main/egldisplay.c. Michael, I'll attach a compiled but untested patch; can you please let me know if it helps?
Created attachment 135490 [details] [review] egldisplay-try-interface-name-for-wl-display.patch
<cheeky> I do recall mentioning that exposing the same symbol(s) will lead to bad experiences. Followed by some ideas... </cheeky> WRT eglGetDisplay - I'd recommend moving towards the EGL_*_platform_* extensions ASAP - EGL_EXT_platform_wayland or EGL_KHR_platform_wayland in this case. A better heuristic would be to use dladdr() for eglGetDisplay. See the analogous GBM patch [1]. https://patchwork.freedesktop.org/patch/187918/
(In reply to Emil Velikov from comment #4) > <cheeky> > I do recall mentioning that exposing the same symbol(s) will lead to bad > experiences. Followed by some ideas... > </cheeky> Yep, as per the discussion on inlining wayland_drm_buffer_get. :) It certainly hurts, but then again breaking ABI and forcing every single Wayland user to rebuild - probably having to change every symbol name in the API to make sure there was no clash between the two when loaded - would be uncharted depths of pain. On the other hand, the solution is the same: look at the interface name, rather than ever compare pointers equally. Unfortunately, we can't use the same solution since the wayland-drm one only works for wl_resource in libwayland-server rather than a plain wl_interface or a wl_proxy ... oh well. > A better heuristic would be to use dladdr() for eglGetDisplay. See the > analogous GBM patch [1]. I don't think that would necessarily fix it, particularly if the wayland-client.so.1 being loaded differed, e.g. due to people linking their own copies?
(In reply to Daniel Stone from comment #2) > Michael, I'll attach a compiled but untested patch; can you please let me > know if it helps? Looks good. It does the right thing for wayland and drm at least. is _eglPointerIsDereferencable() sufficient to ensure that the whole string is accessible?
(In reply to Michael Olbrich from comment #6) > (In reply to Daniel Stone from comment #2) > > > Michael, I'll attach a compiled but untested patch; can you please let me > > know if it helps? > > Looks good. It does the right thing for wayland and drm at least. > is _eglPointerIsDereferencable() sufficient to ensure that the whole string > is accessible? Good point - I guess it'd have to be if (_eglPointerIsDereferencable(child_pointer) && _eglPointerIsDereferencable(((char *) child_pointer) + strlen("wl_display") + 1) && strcmp(interface->name, "wl_display") == 0) ... ugh. Does that work for you?
(In reply to Daniel Stone from comment #7) > Good point - I guess it'd have to be if > (_eglPointerIsDereferencable(child_pointer) && > _eglPointerIsDereferencable(((char *) child_pointer) + strlen("wl_display") > + 1) && strcmp(interface->name, "wl_display") == 0) ... ugh. Does that work > for you? Yes that works.
(In reply to Pekka Paalanen from comment #1) > Any reason you cannot use EGL_KHR_platform_wayland? It's not my code. It's somewhere in gstreamer-vaapi. I was just debugging why my application was crashing.
(In reply to Michael Olbrich from comment #9) > (In reply to Pekka Paalanen from comment #1) > > Any reason you cannot use EGL_KHR_platform_wayland? > > It's not my code. It's somewhere in gstreamer-vaapi. I was just debugging > why my application was crashing. Ok, while this issue is being worked on in Mesa, I would very much recommend filing a bug against gstreamer-vaapi to start using the EGL platform extensions whenever available. It's the only reliable way forward.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/171.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.