OpenGL/GLFW Conflict Between Taichi and PyGEL3D on macOS (Apple Silicon)
Environment
- macOS with Apple Silicon (M3 Max)
- Python 3.11
- Genesis Physics 0.2.0
- PyGEL3D 0.5.2
- Taichi 1.7.2
Issue
When running the macOS example script with visualization enabled, there's a conflict between GLFW implementations from Taichi and PyGEL3D packages. This leads to OpenGL initialization issues and ultimately causes a framebuffer binding error.
The specific error starts with duplicate GLFW class implementations:
Class GLFWHelper is implemented in both /taichi/_lib/core/taichi_python.cpython-311-darwin.so and /pygel3d/libPyGEL.dylib
Class GLFWApplicationDelegate is implemented in both locations
[etc...]
This is followed by shader uniform binding failures and eventually crashes with:
OpenGL.error.GLError: GLError( err = 1282, description = b'invalid operation', baseOperation = glBindFramebuffer, cArguments = (GL_DRAW_FRAMEBUFFER, 0) )
Steps to Reproduce
Create a Python virtual environment
Install genesis-world and its dependencies
Run the macOS example script form the /examples directory with visualization enabled (python getting_started_mac.py -v)
Expected Behavior
The visualization window should open and show the physics simulation.
Actual Behavior
The script crashes with OpenGL errors due to conflicting GLFW implementations.
I find that this bug is not caused by OpenGL/GLFW conflict. I compile PyGEL3D without OpenGL/GLFW, by setting Use_GLGraphics to OFF in CMakeLists.txt. Conflict warnings disappear but bug still exists. Here is a screen record for log.
https://github.com/user-attachments/assets/68b3bfaf-dfe2-43b3-b511-45414e0787bf
I fixed it by replacing genesis/ext/pyrender with pyrender offical one, with some update compatible with genesis. Code is here https://github.com/DuinoDu/Genesis. Plan to push a pull request after fixing other compatible bugs.
https://github.com/user-attachments/assets/c0ea8d08-114f-4fc9-93ab-d8d1ecec7963
Just wonder why don't use pyrender via pip but copy-paste?
The same issue on Python 3.10 and 3.12
I solve this problem using the older "PyGEL3D == 0.1.0" version on MacOS M1 chip. #179
Thanks to the post of: https://github.com/Genesis-Embodied-AI/Genesis/issues/207#issuecomment-2558123904
I was able to get the initial getting started script working on my Macbook Pro M3 Max w/ Sonoma 14.5.
I could not get it to work with my python venv's but I had success using miniconda with Python 3.10.
The crash is unrelated to Taichi dylib conflict. The actual bug has been fixed on main branch.