-
Notifications
You must be signed in to change notification settings - Fork 44
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
EGL contexts in GrDirectContext.MakeEGL #294
base: main
Are you sure you want to change the base?
EGL contexts in GrDirectContext.MakeEGL #294
Conversation
…L contexts with EGL There are two ways of enabling EGL support on Linux AFAIK: `skia_use_egl=true` switches over to X11 completely. Or we just add `GrGLInterfaces::MakeEGL` to GLX builds. This is the 2nd approach. `skia_use_egl=true` is simpler, but modifies existing X11 behavior. Fixes kyamagu#287
This pull is complete as is (with tests etc), but I am against merging, for reasons of doubting its being generally useful and long-term effort of maintaining the addition. |
The mac 13 Intel build unfortunately is expected to fail because of actions/runner-images#11241 . If that's the only failed job, re-run when that issue is addressed. |
I need to test this here, it is certainly an oversight: the egl api works in X with real hardware, and work headless with real hardware. I have never tried doing EGL with Xvfb - it looks like the EGL API segfaults in software-only X! This isn't a surprise on hindsight: the whole point of EGL is to use real GPU without X, so I have never tried it with software-only Xvfb. So the EGL API needs to detect when is Xvfb and just bail, rather than segfault. |
Cannot reproduce the problem locally, but the most likely source of segfault is that Xvfb is not capable of EGL in CI. This change allows EGL context to fail if under "some sort" of X.
…keGL Another go at fixing EGL segfault - maybe the libEGL's are too old: On EL7, EGL/egl.h is in mesa-libEGL-devel instead of libglvnd-devel (later Redhat) Missing GLES2/gl2.h - in mesa-libGLES-devel
Looking more carefully, the segfault in CI seems to be on load, rather than at the specific tests. And with the other changes (the EGL headers are in different packages compared to current redhat/fedora - my own system), really suggests that the segfault is a side-effect of #175 - building against an old libEGL and running on new system can segfault; hence my latest addition to this pull. This adds to my reservation against merging this - the EGL libraries seems to be not backward ABI compatible, hence not expected to be compatie across vendor either. I.e. @Swarzox you should take this pull and build it on your platform against the system's own EGL, whatever it is shipped with. Don't use binary wheels from somebody else. |
The current gn code still has this problem, so upgrading gn isn't useful. Hence a custom patch.
This reverts commit 2fa072e. Current gn has this fixed: commit 0725d7827575b239594fbc8fd5192873a1d62f44 Author: David 'Digit' Turner <digit@google.com> Date: Tue Jan 18 12:14:01 2022 +0100 Remove misc GCC-related compiler warnings.
Current gn does not like being compiled with older g++:
While older gn doesn't like being compiled with newer g++ (though we had a patch for this earlier) |
See python/cpython#128161 "Defining iterator in a separate class no longer works in 3.13" We have iterator for SkTextBlob defined by SkTextBlob::Iter(textblob), which is the c++/pybind11 equivalent of the same situation. Following the suggestion: python/cpython#128161 (comment) Also see actions/runner-images#11241 Fixes kyamagu#295
…rDirectContext.MakeGL
…t's the problem with segfault
…are installed, but you never know
I am going to close this, tidy up and redo. The bottom line is that the bulk of the changes are correct and work as intended, if you build and test directly on the platform - I have replicated my desktop's success in github CI: This basically adds to the opinion against merging this - it is okay as an enhancement if you build skia-python yourself on the platform you intend to run egl headless, but binary wheels built with this patch on one linux isn't compatible with another Linux. @Swarzox . |
gn is really written for clang. Later version of gn has this fixed, but won't build on older g++ (12) for another problem. Sigh. Staying in this version of gn for the main builds. Fedora ships gn actually, though it is a lot more change to adapt to this.
Filed pypa/cibuildwheel#2118 for the segfault. The bundled libEGL is what causes the segfault. If I disable the tests and download the untested wheel, run What happens, I think, is this: libEGL is a stub/ trampoline library from the libglvnd project to load libEGL_* from GPU vendors or mesa on a per screen basis. It must be next to the vendor's to be useful. Loading a relocated copy means it can't even find the mesa one for typical fallback, therefore it crashes on load. |
The instruction to fix the wheel is:
For the python 3.13 wheel, after installed in user location. |
I have added a stanza in the ci to build skia-python and test egl on fedora the conventional way, and it passes. @Swarzox |
Small doc update after retesting the patchelf instructions (the 8 hex digits I assume are checksums of the libraries; they changed as I switched the build hosts back to 2_28). You can download the build artefact, install and run patchelf to correct the wheels @Swarzox . I'll be interested to know if you can run the patchelf'ed wheel directly against your headless system. |
Some of this (doing a direct fedora build and testing on it) is useful, so i probably will copy them over to m134, but there isn't much point of tidying - most of the mess is in the testing code, the fundamental is in the skia patch and |
This is a slightly different way of addressing #287 . I am posting this just as a reference for @Swarzox , and if he wants to try the CI builds to see if it works in his usage. Personally, I am against merging this in its current form, for 3 reasons:
Fixes #287
Cc @Swarzox this pull add two new ways of getting a GL context:
skia.GrDirectContext.MakeGL(skia.GrGLInterface.MakeEGL())
andskia.GrDirectContext.MakeGL(skia.GrGLInterface.MakeGLX())
, to explicitly initialize GL contexts in those two ways.skia.GrDirectContext.MakeGL()
is still via GLX. As I commented in #287 , if you setskia_use_egl=true
when building skia, the default switches to via EGL.I'd be interested in two things:
Depending on the answer to the 2nd question, we might still think about merging this, if there is a good reason...