Visualization issues on Ubuntu 22.04 LTS on WSL2 for Windows10

Geant4 Version: 11.2.1
Operating System: Ubuntu 22.04 in WSL2 for Windows10
Compiler/Version: gcc 11.4.0
CMake Version: 3.20.1


Hi, I installed Geant4 v11.2.1 on Ubuntu 22.04 LTS on WSL2 for Windows10. I built some basic examples and run them to see if everything worked out. Running the example B2a I encounter some issues with the visualization with the interactive GUI.

When configuring the build, I ran cmake with the following flags:

GEANTDIR=/home/dboccanfuso/geant4_local/geant4-11.2.1
cmake -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_QT=ON -DGEANT4_USE_RAYTRACER_X11=ON -DCMAKE_INSTALL_PREFIX=/usr/lib/x86_64_linux_gnu/qt5 -DCMAKE_INSTALL_PREFIX=$GEANTDIR-install $GEANTDIR

And then got the following output

-- Checking C++ feature CXXSTDLIB_FILESYSTEM_NATIVE - Success
-- Disabling Geant4 Qt3D driver, missing Qt packages: Qt53DCore;Qt53DExtras;Qt53DRender
-- Reusing dataset G4NDL (4.7)
-- Reusing dataset G4EMLOW (8.5)
-- Reusing dataset PhotonEvaporation (5.7)
-- Reusing dataset RadioactiveDecay (5.6)
-- Reusing dataset G4PARTICLEXS (4.0)
-- Reusing dataset G4PII (1.3)
-- Reusing dataset RealSurface (2.2)
-- Reusing dataset G4SAIDDATA (2.0)
-- Reusing dataset G4ABLA (3.3)
-- Reusing dataset G4INCL (1.2)
-- Reusing dataset G4ENSDFSTATE (2.3)
-- The following Geant4 features are enabled:
CMAKE_CXX_STANDARD: Compiling against C++ Standard '17'
GEANT4_BUILD_MULTITHREADED: Build multithread enabled libraries
GEANT4_BUILD_TLS_MODEL: Building with TLS model 'initial-exec'
GEANT4_USE_SYSTEM_EXPAT: Using system EXPAT library
GEANT4_USE_OPENGL_X11: Build Geant4 OpenGL driver with X11 support
GEANT4_USE_RAYTRACER_X11: Build RayTracer driver with X11 support
GEANT4_USE_QT: Build Geant4 with Qt5 support

-- Configuring done
-- Generating done
-- Build files have been written to: /home/dboccanfuso/geant4_local/geant4-11.2.1-build

Anf the no issues when running make -jN and make install. So I guess the problem is that cmake doesn’t find the Qt packages, but they are present in my shared library folder. Is there something I’m missing?

Hi

Not quite sure what you are saying. There does not seem to be any crash. What you are seeing looks to me like a tiny detector - have you got the zoom factor right? Or have you got a very large world that is not marked “invisible”. Is it B2a “out if the box”, i.e., without any modification? If so, I’m puzzled.

To zoom, use the mouse (drag towards you), or /vis/viewer/zoom 10, say.

Come back to us if this does not help. In the past we have seen problems if X11 and Qt are both installed - some versions of Qt come with their own version of X11, then there are two installations of X11 and cmake gets confused.

John

Hi John
I’m sorry that my post was not clear, it’s my first time posting.

My problem is that I’m confident the visualization is not working properly.

For comparison, the following is a screenshot of the same example B2a obtained by a collegue of mine.

Instead, when I run the example B2a and fire a particle I get the image that I showed in the post. (The forum doesn’t allow me to attach another screenshot, sorry)

It seems to me that interactions between particles and detectors are handled correctly, but detectors are just not shown in the GUI.

I can confirm that the example is without modifications for both me and my collegue. Running /vis/viewer/zoom/ 10 also didn’t change anything.

Thank you
Daniele

OK Daniele

