Bug 263209 - cad/kicad: should provide an option to be built without EGL
Summary: cad/kicad: should provide an option to be built without EGL
Status: Closed Not Accepted
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Christoph Moench-Tegeder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-10 20:09 UTC by Robert Clausecker
Modified: 2023-06-15 01:55 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (cmt)


Attachments
cad/kicad: add option EGL (1.46 KB, patch)
2022-04-10 20:09 UTC, Robert Clausecker
fuz: maintainer-approval? (cmt)
Details | Diff
pkg info wx31-gtk3 (2.04 KB, text/plain)
2022-04-16 21:10 UTC, Josef 'Jeff' Sipek
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Clausecker freebsd_committer freebsd_triage 2022-04-10 20:09:04 UTC
Created attachment 233135 [details]
cad/kicad: add option EGL

I'm running FreeBSD 13 on a Dell Precision M4800 laptop.  This laptop has a graphics card that requires the old nvidia-driver-340 to work; more recent drivers lead to surprises when waking up from suspend-to-RAM.

Unfortunately this driver is too old to support EGL, so when starting the kicad circuit editor, I get an undefined symbol error (for eglGetPlatformDisplay used by wx31-gtk3 libraries) due to the missing EGL support.

While there is no fix, this can be worked around by compiling kicad without EGL support.  This requires toggling the KICAD_USE_EGL cmake option which is currently hard wired to "on".  The attached patch adds an option to kicad (it probably also applies to kicad-devel), permitting EGL to be turned off.

Tested on amd64 FreeBSD 13.
Comment 1 Robert Clausecker freebsd_committer freebsd_triage 2022-04-16 16:41:40 UTC
Apparently the situation is more complicated than that: disabling EGL only works (and is required) if x11-toolkits/wxgtk31 is compiled without EGL support (a patch is needed for that).  Will check if I can submit a patch to that port.
Comment 2 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2022-04-16 20:57:16 UTC
eglGetPlatformDisplay is from libEGL of libglvnd's fame, isn't it? Why would that symbol be missing? libEGL is non-optional, as far as I can see (libGL and libGLX can be deselected via X11).
Can you show the output of "pkg info wx31-gtk3"? How are your packages built?
Comment 3 Josef 'Jeff' Sipek 2022-04-16 21:10:22 UTC
Created attachment 233258 [details]
pkg info wx31-gtk3

I've gotten the same issue on a desktop running old nvidia card (and driver).  I filed a bug with upstream KiCad but they closed as an unsupported OS/distro problem.  I'm attaching the 'pkg info wx31-gtk3' output.  All the relevant packages are from the quarterly ports repo.

[1] https://gitlab.com/kicad/code/kicad/-/issues/11369
Comment 4 Robert Clausecker freebsd_committer freebsd_triage 2022-04-16 21:30:41 UTC
(In reply to Christoph Moench-Tegeder from comment #2)

These libraries are overridden by the libraries of the graphics driver in use.  So the actual library used is probably /usr/local/lib/libnvidia-eglcore.so from nvidia-driver-340 which doesn't have this symbol.

In the example where it does not work I use wx31-gtk3 from binary packages.  In my working example I use a custom build with the patch from bug #263347 applied and option GLCANVASEGL disabled.

Note that the patch I submitted will have to be changed because the EGL option must be set to the same value as the GLCANVASEGL option from wx31-gtk3.  Perhaps having cmake just auto-detect it is the best solution.
Comment 5 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2022-04-17 21:40:58 UTC
(In reply to Robert Clausecker from comment #4)

What, overrides? What the fresh heck?
Oh, I see: the "old" nvidia driver does not "not support EGL" - according to https://www.nvidia.com/Download/driverResults.aspx/68326/en-us it does, since 331 from 2013 - but the packages for the older (<410) drivers install a libmap configuration to remap libEGL to libEGL_nvidia, and that has only a subset of the EGL API and most promimently it's missing our beloved eglGetPlatformDisplay(), which was added in EGL specification 1.5 - https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglGetPlatformDisplay.xhtml - from 2014. That's an espacially shitty situation as the libEGL wxgtk is linking against (the one from libglvnd) is not the one it's running with (the one from nvidia-driver-340, in your case).

So this boils down to "the graphics driver downgrades your system, and now it doesn't support 8 year old interfaces anymore as that driver was specced out before that and now you're in a world of hurt", and it's not a kicad issue but the old nvidia-driver screwing your system libraries.

wxgtk does the right thing and checks for "egl >= 1.5" to exist (configure line 42903), but again, that's for naught if you get a different library at runtime.
Comment 6 Tomasz "CeDeROM" CEDRO 2022-05-08 11:33:28 UTC
Thank You CMT! I can confirm 3D View now works :-) That also fixes https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262802 :-)
Comment 7 Josef 'Jeff' Sipek 2022-12-03 04:08:31 UTC
Do you have any suggestions for a workaround?  I've been running kicad in a vm to avoid this issue and it's a headache.
Comment 8 Tomasz "CeDeROM" CEDRO 2022-12-03 04:41:07 UTC
Is this a runtime or build issue?

