-
Notifications
You must be signed in to change notification settings - Fork 82
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
macOS Support #271
Comments
OpenGL Issue (from #264)Unfortunately the board viewer does not work yet. glLineWidth(…) and glBlitFrameBuffer(…) are causing an error. By removing glLineWidth(…) and drawing directly to the screen instead of using glBlitFrameBuffer(…) the board viewer does start. Debugging OpenGL is not much fun, maybe someone has an idea. Some potentially useful apitrace output:
|
Maybe move this to Milestones if it's a priority. https://github.com/horizon-eda/horizon/milestones |
I'm still a bit undecided whether it's worth given the current state of OpenGL and Gtk on mac os. There still seem to be quite a lot of glitches in GtkGLArea's quartz backend and apple's move to only allow notarized apps to run doesn't make mac os an attractive platform to target. |
@phlmn Icons are fixed by providing This is how horizon on 10.15 currently looks for me: Main problem so far is window resizing. This is completely broken. Moving between HiDPI (internal) and normal DPI (external monitor) is a problem as well, not entirely sure if this is related. @carrotIndustries I get your point about notarizing, at least bundling an app package seems somewhat supported by the project itself: GTK OSX Bundling wiki page. In general I'm surprised how much actually works. |
FWIW, the resizing issues seems to be an GTK issue. Happens with the glarea demo as well. Looks pretty much like this is the same issue: https://gitlab.gnome.org/GNOME/gtk/-/issues/1298 |
That's excellent news! To me that's enough to claim at least 'experimental' mac OS support. Please open a PR with the changes you did to make it build an run or tell me which of the existing mac OS-related PRs to merge. With that done we can also add CI to make sure it keeps building on mac OS. |
This was built using master, I will have a look at #290, which I missed so far, thanks for pointing that out. Things I would like to hear your opinion on before creating a PR:
Disclaimers:
|
Oh, didn't realize it's that bad. Claiming mac OS support with that level of buggyness will most likely cause more annoyances than not supporting it for the time being.
Isn't it available in homebrew? For msys2 for example, I added the c++ bindings to the zeromq package upstream: msys2/MINGW-packages#2193
We've had the same issue on freebsd, so adding darwin to that if should to the trick: Lines 734 to 736 in c4b9f8f
Another avenue could be to draw quads and turn them into grid marks in the fragment shader. My gut feeling tells me that his might be slightly faster.
I guess that this could alienate a lot of mac OS users, so we probably need to come up with one.
If that also happens with other Gtk apps, you should probably report in the gtk bugtracker. |
Looks like GTK got a new OGL backend for macOS. https://blogs.gnome.org/chergert/2020/12/15/gtk-4-got-a-new-macos-backend-now-with-opengl/ |
That's good news, but that's Gtk 4. It'll likely take quite some time till we use Gtk4 since it deprecated some features we need: https://discourse.gnome.org/t/using-gtkpopovermenu-as-a-gtkmenu-replacement/3786 We also need to make sure that a usable version of Gtk4 is available in all distros we want to support, i.e. Debian stable and Ubuntu LTS. |
RIP |
@schneider-engineering Can you share your changes? For zmq, relying on osrf/simulation/cppzmq seems fine. |
As far as I can tell, that's not really feasible since there have been some significant API changes, such as All in all, the earliest we can start thinking about Gtk4 is if it's available on all platforms as it's either gtk3 or gtk4. |
@isometric somehow lost sight of this. will have a look tomorrow, ok? |
It seems like longer term we should consider dropping from OGL to GLES and then maybe ANGLE if it comes to that. Seems like OGL all but dead as future support is concerned -- if not for macOS it then for the rPi 4 and successors. |
That idea has crossed my mind as well. The minimum GLES version required though would be 3.2 due to extensive (or excessive?) use of geometry shaders. We should keep support for OpenGL proper as that allows for more optimal rendering such as My main motivation for supporting GLES is bringing the app to non-x86 platforms since none(?) of the GPUs in ARM SoCs support non-ES OpenGL. |
Hmm it seems like the rPi is already GLES 3.2 - it also supports OGL 2 and I think some of the nV Tegra stuff supports OGL 4.x but it's not exactly the most relevant platform these days. |
So I was able to get horizon running by pull just the GL fixes in #290 without the memory violations. Also managed to get GTK built from source so might take a stab at resizing next week. Not sure why but I noticed that the black frame/halo around schematic/pcb doesn't appear in the gtk3-demo, any ideas @schneider-engineering? It also looks like GTK4 just uses ANGLE for compat so we may as well just use that directly if this doesn't work. @carrotIndustries any idea how much work is needed for GLES? |
I don't have any experience at all with GLES, but apart from some functions as the mentioned
Might be related to client-side decorations and/or OpenGL. |
I'd like to teach horizon as part of our university course, and the lack of macOS support is as of now the only thing blocking me from doing so, as many of our students have Macbooks. Sadly I don't have a mac myself so I can't really look into it, but I am definitly following this development : ) |
Perhaps the best way forward would be to run Easy EDA on MacOS MoltenVK via Zink: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7383 Zink is OpenGL implementation running on top of Vulkan or in case of Mac MoltenVK. |
That looks promising https://www.collabora.com/news-and-blog/blog/2021/06/14/zink-summer-2021-update/ |
I would love to hear if anything has changed here. I came to say that I was able to compile without any trouble on Apple silicon with just a set of homebrew libraries. The GL view crashes, as described above. There are a load of macOS Eagle users who need to bail out now that it's really dead and this really seems like the right place to land. Anyone interested in taking sponsored work on this topic? |
I've added: export PKG_CONFIG_PATH="/opt/homebrew/opt/libarchive/lib/pkgconfig" into the terminal and now Horizon started compiling... but came to a halt at: build/obj/3rd_party/router/router/pns_router.o Boost 1.78.0_1 is installed and up-to-date. |
you're missing If boost is installed in homebrew, you might want to check the include paths. |
EDIT: Got all former barriers out of the way (with changing the makefile) but it looks like one thing is still holding me up: lstdc++fs. |
I just gave it another try. Like a few years ago, there are some OpenGL issues. Grid is not working, Screenshots: Required brew packages:
Note: Build command: "necessary" patch (this is a little hacky, but I guess assuming to have homebrew is fine nowerdays):
|
Hi Schneider-engineering, Anyway, tried to use your patch file but I get this error message:
BTW: I used a clean Makefile from the repo. |
Started to compile on macOS-x86_64 and ran into the same problem as with macOS-arm64: What am I missing? EDIT: Duh... the makefile still had:
After commenting out However, there are still bugs to iron out as schneider-engineering mentioned. |
@sparkylein sorry, for the late response. Not sure why the patch would not apply for you. Glad you got it compiled in the end. Clang/LLVM has Would you mind sharing your environment variables, that made the makefile patch minimal? What machine do you have? Do you have a retina display? From what I remember, half of the issues in GTK are caused by DPI and screen/pixel coordinate conversion issues. What patches to canvas_gl where necessary for you to get it to render? |
@schneider-engineering, no worries. I used the master branch (got it through a zip file) and I suppose you pulled from git which gives you the latest incarnation of the repo. Compiled it on 2 macOS machines: one with intel-i5 and the other has the M1-Max. The makefile change for macOS-intel is:
The makefile change for macOS-Apple-Silicon is:
To make it easier I borrowed a python file from the KiCAD Mac-builder package and changed to (build_on_mac.py): #!/usr/bin/env python #Try not to use any packages that aren't included with Python, please. import argparse def print_and_flush(s): def get_number_of_cores(): def get_local_macos_version(): def main():
if name == "main": This python script is used to compile with max cores. Before I forget, I also used a shell script to pull in all libraries with home-brew (again... borrowed it from the KiCAD Mac-builder package) and changed it accordingly (bootstrap.sh): #!/bin/bash #homebrew location (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon and /home/linuxbrew/.linuxbrew for Linux) #Easy hack to get a timeout command for _ in 1 2 3; do PATH=$PATH:/usr/local/bin Normally I don't like to use several different shell scripts and python helper code, but in this case I was eager to get it done. :P The next steps are fixing all the bugs on macOS. |
Compile time: macOS Monterey 12.4 on 2016 MacBook Pro with intel-i5: 9:50 minutes macOS Monterey 12.4 on 2021 MacBook Pro with M1-Max: 2:10 minutes DIdn't think the difference would be that big... |
As schneider-engineering mentioned "set_has_alpha(true);" needs to be set otherwise the schematic and board windows will crash and not open. What's really weird is that both windows (schematic and board windows) have a thick dark frame surrounding them. Also in WIndows all shortcuts are Ctrl-Z, Ctrl-S, etc. on Mac it needs to move to Cmd-Z, Cmd-S respectively. Edit: fixed typo... |
The horizon imp window is acting weird on this platform. |
hey @sparkylein, gtkmm (3) on mac os does not seem to be too mature. Very minimal Demo based on https://github.com/GNOME/gtkmm/blob/gtkmm-3-24/demos/gtk-demo/example_glarea.cc: It has the exact same issues. This is not due to the lack of comments in Horizon ;) Interestingly enough the drop shadow around the window renders just fine, but all other issues are exactly the same (Even without the GLArea). As I'm neither comfortable with GTK, nor with C++, this is where I gave up the last time (and just kept using KiCAD) |
@schneider-engineering, you are correct, if a simple gtkmm app has the same issues, then it it likely impossible to fix this downstream… Nevertheless, documenting code is a good habit to have, especially in a complicated software package like horizon. Looking through the code and see the different kind of technologies that were used to accomplish this and the fact that this is the work of one person amazes me. Just wonderful! I spent over a decade on Linux, which is great, but wanted better hardware, than HP, Lenovo, etc. can offer, which made me move to a Mac. Therefore, I would love to see horizon work well on macOS :) |
I also gave up but I have had success running Horizon on virtualized linux in UTM on both amd64/intel and aarch64/M1. It seems that a lot of these issues were recently addressed in the new macos gtk backend 4 [1], so I think we should wait until horizon is ported to version 4. That might have to wait until 2023 which is roughly when gtk4 [2] will appear in a stable Debian with the release of Debian Bookworm [3]. [1] https://blogs.gnome.org/chergert/2020/12/15/gtk-4-got-a-new-macos-backend-now-with-opengl/ |
@tkornack, thank you for the info. Looking forward when horizon will use gtk4 :) |
BTW: homebrew has already gtkmm-4.6. |
Don't hold your breath. Right now, gtk 4 makes it much harder to attain the user experience I want for Horizon EDA:
Porting Horizon EDA to Gtk4 would be a multi-month effort and it'll most likely have worse user experience than the current Gtk3 implementation. |
@carrotIndustries, thank you for the links. |
Is this a different gtk beast? Obviously this gnome/gtk project started life as: Not sure if it is worth looking into this... |
From a cursory glance, they're all about improved integration or packaging. None of them will fix the issues the mac OS backend has. |
And I though because (at least that's what I thought it is) it's a thin layer with gtk widget names but inside they use native cocoa widgets, it would eliminate any redrawing issues that exist with "normal" gtk widgets. Thank you for your time and input in this. |
Re: GTK4, FYI a handy way to track preparedness is here if you want to copy it: |
Solvespace is in a much better position for adapting to a new UI toolkit since it already supports three and doesn't contain that much UI and UI-specific code to begin with. See #271 (comment) |
While you're not holding your breath you can try it under Ubuntu, using Parallels on Apple Silicon. It mostly works and performance is great. Build it from source. 3D viewer doesn't work :(
If you really want 3D viewer with terrible performance, run it like:
|
UTM also works well; 3D works and is tolerable. |
@tkornack I took your advice and gave UTM a try. At first it had the same OpenGL problems I'd seen elsewhere. I learned that UTM has recently implemented a new display driver virtio-gpu-gl-pci which uses the GPU and is very snappy but breaks Horizon. I was surprised that even the LIB_GL_ALWAYS_SOFTWARE workaround does not help like it does in parallels. You can configure UTM to use the old display driver, virtio-ramfb, and then Horizon works but the performance is only tolerable, not great. |
Interesting, that's the first GL implementation I've come across that doesn't support this function. Implementing a workaround that uses one draw call per component should be possible. It's nothing that I plan on doing, but if someone wants to do it, I'm glad to help. |
VMWare Fusion claims to have OpenGL 4.3 so I gave it a shot. My 3rd trip through the Ubuntu installer in as many days. Good news: 3D works perfectly! Bad news: Nothing else works! The schematic and layout tools just show the blue background with the light blue plusses. You can zoom in and out on the plusses, but nothing else displays. I learned that getting OpenGL to work consistently across different GPUs and OSs is something people are very interested in, because of games. But it must be very hard to accomplish, though, and there's no easy solutions in the marketplace. The internet recommends to use middleware instead, specifically Orge3d, https://www.ogre3d.org/about/features which does seem to have a story about integrating with GTK. https://wiki.ogre3d.org/GtkmmOgre |
@carrotIndustries, I gave it a try. Parallels supports OpenGL 4.0. The function that requires OpenGL 4.2 is glDrawElementsInstancedBaseInstance. OpenGL 4.0 can support the similar-sounding function glDrawElementsInstanced. So, glDrawElementsInstancedBaseInstance -- 👎 The difference is the final parameter called baseinstance. What does baseinstance do? I read the documentation 5 times and I have no idea. It's a mystery to me. https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDrawElementsInstancedBaseInstance.xhtml What's passed to baseinstance is something called,
What happens is, some components appear in the wrong place. If I could understand what But there's more problems. With this fix the 3D viewer does load and run under Parallels without error. However, it's a black screen except for the axis which animate perfectly. I don't know how I can make progress against a black screen. |
I'm curious if anything has changed about GTK4 support, given the time that's passed or your experience writing Dune 3D. |
I think it's a good idea to keep track the state of macOS support inside an issue.
I started to implement macOS support with #264, but are are quite some things missing. Things I currently have on my mind:
The text was updated successfully, but these errors were encountered: