Tom94 / tev

High dynamic range (HDR) image viewer for graphics people
BSD 3-Clause "New" or "Revised" License
1.08k stars 86 forks source link

tev does not exit when the window is closed #216

Open alex-fu27 opened 9 months ago

alex-fu27 commented 9 months ago

I have just been looking for an OpenEXR viewer, tried out tev on NixOS and started it from the shell with a Multilayer EXR image as argument, but when I close the window, the program just stays running until I kill it:

$ tev ./0047.exr 
11:12:50 SUCCESS  Initialized IPC, listening on 127.0.0.1:14158
11:12:50 INFO     Launching with 8 bits of color and LDR display support.
11:12:50 SUCCESS  Loaded /home/alex/uni/masterarbeit/impl/datasets/table/output/./0047.exr via OpenEXR after 0.061 seconds.
^C^C
$ tev --version
tev — The EXR Viewer
version 1.26 (64 bit)
Tom94 commented 9 months ago

Hi, thanks for reporting this. Unfortunately I can’t reproduce it — I routinely use tev on Ubuntu and Arch via the shell (with tiling and regular window managers) and so far have not come across this. I suspect the window-close message from your WM might not make it through GLFW to tev.

If you have extra information, I’d much appreciate it. Like: what WM do you use, do you use x11 or Wayland, does the problem also happen when building from source, what’s your specific OS version, etc.

Also, if someone else watching this repo has run into this in the past, feel free to chime in.

to-mas-kral commented 5 months ago

Hi, I've just encountered this as well. Using tev version 1.26dev (64 bit) from AUR. I use KDE Plasma 6.0.3 with KWin on Wayland.

EDIT: switching to X11 doesn't solve the issue

alex-fu27 commented 5 months ago

I built the Debug configuration and ran tev with gdb. This is the log: log.txt

If I interpret this correctly, you have this

    // Spawn a background thread that opens images passed via stdin.
    // To allow whitespace characters in filenames, we use the convention that
    // paths in stdin must be separated by newlines.
    thread stdinThread{[&]() {
        string channelSelector;
        while (!shuttingDown()) {
            for (string line; getline(cin, line);) {
                string imageFile = tev::ensureUtf8(line);

                if (imageFile.empty()) {
                    continue;
                }

and if the application is exiting, the getline is blocking until the stdin file is closed, so this thread never dies.

Tom94 commented 5 months ago

Hi, that's a great catch! Right below the code you just linked, the thread is detached, which should not allow it to stall the application

// It is unfortunately not easily possible to poll/timeout on cin in a portable manner,
// so instead we resort to simply detaching this thread, causing it to be forcefully
// terminated as the main thread terminates.
stdinThread.detach();

... but your GDB log indeed seems to say otherwise. Could you try removing the stdinThread variable entirely and let me know whether it resolves the issue? If so, I'll try to come up with an alternative.