So how about my other suggestion - that you might have two versions on X11 installed on your computer? For example, on. my computer, the following commands find lots of X11-related libraries in two different locations:

 find -L /usr -type f -name 'libX11.*'
 find -L /opt -type f -name 'libX11.*'

Consequently, at this moment (I hope to fix it), I cannot build with X11 and Qt at the same time. So, if this is the case for you, try building _without_X11, i.e., remove

-DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_RAYTRACER_X11=ON

from your cmake command, and rebuild. Try doing that anyway.

If that doesn’t work, it might be you need to update your graphics card driver.

Anyway, let us know how you get on.

John

My graphic drivers are up to date. I deleted the folder containing Geant and installed again without building X11, but nothing changed.

Just for completness, I also ran the command for finding X11 libraries and got this output, but I don’t know how to interpret it

find: File system loop detected; ‘/usr/lib/llvm-14/build/Debug+Asserts’ is part of the same file system loop as ‘/usr/lib/llvm-14’.
find: File system loop detected; ‘/usr/lib/llvm-14/build/Release’ is part of the same file system loop as ‘/usr/lib/llvm-14’.
/usr/lib/x86_64-linux-gnu/libX11.so.6
/usr/lib/x86_64-linux-gnu/libX11.so
/usr/lib/x86_64-linux-gnu/libX11.a
/usr/lib/x86_64-linux-gnu/libX11.so.6.4.0
find: File system loop detected; ‘/usr/lib/x86_64-linux-gnu/hdf5/serial/lib’ is part of the same file system loop as ‘/usr/lib/x86_64-linux-gnu/hdf5/serial’.
find: File system loop detected; ‘/usr/lib/x86_64-linux-gnu/hdf5/openmpi/lib’ is part of the same file system loop as ‘/usr/lib/x86_64-linux-gnu/hdf5/openmpi’.
find: File system loop detected; ‘/usr/bin/X11’ is part of the same file system loop as ‘/usr/bin’.

Hi Daniele.

I’m afraid I’m stumped. Are there any other users of Ubuntu in WSL who can help?

There are different ways of installing Linux on Windows, but I’m afraid I’m not an expert there.

Sorry not to be more helpful.

John

Thank you anyway John.

If I ever find a solution I might update here so that it can be useful for other users too.

Unless there’s a typo here, you have two entries for CMAKE_INSTALL_PREFIX. I’m not 100% ure what the effect of that is, but whack that you have the install where you expect and that the correct qt5 has been picked up. The nominally correct invocation would be

-DCMAKE_PREFIX_PATH=/usr/lib/x86_64_linux_gnu/qt5
-DCMAKE_INSTALL_PREFIX=$GEANTDIR-install

thank you for your reply. It was indeed an error on my part. But even after building again with the fixed invocation I get errors.

This is the output after running example B1

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-dboccanfuso'
Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile
Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile
QGLShaderProgram: shader programs are not supported
Errors linking simple shader:
Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile
Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile
QGLShaderProgram: shader programs are not supported
Errors linking blit shader:
Warning: "" failed to compile!
Warning: "" failed to compile!
Warning: "" failed to compile!
Warning: "" failed to compile!

It appears that you got different results after setting
-DCMAKE_PREFIX_PATH=/usr/lib/x86_64_linux_gnu/qt5

meaning that beforehand it could have pulled in another installation of qt5 from some other place, and now it should be getting it from the standard place. You could run “ldd ./exampleb2a” to see the paths to the actual libraries being linked into your executable.

I have just built Geant4 11.2.1 under WSL2 on Windows 10, selecting only the -DGEANT4_USE_QT option. This will automatically pull in the correct OpenGL and X11 libraries, so to keep things clear I didn’t set the -DGEANT4_USE_OPENGL_X11 option.
On building and running exampleb2a, the OpenGLQt viewer was opened and it showed the geometry correctly without any problem like you showed above.

