glvis icon indicating copy to clipboard operation
glvis copied to clipboard

EGL headless visualization

Open najlkin opened this issue 6 months ago โ€ข 8 comments

This PR adds headless (no GUI) visualization using EGL standard. The new EglWindow serves as an alternative backend instead of SdlWindow, which is no longer needed directly and the code uses general GLWindow base class instead. The headless rendering is available in the following ways:

  • from command line with option -hl (control key q should be used to quit after the visualization is done)
  • saved streams when started with the above option (end of the input stream closes the visualization)
  • from scripts, starting them with the above option or through headless command before the visualization command(s), which are then performed without autopausing (end of the script files closes the visualization)
  • server started with the -hl option, where end of the input streams also closes the visualization(s)

โ†ช๏ธ dependencies:

  • #335

๐ŸŒŸ bonus features:

  • moved SDL-based content to sdl directory (and similarly EGL-based to egl), cleaning up file hierarchy
  • fixed handling of screenshot command in scripts, as criticized in #254
  • fixed caching of MFEM in CI tests (MPI option was not recognized)
  • removed using namespace std pollution (i.e., uncontrolled spreading through header files)

๐Ÿ“Ž todo:

  • [x] CI building (only Ubuntu)
  • [x] server mode
  • [ ] CI tests?

โœ”๏ธ testing:

  • [x] some cmd lines
  • [x] some scripts
  • [x] some saved streams
  • [x] inline visualization
  • [x] js

najlkin avatar May 12 '25 22:05 najlkin

I have tried headless CI tests with EGL and some pass smoothly, but other fail at initialization. There seems to be some issue on the runners like limited video memory or something, so it is very random. You may compare this run and this. I have removed the tests and only building with EGL support is done on Ubuntu (in the existing runs, tests use SDL normally).

najlkin avatar May 15 '25 17:05 najlkin

Ok, the headless server works nicely now. It should be tested in combination with parallel applications on clusters. If IP/TCP sockets cause some problems, we could try to use Unix sockets locally on the node ๐Ÿค” .

najlkin avatar May 23 '25 20:05 najlkin

Ok, the headless server works nicely now. It should be tested in combination with parallel applications on clusters. If IP/TCP sockets cause some problems, we could try to use Unix sockets locally on the node ๐Ÿค” .

That's awesome, thanks @najlkin !

tzanio avatar May 25 '25 19:05 tzanio

@justinlaughlin, what happens if we load a steam with "screenshot" command in the web version?

tzanio avatar May 28 '25 23:05 tzanio

I think an error ๐Ÿ˜ , because glvis-js supports only keys and valuerange commands apart from the data loading ones (see #315 ). But you may enter keys S to get a screenshot. I wonder what will happen then ๐Ÿค” .

najlkin avatar May 28 '25 23:05 najlkin

@justinlaughlin, what happens if we load a steam with "screenshot" command in the web version?

I think an error ๐Ÿ˜ , because glvis-js supports only keys and valuerange commands apart from the data loading ones (see #315 ). But you may enter keys S to get a screenshot. I wonder what will happen then ๐Ÿค” .

I think pressing S will "download" the new file that is created by the C++ code, so depending on your browser configuration, the file may be saved directly to your "Downloads" folder without a prompt, or you may get a "save file" dialog box to choose where to save the file.

v-dobrev avatar May 30 '25 06:05 v-dobrev

Hmm, at least in basic.html nothing happens after S. It would be too nice to get a file ๐Ÿ™ƒ . I guess it violates some security policies and the code does not get a writing file handle ๐Ÿšซ .

najlkin avatar May 30 '25 21:05 najlkin

But in glvis live, it works๐Ÿ˜ฎ . However, there is a special code for it, handling specifically S, calling saveScreenshot() in index.js. You get glvis.png file for download. It shares SaveAsPNG() with the main code, so there is a potential for headless operation if you are thinking that way ๐Ÿ˜‰ .

najlkin avatar May 30 '25 21:05 najlkin