PlantSimulationLab/Helios

Visualizer error on macOS with SSH X11 forwarding

Opened this issue · 3 comments

When running any code that involves the Visualizer plugin, I get the following error:

Initializing graphics...terminate called after throwing an instance of 'std::runtime_error'
  what():  ERROR(Visualizer): Failed to initialize graphics.
Common causes for this error:
-- OSX
  - Is XQuartz installed (xquartz.org) and configured as the default X11 window handler?  When running the visualizer, XQuartz should automatically open and appear in the dock, indicating it is working.
-- Linux
  - Are you running this program remotely via SSH? Remote X11 graphics along with OpenGL are not natively supported.  Installing and using VirtualGL is a good solution for this (virtualgl.org).

Aborted (core dumped)

Context:

  • I am on Apple M1
  • The code is on a remote Ubuntu GPU machine that I connect to with SSH forwarding (tried ssh -X and ssh -Y)
  • XQuartz is installed and configured as the default X11 window handler. When running the code, XQuartz opens and appears in the dock but nothing is displayed.
  • The same code works well with SSH forwarding from another Linux machine (the preview displays correctly)
  • Other remote graphical applications display fine on my Mac (I tested xclock and glxgears)

The issue is that OpenGL graphics cannot be forwarded over SSH without a 3rd party utility. As mentioned in the error message, one option is to install the VirtualGL utility. You need to follow their install instructions carefully, as it can be tricky in some cases. Another option is to use a VNC server/client like TurboVNC to remotely connect using a virtual desktop rather than over SSH. This is our preferred method because you can run CLion on the remote sever.

Ok thanks, I will try these options.

I am surprised that forwarding glxgears (based on OpenGL) works fine though...

I managed to get the Visualizer working commenting out these two lines in Visualizer.cpp:

 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL

Apparently it's an error with GLX_ARB_create_context_profile, it seems to be a common issue with X11 forwarding on Mac.

GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable
GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable

I got the above error when adding some glfw debugging in my script:

 static void glfwError(int id, const char* description)
    {
  std::cout << description << std::endl;
}
int main(){
   glfwSetErrorCallback(&glfwError);
  [...]
  }