Did you try any other viewers? The command “vis/open TSG” can be used to open a second viewer which does not depend on X11 or external libraries. See if it works.
Also, do a “wsl --update” from a Windows prompt if you haven’t done it recently. This will merge the WSLg graphics into WSL2. This was formerly available only on Windows 11 and with it the Linux graphics applications, including the X11 ones, will be seamlessly integrated into the Windows graphics. Manually starting an X server under Windows is no longer necessary and should be omitted.
If you are not certain what all the build options really are set to, you can run cmake-gui to check/change them, or look in CMakeCache.txt with a text editor (but that’s more cumbersome).

thank you for your reply.

My version of WSL2 is the latest version. I built geant4 again with the following command

GEANTDIR=/home/dboccanfuso/geant4_local/geant4-v11.2.1
cmake -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_QT=ON -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/qt5 -DCMAKE_INSTALL_PREFIX=$GEANTDIR-install $GEANTDIR

Then, when I run any example I get errors like those that I showed in my previous reply. Then I used the command vis/open TSG and it works! The ‘default’ viewer that is giving me trouble is (OpenGLStoredQt), while after running the command you wrote it becomes (TOOLSSG_QT_GLES).

Is there a way to set it as the default viewer?

On a side note, I have to start an X server manually, otherwise nothing happens.

From 11.2, you can set an environment variable G4VIS_DEFAULT_DRIVER, e.g.,

      - (bash) export G4VIS_DEFAULT_DRIVER=TSG
      - (tcsh) setenv G4VIS_DEFAULT_DRIVER OI

Just for the record, my WSL configuration is

wsl --version
WSL version: 2.1.5.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.4412

It is odd that with WSLg you still have to run a Windows X server.
My experience with most of these X servers is that for WSL OpenGL graphics they either do not work at all (e.g. Xming) or do not work reliably. If you want to check your system, use the following commands:

glxinfo: similar to dpyinfo but shows the OpenGL version and the supported GLX extensions.
glxgears: should show a set of 3d smoothly rotating gears
If either of these fail or hang up then your OpenGL configuration is broken.
My system has Intel graphics on the motherboard and I also ran into trouble with the installed driver causing OpenGL to fail. Installing a newer driver direct from Intel fixed this. Everything ran perfectly until the next Windows Update which over-wrote this driver with the old one and I had to reinstall!

My WSL configuration is identical to yours:

Versione WSL: 2.1.5.0
Versione kernel: 5.15.146.1-2
Versione WSLg: 1.0.60
Versione MSRDC: 1.2.5105
Versione Direct3D: 1.611.1-81528511
Versione DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Versione di Windows: 10.0.19045.4412

I do, however, get problems with OpenGL!
glxgears: gears are shown but they do not rotate!
glxinfo gives me this:

name of display: 172.18.33.73:0.0
display: 172.18.33.73:0  screen: 0
direct rendering: No (LIBGL_ALWAYS_INDIRECT set)
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_context_flush_control, GLX_ARB_create_context,
    GLX_ARB_create_context_no_error, GLX_ARB_create_context_profile,
    GLX_ARB_fbconfig_float, GLX_ARB_framebuffer_sRGB, GLX_ARB_multisample,
    GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile,
    GLX_EXT_fbconfig_packed_float, GLX_EXT_framebuffer_sRGB,
    GLX_EXT_get_drawable_type, GLX_EXT_import_context,
    GLX_EXT_no_config_context, GLX_EXT_texture_from_pixmap,
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer,
    GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
    GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, GLX_SGI_make_current_read
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:
    GLX_ARB_context_flush_control, GLX_ARB_create_context,
    GLX_ARB_create_context_no_error, GLX_ARB_create_context_profile,
    GLX_ARB_create_context_robustness, GLX_ARB_fbconfig_float,
    GLX_ARB_framebuffer_sRGB, GLX_ARB_get_proc_address, GLX_ARB_multisample,
    GLX_ATI_pixel_format_float, GLX_EXT_buffer_age,
    GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile,
    GLX_EXT_fbconfig_packed_float, GLX_EXT_framebuffer_sRGB,
    GLX_EXT_import_context, GLX_EXT_no_config_context, GLX_EXT_swap_control,
    GLX_EXT_swap_control_tear, GLX_EXT_texture_from_pixmap,
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_INTEL_swap_event,
    GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, GLX_MESA_swap_control,
    GLX_NV_float_buffer, GLX_OML_swap_method, GLX_OML_sync_control,
    GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer,
    GLX_SGIX_visual_select_group, GLX_SGI_make_current_read,
    GLX_SGI_swap_control, GLX_SGI_video_sync
