Genesis icon indicating copy to clipboard operation
Genesis copied to clipboard

OpenGL/GLFW Conflict Between Taichi and PyGEL3D on macOS (Apple Silicon)

Open analogjedi opened this issue 1 year ago • 4 comments

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.

analogjedi avatar Dec 20 '24 14:12 analogjedi

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

DuinoDu avatar Dec 20 '24 17:12 DuinoDu

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?

DuinoDu avatar Dec 20 '24 18:12 DuinoDu

The same issue on Python 3.10 and 3.12

arch1baald avatar Dec 20 '24 19:12 arch1baald

I solve this problem using the older "PyGEL3D == 0.1.0" version on MacOS M1 chip. #179

VioletBenin avatar Dec 20 '24 21:12 VioletBenin

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.

analogjedi avatar Dec 22 '24 17:12 analogjedi

The crash is unrelated to Taichi dylib conflict. The actual bug has been fixed on main branch.

duburcqa avatar Mar 12 '25 23:03 duburcqa