Skip to content
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

Allow libopengl.so to be used when GLX_LIB is missing #257

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

batesj
Copy link

@batesj batesj commented Jun 17, 2021

This maintains compatibility with previous behavior of
always using GLX_LIB if it is found. The only change is
when there is no GLX_LIB.

Previous behavior when no GLX_LIB:

  • abort.

New behavior when no GLX_LIB:

  • Try to load libOpenGL.so as gl_handle (glx_handle remains NULL).
  • Else, abort.

@batesj
Copy link
Author

batesj commented Jun 17, 2021

@ya-isakov @tomeuv @ebassi

PTAL. Also, if you have a repro with one of the known downstream failures caused by #229, it would help to have someone test one of those cases.

@batesj
Copy link
Author

batesj commented Jun 22, 2021

ping.

@ya-isakov
Copy link
Contributor

ya-isakov commented Jun 22, 2021

@batesj Checked it on my libGL-free system - it works:

openat(AT_FDCWD, "/usr/lib64/libGLdispatch.so.0", O_RDONLY|O_CLOEXEC) = 16
....
openat(AT_FDCWD, "/usr/lib64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib64/libOpenGL.so.0", O_RDONLY|O_CLOEXEC) = 21
openat(AT_FDCWD, "/lib64/libGLX.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib64/libGLX.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib64/libGLX.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib64/libGLX.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

(spam about libGLX.so is caused by lack of check, which I had in one of my other patches)
Without your patch, vanilla libepoxy:

openat(AT_FDCWD, "/usr/lib64/libGLdispatch.so.0", O_RDONLY|O_CLOEXEC) = 16
openat(AT_FDCWD, "/usr/lib64/libOpenGL.so.0", O_RDONLY|O_CLOEXEC) = 21
....
openat(AT_FDCWD, "/usr/lib64/haswell/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib64/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, "Couldn't open libGL.so.1: libGL."..., 96Couldn't open libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory

But previous one worked for me, too, so, somebody with Xorg should also check...

@batesj batesj marked this pull request as ready for review June 25, 2021 23:50
@batesj
Copy link
Author

batesj commented Jun 25, 2021

I've tested this extensively now in Chrome OS and confirmed that it works to enable the use of libOpenGL.so while not changing behavior of existing libGLX expectations. For example, confirmed that this libepoxy change does not break crostini apps when libopengl0 is installed.

@batesj
Copy link
Author

batesj commented Jun 28, 2021

@ebassi ptal

@ebassi
Copy link
Collaborator

ebassi commented Jun 28, 2021

Let's see if the people having issues in #252 and #240 can test this: @Ernest1338 and @evelikov

As an aside: there's no point in pinging me. I receive all bug mail for libepoxy.

@kev009
Copy link

kev009 commented Jun 28, 2021

LGTM from code inspection, we didn't experience any known crashes on FreeBSD that I am aware of but just switched to libglvnd everywhere so would like to drop the direct GLX dependency.

@evelikov
Copy link

evelikov commented Jun 30, 2021

From a quick look libGL -> libOpenGL fallback sounds like the right thing to do. Thank you.

I would suggest a couple of things:

Doubt I can test it at the moment @linkmauve - do you have some time to check this on your end?

@batesj
Copy link
Author

batesj commented Jun 30, 2021

Does the test need to be in this pull request or can it be a followup? The nature of this change is at the level of attempting to open libGL.so.1 and libOpenGL.so.0 so a test could have have dummy libraries that confirm libGL.so.1 is loaded if it exists, and then fall back on libOpenGL.so.0.

@Ernest1338
Copy link

I'm on vacation at the moment, I will test this when I get home.

@evelikov
Copy link

evelikov commented Jul 1, 2021

Does the test need to be in this pull request or can it be a followup? The nature of this change is at the level of attempting to open libGL.so.1 and libOpenGL.so.0 so a test could have have dummy libraries that confirm libGL.so.1 is loaded if it exists, and then fall back on libOpenGL.so.0.

I don't have a preference if tests come here or as follow-up.

The test you outlined doesn't sound super useful. Tests which do functional testing, similar to the bugs #240 #252 and even #253 would be much more valuable. Mind you I did not trace each use-case, so it might be that they all follow the exact same problematic pattern.

Note: the tests are a suggestion, ultimately it's not my call to make.

@batesj
Copy link
Author

batesj commented Jul 1, 2021

Perhaps there's an easy github workflow that would repro some of the original integration bugs in #240, #252 and/or #253. There is some investigation to be done for that, so would prefer to not block this CL -- filed #258 for that.

In the mean time this CL fixes the bug that @ya-isakov described in #229 (comment). To reiterate the motivation here: without this fix, it is impossible for a wayland-only system to use OpenGL via libepoxy.

@kev009
Copy link

kev009 commented Jul 1, 2021

From the outside it seems like this is an acceptable workaround to an issue that is not very well understood. With my cursory inspection it seems to require non-trivial knowledge of how these handles are used everywhere (which might affect library-consumers?) and whether there are known or unknown limitations with libOpenGL in a GLX setup. Until the issue is better understood, it is difficult to prescribe a test plan, and the salient change is to preserve old known good behavior for GLX.

This is probably obvious to most but I'll just write it here for completeness: libGL == libOpenGL + libGLX.

@batesj
Copy link
Author

batesj commented Jul 1, 2021

Done.

src/dispatch_common.c Outdated Show resolved Hide resolved
@evelikov
Copy link

evelikov commented Jul 2, 2021

@batesj I'm aware how annoying libGL.so can be. In case it's unclear - I'm not suggesting we should block this MR. I did said "suggestion" and not "requirement" exactly for that reason ;-)

@batesj
Copy link
Author

batesj commented Jul 2, 2021

Thanks for the review, @evelikov!

This maintains compatibility with previous behavior of
always using GLX_LIB if it is found. The only change is
when there is no GLX_LIB.

Previous behavior when no GLX_LIB:
- abort.

New behavior when no GLX_LIB:
- Try to load libOpenGL.so as gl_handle (glx_handle remains NULL).
- Else, abort.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
@Ernest1338
Copy link

So I tested this, and found no issues (related to Xorg at least). ;)

@batesj
Copy link
Author

batesj commented Jul 12, 2021

Thanks for testing @Ernest1338, sounds like we can land this then.

@ebassi
Copy link
Collaborator

ebassi commented Jul 12, 2021

I agree. Thanks to everyone who tested this, it's very much appreciated.

Thanks @batesj for working on this, as well.

@ebassi ebassi merged commit ecfa8e0 into anholt:master Jul 12, 2021
@batesj
Copy link
Author

batesj commented Jul 12, 2021

Thanks @ebassi, let me know when you think we can release version 1.5.9 with this change.

@batesj batesj deleted the allow_libopengl branch July 15, 2021 21:45
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.

6 participants