GLX version: 1.4
GLX extensions:
    GLX_ARB_context_flush_control, GLX_ARB_create_context,
    GLX_ARB_create_context_no_error, GLX_ARB_create_context_profile,
    GLX_ARB_fbconfig_float, GLX_ARB_framebuffer_sRGB,
    GLX_ARB_get_proc_address, GLX_ARB_multisample,
    GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile,
    GLX_EXT_fbconfig_packed_float, GLX_EXT_framebuffer_sRGB,
    GLX_EXT_import_context, GLX_EXT_no_config_context,
    GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating,
    GLX_MESA_copy_sub_buffer, GLX_OML_swap_method, GLX_SGIS_multisample,
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group,
    GLX_SGI_make_current_read
OpenGL vendor string: Mesa/X.org
OpenGL renderer string: softpipe
OpenGL version string: 1.4 (3.3 (Compatibility Profile) Mesa 22.0.0-devel (git-7aab7ccd36))
OpenGL extensions:

270 GLX Visuals ...

X Error of failed request:  GLXBadCurrentWindow
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  5 (X_GLXMakeCurrent)
  Serial number of failed request:  56
  Current serial number in output stream:  56

I have an NVidia graphic card with the raccomended drivers installed. Should I just try some other driver version or change something about OpenGL?

This doesn’t seem to work, the default viewer is still OpenGLStoredQt, should I set the variable before or after running geant4.sh? Or do I need to write it in a specific file?

Before or after - shouldn’t matter. It’s about creating the Unix environment in which your app will run. So if your app is myApp, in the terminal from which you are going to launch it, and in the working directory (folder) where any files that it accesses exist:

export G4VIS_DEFAULT_DRIVER=TSG
<path-to>myApp

(If myApp is in the same directory, it’s just ./myApp.)

If you don’t want to change your environment beyond that for you app, you can

G4VIS_DEFAULT_DRIVER=TSG ./myApp

(In the above, I am assuming an sh-like shell, e.g., bash. echo $SHELL to discover what you are using.)

Re glxinfo and glxgears results, did you have a Windows X server running? If so, this reflects that your X server cannot do OpenGL. You didn’t mention which X server you are running. As I mentioned above, several of them don’t work and if I remember correctly, in the end I found that GWSL (available from the Windows Store) was the only one that worked.
First, try glxinfo and glxgears without an X server running. Make sure you kill it because they tend to lurk in the background. Then do a fresh Ubuntu login and check that the DISPLAY variable is set to “:0” before running them. If this works, then try running your G4 app.
This is the limit of my knowledge so otherwise I can only suggest trying GWSL as a work-around.

Hi, I finally solved the problem.
The issue was that I was using MobaXterm to acces WSL2 and Moba requires an X server. I was using VcXsvr (aka Xming), and to make it work I followed some instruction on GitHub that told me to add a line to ./bashrc to change my DISPLAY variable, indeed my DISPLAY variable was set to 10.50.0.254:0.0.

So I removed that line from .bashrc, stopped using MobaXTerm and used the dafault Ubuntu terminal that comes with WSL2. Now everything works as you said without using Xming.

Thank you very much

I’m glad you got everything working. Now that the WSL-to-Windows graphics connection is taken care of internally, the performance should be better and also the new Linux non-X graphics applications (Wayland) should work seamlessly as well, although I haven’t tested this as yet.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.