apposed / jaunch

Launch Programs 𝙔𝙤𝙪𝙧 Way! 🍔
The Unlicense
7 stars 2 forks source link

XInitThreads #15

Closed ctrueden closed 2 months ago

ctrueden commented 6 months ago

The ImageJ Launcher calls XInitThreads on Linux when not in headless mode, so that 3D graphics libraries like Vulkan work as needed:

#ifdef __linux__
  void (*xinit_threads_reference)();
  ...
  // This call is neccessary on Linux to avoid X11 errors when using
  // various 3D graphics APIs like Vulkan or OpenGL.
  if (!headless) {
    void *libX11Handle = dlopen("libX11.so", RTLD_LAZY);
    if(libX11Handle != NULL) {
      debug("Running XInitThreads\n");
      xinit_threads_reference = dlsym(libX11Handle, "XInitThreads");

      if(xinit_threads_reference != NULL) {
        xinit_threads_reference();
      } else {
        error("Could not find XInitThreads in X11 library: %s\n", dlerror());
      }
    } else {
      error("Could not find X11 library, not running XInitThreads.\n");
    }
  }
#endif

Should Jaunch also do this? Maybe an optional directive? It would be a directive that does not switch the result from LAUNCH to CANCEL.

imagesc-bot commented 5 months ago

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/jaunch-a-new-java-launcher-test-fiji-with-java-21/92058/1

kephale commented 5 months ago

Is there a reason not to run XInitThreads?

ctrueden commented 4 months ago

@kephale Not that I know of. But I know next to nothing about XInitThreads. Why is this even necessary in the first place? What impact does it have to run or not run it? I have no idea.

kephale commented 4 months ago

Yeah, all I know is that you get race conditions if you don't run it. sciview is still being haunted by whatever race conditions are happening on Linux, which can't be just XInitThreads...

skalarproduktraum commented 3 months ago

44 brings this one step closer 👍