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

Segfault on MacOS when shadows are on (GRAPHIC ON) #204

Closed
c-joly opened this issue Jun 28, 2024 · 5 comments
Closed

Segfault on MacOS when shadows are on (GRAPHIC ON) #204

c-joly opened this issue Jun 28, 2024 · 5 comments
Assignees

Comments

@c-joly
Copy link

c-joly commented Jun 28, 2024

Hi @costashatz, here is in issue linked to the review openjournals/joss-reviews#6771

Launching the examples in graphical mode on MacOS 14.5 (ARM64) results in a segfault due to OpenGL immediately (C++) and after about one second (Python bindings). Deactivating the shadows solve the problem (tested by updating some examples in Python and C++).

I saw there is already a warning message mentioning unexpected behavior with shadows on MacOS. In turns out that with my configuration, there is no behavior at all (☠️).

Do you think you can patch the examples to switch off the shadows by default, or better to deactivate them if the Darwin architecture (==MacOS) is detected? In Python, the test can be made easily thanks to the function system of the module platform.

@costashatz
Copy link
Member

@c-joly thank you for your hard work. I will try to reply to all of your issues.

Deactivating the shadows solve the problem

Nice to hear!

better to deactivate them if the Darwin architecture (==MacOS) is detected?

Yes. This is what I will do. I am already checking for Darwin architecture in my code. So this should be easy. It was just that shadows were working in some machines, and producing some small artifacts on others. But on yours, it seems that they do not work at all.

It's unclear to me why, but the easiest workaround is to indeed disable shadows by default on Mac.

Thanks again!

@c-joly
Copy link
Author

c-joly commented Jun 28, 2024

It's unclear to me why, but the easiest workaround is to indeed disable shadows by default on Mac.

I found on some forum that there is no support anymore of OpenGL on MacOS. Some people mention that the bugs and compatibility issues may be worse in the future. It looks like Apple would like to force developers to use Metal on MacOS, which is now the only graphics API officially supported.

@c-joly
Copy link
Author

c-joly commented Jul 4, 2024

Hi @costashatz, a little update about these segfault. I figured out they happen only when my computer is docked and an extra screen is connected. I figured out by accident that I can run the examples in shadowed mode when I used my laptop without any extra screen... 🫤

@costashatz costashatz self-assigned this Jul 12, 2024
@costashatz
Copy link
Member

@c-joly I managed to replicate this issue. I was able to get the crash also by moving the window extensively around the screen (even when connected to one screen).

The examples run but they can very easily crash. This issue because of 2 reasons:

  1. Mac OSX does not support OpenGL, only a subpart of it. For this reason, my shaders for shadows compile but with important warnings (the number of lights variable gets a random value!). This can obviously result in accessing memory that does not exist or getting junk values that make the process crash.

  2. The HiDPI scaling works differently on Mac and Linux. I have spent most of my time (when writing the graphics) optimizing for the Linux case, and thus it is possible that on Mac we access memory that is not defined.

My intuition tells me that (2) is what causes the issue. This is also "validated" by the fact that everything runs fine in Windowless mode where HiDPI is not there (there is no window scaling when there's no window! hahah).

I will disable shadows by default in Mac windowed cases so that the user experience is better, add some comments about this behavior in the docs, and create a github issue so that I remember to try and fix this at some point.

I will ping you once I have completed all of the above.

@costashatz
Copy link
Member

This should be fixed by 9412aa2 (and see #223). @c-joly let me know if I forgot something.

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

No branches or pull requests

2 participants