Brainstorm on Ubuntu 20.04 / bug with Matlab jogl

Hi,

I've been using the Brainstorm with Matlab runtime R2020a update 6 then update 7 for about a year with OpenGL without any issues on Ubuntu 20.04. Recently I updated my system and now I'm hitting the following error with starting brainstorm:
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue by running this command: opengl problems,
then restart MATLAB.
To share details of this issue with MathWorks technical support, please
include this file with your service request: /home/hipuser/jogl.ex.109

The file jogl.ex.109 contains:
com.jogamp.opengl.GLException: MATLAB Compiler Runtime: createImpl ARB n/a but required, profile > GL2 requested (OpenGL >= 3.1). Requested: GLProfile[GL4bc/GL4bc.hw], current: 4.6 (Compat profile, compat[ES2, ES3, ES31], FBO, hardware) - 4.6.0 NVIDIA 470.74
at jogamp.opengl.x11.glx.X11GLXContext.createImpl(X11GLXContext.java:418)
at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:759)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:642)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1263)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1131)
at jogamp.opengl.GLAutoDrawableBase.defaultDisplay(GLAutoDrawableBase.java:466)
at com.jogamp.opengl.GLAutoDrawableDelegate.display(GLAutoDrawableDelegate.java:190)
at com.mathworks.hg.uij.OpenGLUtils$MyGLListener.getGLInformation(OpenGLUtils.java:355)
at com.mathworks.hg.uij.OpenGLUtils$MyGLListener.getGLData(OpenGLUtils.java:512)
at com.mathworks.hg.uij.OpenGLUtils.getGLData(OpenGLUtils.java:79)

I've tried various workaround without success.

What I found and tried:
https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1726595
https://itectec.com/matlab/matlab-hardware-opengl-failure-on-ubuntu-16-04-3-can-not-initialize-shared-resources/

Did any of you hit this issue as well?
Do you have any idea how to solve this?

Many thanks!

What I found and tried (2nd post due to link limit):
https://bugs.launchpad.net/ubuntu/+source/scilab/+bug/1742894
https://ch.mathworks.com/matlabcentral/answers/377644-hardware-opengl-failure-on-ubuntu-16-04-3-can-not-initialize-shared-resources

This is a Matlab-related issue, not a Brainstorm issue per se. Therefore this is not something we will be able to fix on our end. Fixing this issue involves most likely for you to find the correct combination of libraries on your system.
The most appropriate way to get help with this issue would be to post a bug report on the Mathworks website, with all the information on how to reproduce the error.

If you get a decent workaround from the Mathworks support, please share it here.
If you don't , we could work on adding extra input parameters to completely disable the use of JOGL from the command line. However, since we won't be able to reproduce your system-specific issues, this would require for you to test this on your end, with a full installation of Matlab (not the Matlab Runtime).

Does Brainstorm start from a full Matlab install on this system?
If Brainstorm does NOT start, please try the following:

  • edit the function brainstorm.m,
  • comment out the lines 72-92,
  • add a line JOGLVersion = 0;.
  • => Does it work after editing the file?

If Brainstorm does start with a full Matlab install, but the compiled version crashes, you'll need to recompile Brainstorm after the modification in order to make sure this will fix the problem.
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#How_to_compile_Brainstorm

Once you've figured out how to fix your startup option, let me know and I'll work on adding an extra command-line option nojogl, or something like that.

Dear François,

thanks for your answer.

I'm only using the matlab runtime for now. I do not have access to the full version of matlab to test.

We submitted the bug to Mathworks and are waiting for their answer.

If jogl is disabled, we won't have OpenGL support, right?

Another question, I saw you have a version of brainstorm for the 2021 runtime, would that contain a newer version of JOGL?

If jogl is disabled, we won't have OpenGL support, right?

The Matlab OpenGL renderer would still be available.
The only thing that would not work anymore is the rendering of connectivity graphs using JOGL. This would be a very minor issue, as we now have a Matlab version of these graphs available:
https://neuroimage.usc.edu/brainstorm/Tutorials/ConnectivityGraph

Another question, I saw you have a version of brainstorm for the 2021 runtime, would that contain a newer version of JOGL?

No. The developments of JOGL are stalled and so are their integration in Matlab.
Our next step is to get rid of it completely in the Brainstorm distribution.
We will keep it for a few more months while we finish debugging the new functions.
You should not worry about losing this JOGL support.

However, you could try the 2021a compiled package, maybe in that Runtime version, your bug doesn't exist anymore (independently from the JOGL version)

Hi,

I tried the 2021a compiled package with the following versions for the nvidia drivers

  • nvidia-driver-460
  • nvidia-driver-470 (recommended)
  • nvidia-driver-495
    without success.

Trying this was the suggestion of Mathworks after we submitted a bug report. We are currently waiting for other input from them.

I still don't have access myself to a full version of Matlab unfortunately.

With all the cash and power available at HBP, you could not find any computer where you could recompile Brainstorm without JOGL?...

Once you've figured out how to fix your startup option, let me know and I'll work on adding an extra command-line option nojogl , or something like that.

Good luck...

We are currently working on making the brainstorm code base lighter.
I decided to anticipate this complete removal of the JOGL libraries, which were going to be more and more complicated to maintain:

I recompiled Brainstorm without the JOGL .jar files.
Please try again with the latest compiled version.

Note that we are also in the process of removing all the compiled files from the github repository, therefore to get the compiled version of Brainstorm, you need to download it from the website.
http://neuroimage.usc.edu/bst/getupdate.php?c=UbsM09&src=0&bin=1

Thanks a lot François. I will try the new version and let you know!

We have a computer but did not manage to compile brainstorm and I don't have access to it myself.

Hi François,

I can confirm that the new version works!

Thank you so much for your help in resolving this.

Cheers