-
Notifications
You must be signed in to change notification settings - Fork 113
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 dust off2 #531
Egl dust off2 #531
Conversation
…d HAVE_EGL is not defined. Broke GLX.
I have now tested this, and can confirm it makes FreeCAD run on Wayland. As far as I can tell, this fixes... |
However, if one tries to create a rectangle in FreeCAD Sketcher, SIGSEGV happen. Vertices and distance constraints work fine, but arcs, rectangles and lines causes a crash. @luzpaz, @katepavlu, @euphi or @ramast can you try to compile for this branch on Wayland(!) and see if you get the same issues?
Coin error in SoGroup::removeChild(): tried to remove non-existent child 0x561a5d7621f0 (Annotation)
|
I can't compile on my setup at this time. Maybe some of these folks can ? |
I tried latest 1.0 branch of freecad on kde neon (more or less ubuntu 22.04). I have to set env-variable COIN_GL_NO_CURRENT_CONTEXT_CHECK to avoid triggering of an assert but apart from that it seems to work, creating rectangles, lines, arcs does work. |
@rmu75 just to clarify: it works using sketcher having compiled FreeCAD with this Coin branch? And you are sure you chose EGL build when compiling coin, using build flag? |
I compiled against benj5378:eglDustOff2 branch. Pretty sure it is using native wayland as the font rendering and dpi scaling looks completely different vom my XWayland setup. And the log is spammed with "(qt.qpa.wayland) Wayland does not support QWindow::requestActivate()" messages which don't appear when using XWayland. Rotation and panning is very smooth, but zooming is stuttering and causes spikes in CPU usage and immediate spin up of cpu cooler. |
Sometimes a warning |
I will re-check if it is really using EGL and not some kind of software rendering. Seems I was overly enthusiastic and didn't compile with COIN_BUILD_EGL enabled... will re-check. |
So I rebuilt libcoin with COIN_BUILD_EGL enabled, ldd confirms that FreeCAD imports libEGL.so next to libOpenGL and libGLX, but nonetheless I suspect it is using software rendering. |
So after rebuilding FreeCAD situation is more or less unchanged, it seems to work as usual when started with QT_QPA_PLATFORM=xcb. With QT_QPA_PLATFORM=wayland zooming is a bit sluggish and CPU usage seems to be higher but everything including sketcher seems to work. How can I check if it is really using EGL? |
@rmu75, if you used the |
Perhaps you can find a GPU monitoring tool that will show whether your process is software rendering or not? |
running with EGL_LOG_LEVEL=debug spews out a bunch of debug info like
so at least EGL seems to be initialized. Not sure how to proceed, out of time for today. |
running with LIBGL_ALWAYS_SOFTWARE is a big difference (nothing is smooth any more) so I'm pretty sure that without that it is actually using the GPU. |
AFAIU without COIN_BUILD_EGL this doesn't link to libEGL. But even then EGL is loaded dynamically if needed (via egl glue code?). |
I opened up a project for tracking Wayland and OpenGL ES support. It should be public now. |
I managed to compile libcoin and FreeCAD with
Before the crash I also get some warnings:
With
It's strange that libEGL is using the i915 driver because I have a discrete NVIDIA card that it's supposed to use not the integrated GPU.
Please note that the system packages
|
There is a very thorough investigation of the issue here (I think it's the same) FreeCAD/FreeCAD#16316. I don't think it's Wayland related though. Can you please |
bump |
Me and @hyarion have been considered what might be needed to maintain Coin for future use in FreeCAD. This includes EGL support and reaction to OpenGL currently being outphased in the industry. Might be on hold until FreeCAD community have taken a decision on whether Coin should be used forward on. I have no experience with Coin or EGL. I could read tons of docs on how to support EGL, but currently looking for people with experience in the area to help out. For example with seg faults arising, that I have no idea to why is happening (having zero Coin experience at all). |
At FreeCAD we currently have no plan to migrate out of coin. There have been several discussions among developers about it, and while coin is not actively being worked on, it's a fantastic library, many developers love it, it is simple to use, suits perfectly the needs of FreeCAD, and is extensible enough so it should provide the few things we feel are missing in FreeCAD (shadows, ambient occlusion, "filled" sections, etc) Also, a big question if we thought of replacing it (which would be very extensive work), would be: replacing it with what, and there is no clear or easy answer to that question. For me the conclusion to those discussions was that FreeCAD developers clearly want to stick with coin, and, if needed (basically: if maintenance or packaging become a problem, or if coin maintainers would want that), we would I think be ready to carry its maintenance ourselves. |
Just to give some insight the discussion between me and @benj5378 that benj referred to. The only real issue we identified with coin is that it seems to be quite tightly coupled with OpenGL (in compatible mode). I can't see into the future but it seems like the industry is moving away from OpenGL towards a more fragmented space with vulcan, dx and metal. OpenGL is already deprecated by on apple devices, though still available (https://developer.apple.com/documentation/apple-silicon/porting-your-macos-apps-to-apple-silicon) In order to use coin on a future platform, where OpenGL is not available, it might be needed to look over the backend. Maybe switching over to vulcan or a low lever library like bgfx would be necessary. Another issue to keep in mind is that freecad is using some features like line stipple more frequently, and these will soon require workaround as they are not well supported on various platforms (apples OpenGL driver causes quite ugly stipples when they are used with a line width. Some older mesa libraries are failing completely). If there would be a plan to swap OpenGL to something else, then it would be better for freecad if that is done before more features which ties it closer to OpenGL is implemented. I agree that both coin has served us well and that there's currently no need to use anything else in freecad. Changing from coin to another engine does not look like a good option, but improving coin if needed, does. |
I looked at MGL on Apple M3 laptop to see if that technology could be used as a wrapper on metal for bringing Coin OpenGL to the new Apple machines. The MGL open source is very poorly supported and I was unable to bring up the test suite on it. So I'm not recommending that approach without an investment in fixing it/MGL. It would be interesting to see if the low-level, OpenGL-based rendering interface for Coin could be made abstract and generic enough to support different 3D rendering pipelines. It may be a pipe dream, though, and take a considerable amount of work with lots of limitations for each platform. |
Great to see this discussion. I have been working ocasionally on this task, started from the EGL PR and been trying to convert Coin3D to work with modern OpenGL. Incidentally I started with a separate branch for a bgfx-based renderer, like you suggested, but eventually switched back to just porting the existing renderer to modern OpenGL, with the eventual to get FreeCAD to run on the web with WebGL. I haven't worked on it in a bit, but I think I had some basic geometry rendering with shaders on the web with Emscripten-based setup, as well as compatibility profile feature gating. Would be glad to clean it up and share it if someone would like check it out and/or help move things along. |
Exactly that was the motivation a few years ago when I started to move Coin over to Github and spent a large amount of time to get the build process running with GitHub Actions. To me Coin seemed to good to let it die. I have used it a very long time in a physics simulation software for visualisation.
I coudn't answer that either and spent some time with Qt3D, but Coin feels to me more like batteries included. It's easy to quickly get something up and running.
As for now packaging is not a problem. Releasing is simply adding first time contributors to the THANKS file, adding ChangeLog file, bumping the version number and tagging the release. Everything else runs fully automated on Github and AppVeyor. And, most linux distributions and vcpkg include a ready to install package for Coin, simage, SoQt and Quarter. As FreeCAD is one of the largest software packages using Coin, please drop a issue or a note when a new minor or major release is planned and some fixes need to be released. |
AFAIK Coin3d/FreeCAD only requires OpenGL 2.0, which should be well covered by ANGLE: |
ANGLE only implements OpenGL ES, which does not cover the immediate mode subset of OpenGL that Coin3D uses. |
the discussion that is going seems like it's better have in the issue rather than on a pull request, it is not clear to me what is the status of this PR, are there remaining problems with it? |
I compiled your branch (following the orignal Coin's INSTALL.MD) and used it against Freecad but the issue still occurs, I might be doing something wrong:
Very laggy and completely white 3d view. Specs:
Could you please write a small list of steps of make your coin branch work for freecad? |
Your log shows references to
I think there may have been some problem detecting EGL on your system and it was not built. |
@VolkerEnderlein The EGL support effort has been sitting still for a few years now, with seemingly no plan in sight to merge it. I have a few local improvements on top of this for which I would like to send PR, but at this rate not sure how to plan it. As well as a more wider effort to introduce modern OpenGL rendering support (ES 2.0+ / 3.0+), but at this rate I am worried to even spend so much effort on it for it to be code rotting in the PR queue. I recently discussed in FreeCAD Discord development channel about this work and about this specific concern. Everyone feels like working with upstream is the way to go, but we need some kind of support from your side to make it happen. Without some support/changes, the only action left to take, in my opinion, is to advocate for and create a FreeCAD-specific fork of Coin3D where development can happen going forward. |
@benj5378, I can reproduce the segfault you get but this also happens on the coin master branch, 4.0.3 tag and on this branch with COIN_BUILD_EGL = OFF. This happens when building Coin with a Debug build type. If I use a RelWithDebInfo build type the segfault does not happen. So I think it is safe to say that this PR is not the source of the segfault and so we can probably ignore it for this PR. However, FreeCAD + Coin with COIN_BUILD_EGL = ON does not use wayland on my PC. when using xeyes, the eyes are following my mouse while hovering FreeCAD, indicating it is not wayland. |
Actually I had to install qt6-wayland in my FreeCAD pixi environment and now FreeCAD starts with wayland but the 3D view is all white and I get Coin (Debug build) error messages:
|
Thanks for reaching out @tritao, is there anything I can do to support your work? Should we create a new branch on the Coin side that bundles all the EGL work that has been done so far to make development easier? My knowledge about EGL and Wayland is very limited up to now, so I was happy when @WizzerWorks jumped in to support you. Cheers, Volker |
So my previous message was on my PC with RTX 3060 Ti and driver 565.77 on Fedora 41 KDE. I just tried this branch on my laptop which has integrated intel graphics UHD 630 and then it just works. But when I run on the dedicated GPU in my laptop GTX 1050 with driver 565.77 on Fedora 41 KDE then I also get a white screen and errors. So maybe a NVIDIA problem....? |
I think this crash is similar to a Coin3D mismatch that happens with system Pivy, I added some more details and how to solve it here: FreeCAD/FreeCAD#16316 (comment) |
@VolkerEnderlein About my work, I think an official branch would be great, but what would be best is if you can take a look at the code and design changes, and make sure the design follows what you think is the best practices for Coin3D. However, that work is a bit independent from this EGL work and we can discuss it later once I start sending some PRs. This EGL PR is green, has been tested to work, and additionally does not really change behavior for Coin3D unless COIN_BUILD_EGL is enabled. I think what we are missing here now is a code review from you, and some kind of actionable feedback to get this merged. |
LGTM, I'll merge the branch into Coin. Thanks for the fantastic work. |
Thanks to everyone who worked on this! |
For FreeCAD purposes, I think it would be best to wait until EGL support can be improved so allow it being chosen at runtime, because with the version on this PR its either used exclusively or not (at compile time). I'm planning to send something like that once I have some time to work more on it, hopefully not too far away :) |
The purpose of this PR is to clean up #471, add b49b8b4, rebase, and trigger CI in a non-draft PR.