Will setting graphics to Fallback in place of Accelerated help?

Maybe this could be reported to the upstream?
Comment 9 Josef 'Jeff' Sipek 2022-12-03 04:54:04 UTC
(In reply to Tomasz "CeDeROM" CEDRO from comment #8)
> Is this a runtime or build issue?

Well, it shows at runtime but I could argue it either way.  I'm *far* from an expert on X or anything graphics.  I'm not sure if this is a kicad has an issue, kicad port builds with assumptions that are not true at runtime, or nvidia driver port doesn't have some "flag" to indicate it's lack of EGL support.

> Will setting graphics to Fallback in place of Accelerated help?

How do I try this?  Or do you mean switch from nvidia to vesa in X?  I suppose that should work, but would make anything using OpenGL unbearably slow.  Or is there a way to force just one application to to not use EGL?

Hm, I see a "Rendering Engine" option in kicad - it's already set to fallback for the schematic editor (and others) and that still dies with a 'Undefined symbol "eglGetPlatformDisplay"'.

> Maybe this could be reported to the upstream?

I did way back in April (see comment #3), but they don't care about FreeBSD issues.
Comment 10 Tomasz "CeDeROM" CEDRO 2022-12-03 05:03:48 UTC
(In reply to Josef 'Jeff' Sipek from comment #9)

>> Will setting graphics to Fallback in place of Accelerated help?
> How do I try this?  Or do you mean switch from nvidia to vesa in X?

There are options for Schematic and PCB editor in their Preferences (not the main KiCAD app) where you can select rendering mode Accelerated or Fallback. Fallback is the software rendering and it may help..?

Without this EGL I would not see the 3D Viewer with rendered board nor do anything like export etc. I have switched to kicad-devel for some time. The kicad port now works fine with acceleration for me.. but the file format still did not catch the devel version so I am somehow stuck with devel with some projects I already did with devel version o_O

>> Maybe this could be reported to the upstream?
> I did way back in April (see comment #3), but they don't care about FreeBSD issues.

Yup. They do not only not care about FreeBSD but also files and libraries compatibility which is really annoying "by design".. but there is no other alternative so far :-(
Comment 11 Josef 'Jeff' Sipek 2022-12-03 05:09:36 UTC
(In reply to Tomasz "CeDeROM" CEDRO from comment #10)
> There are options for Schematic and PCB editor in their Preferences (not the main KiCAD app) where you can select rendering mode Accelerated or Fallback. Fallback is the software rendering and it may help..?

It doesn't.  Note that I get get the symbol error when I try to open a schematic of any kind (even an empty one from a new project).  That is, I fire up `kicad`, open a project, and double click on the schematic file ==> linker error & crash.

This happens with both ports - kicad and kicad-devel.
Comment 12 Tomasz "CeDeROM" CEDRO 2022-12-03 05:23:28 UTC
Ugh :\

How about editing ~/.config/kicad/ by hand to enforce Fallback rendering?

How about switching to x11-drivers/xf86-video-nv ? Last update was on September 2022 so maybe it will do the job?

https://www.freshports.org/x11-drivers/xf86-video-nv/
Comment 13 Robert Clausecker freebsd_committer freebsd_triage 2022-12-03 11:39:05 UTC
(In reply to Josef 'Jeff' Sipek from comment #7)

Apply patches from attachment #233135 [details] and attachment #233255 [details].  Then build x11-toolkits/wxgtk31 without GLCANVASEGL and KiCAD without EGL.  Lock these packages so they won't get overwritten by automatic updated.  Then it just works.
Comment 14 Josef 'Jeff' Sipek 2022-12-03 18:06:04 UTC
(In reply to Robert Clausecker from comment #13)
> Apply patches from attachment #233135 [details] and attachment #233255 [details].  Then build x11-toolkits/wxgtk31 without GLCANVASEGL and KiCAD without EGL.  Lock these packages so they won't get overwritten by automatic updated.  Then it just works.

The box I'm on uses Latest (instead of Quarterly) so I had to build wx32-gtk3 instead.  However, the schematic editor fires up now.  Time for some circuit drawing fun :)  Thanks!
Comment 15 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2022-12-05 20:44:57 UTC
(In reply to Josef 'Jeff' Sipek from comment #7)
I'd suggest to yeet that ancient driver and any hardware attached to it with prejudice. When your graphics driver replaces essential libraries and disappears interfaces which should be there for at least half a decade you're rather screwed.
Comment 16 Robert Clausecker freebsd_committer freebsd_triage 2022-12-05 21:02:26 UTC
(In reply to Christoph Moench-Tegeder from comment #15)

Clearly the notion of running FreeBSD on a top-of-the-line laptop from 2015 such as the one I experienced this problem with (Dell Precision M4800) is preposterous.  Clearly we all need to buy a new computer every year just to keep up with the ever increasing demands of this ecosystem.
Comment 17 Tomasz "CeDeROM" CEDRO 2022-12-05 21:13:59 UTC
How about switching to open-source nvidia driver?
Comment 18 Robert Clausecker freebsd_committer freebsd_triage 2022-12-05 21:50:40 UTC
(In reply to Tomasz "CeDeROM" CEDRO from comment #17)

Not available for FreeBSD as far as I know.  If it was available, I would use it immediately!
Comment 19 Tomasz "CeDeROM" CEDRO 2022-12-05 23:32:32 UTC
This one does not work at all?

https://www.freshports.org/x11-drivers/xf86-video-nv/
Comment 20 Robert Clausecker freebsd_committer freebsd_triage 2022-12-06 01:25:43 UTC
(In reply to Tomasz "CeDeROM" CEDRO from comment #19)

That driver was deprecated 10 years ago and does not support any 3D acceleration at all.  Not an option.
Comment 21 Tomasz "CeDeROM" CEDRO 2022-12-06 03:31:06 UTC
Ouch :-( I was also a nVidia customer for almost 20 years.. but my patience ended at OpenCL.. so I have switched to AMD RADEON.. on laptops without additional GPU I use i915 drm.. it works pretty well and only has hiccups when CPU load goes high.. maybe that would be an option?
Comment 22 Robert Clausecker freebsd_committer freebsd_triage 2022-12-06 16:29:37 UTC
(In reply to Tomasz "CeDeROM" CEDRO from comment #21)

The computer in question is a laptop (a Dell Precision M4800) and iirc I had no success using the integrated graphics (if they are even available).
Comment 23 Josef 'Jeff' Sipek 2022-12-07 03:58:41 UTC
(In reply to Christoph Moench-Tegeder from comment #15)
> I'd suggest to yeet that ancient driver and any hardware attached to it with prejudice. When your graphics driver replaces essential libraries and disappears interfaces which should be there for at least half a decade you're rather screwed.

It sucks that hardware that's still perfectly good is turning into waste because of lack of drivers, but that's nvidia's fault (and partially mine for trusting them to provide a driver long enough).  Unfortunately for me, replacing the GPU in a laptop isn't really an option.

I'll just keep an EGL-less build of kicad as a workaround.

Does building with EGL provide any benefit over a non-EGL build?
Comment 24 Tomasz "CeDeROM" CEDRO 2022-12-07 04:38:21 UTC
Driver Part:

1. Some laptops with Intel CPU may be possible to use i915kms module (graphics/drm-510-kmod port) and then modeset Xorg driver? Maybe the xf86-video-intel driver? I know there are some devices with GPU-LCD switch matrix that would eliminate that option. Maybe bios settings.

2. There are also some sort of nvidia-hybrid-graphics and nvidia-secondary-driver ports I would try.

3. What about using older version of the nvidia-driver pkg?

4. Alternatively I would boot of a USB with some Linux and see what driver it uses by default and try running Intel driver (not nVidia) and see what happens. That would be least invasive method of verification. If that works then maybe i915kms would work on FreeBSD too. Assuming Linux has no other GPU-LCD switch driver than FreeBSD.

5. Maybe contacting nVidia themselves and reporting the issue would help? They know all of the details, maybe its a simple bug to fix, there must be someone providing the binary drivers for FreeBSD right?


Sorry I cannot help more. I was at the same point. Laptop was not good enough for everyday work. I use it only for travel and simple tasks now. It was not even possible to video conference and do anything else at the same time. I have simply switched back to desktop from 2013 where I have 8xCPU 32GB RAM and recently did 4x4TB RAIDZ2. I have AMD RADEON RX580 that has hope to work with OpenCL (unlike nVidia). I have 42" 4K monitor unlike 12" laptop because I am getting old and started computers with Atari + TV at age of ~8 so I need to take care of my eyes too. Not to mention how many more things I can see on the screen at the same time (i.e. KiCAD, tmux, etc). I am happy with the switch to that old desktop that performs far better than 5 years younger laptop :-) :-)

BigTech takes care of "enforcing changes"^TM and "planned obsolescence"^TM so we are not even able to use hardware older than 5 years. For instance my MacBookPro from 2015 is barely usable after all those fancy pancy updates.


KiCAD+EGL Part:

1. With EGL I have really smooth experience with Schematic and PCB Editor. This can be quickly compared with Accelerated and Fallback rendering mode in KiCAD. The difference is huge sorry.

2. Some time ago when this EGL and ~6.0 showed up there was a bug and I could not process anything in 3D Viewer even export models as assertion / bug was hit on window open (just like you have now with eeschema). But I had to use kicad-devel version and I am stuck now with some project that other people still cannot open o_O

3. If all other applications work fine with nVidia 3D driver and acceleration and the problem is only with KiCAD then maybe it is in fact KiCAD (or dependencies) bug that can be eventually solved?

Take care! :-)
Comment 25 Jeff Gibbons 2023-01-03 17:05:33 UTC
I am in the same situation as several other users here, with several of my machines (HP EliteBook 8570w and 8770w laptops, with Nvidia Quadro K1000M and K3000M graphics devices which must use the nvidia-driver-390, rather than the latest nvidia-driver): I get the EGL error and crash when trying to run kicad.  But when I apply Robert Clausecker's patches to /usr/ports/cad/kicad/Makefile and /usr/ports/x11-toolkits/wxgtk32/Makefile and rebuild those two ports (after configuring wxgtk32 without GLCANVASEGL and kicad without EGL), everything works beautifully (editing schematics and PCBs, 3D viewing PCBs, etc.).  I first did this about 4 months ago when kicad used wxgtk31, and have now verified that the same elimination of GLCANVASEGL fixes kicad's problem with wxgtk32, too. 

Is there any chance of getting Robert's patches committed?  They don't affect anyone else (any other users of wxgtk32 or kicad); all they do is offer the ability, for users who need it, of building wxgtk32 and kicad without EGL.  And of course the defaults remain exactly the same as they are now (user's who don't change their configs will still build with EGL).  Even if this problem is really with NVidia's old driver and people like us with old hardware, there doesn't seem to be a downside to committing those patches; all they do is help us, without hurting anyone else.
Comment 26 Josef 'Jeff' Sipek 2023-06-15 01:55:30 UTC
I updated my system again and as one would expect the latest ports package replaced the patched version that has EGL disabled.  I have to rebuild the port (which is fine) but I wish I didn't have to manually patch the port and instead could make use of the option much like Robert suggested in his patch.  Could we have this trivial and non-disruptive option to make our lives a bit easier?  Thank you.