saalfeldlab / paintera

GNU General Public License v2.0
95 stars 17 forks source link

Paintera Process not exiting when closing application #479

Closed cmhulbert closed 1 year ago

cmhulbert commented 1 year ago

reported by @axtimwalde Associated stacktrace when forcing the process to quit via Ctrl-C

Traceback (most recent call last):
  File "/home/saalfelds/anaconda3/envs/paintera/bin/paintera", line 11, in <module>
    sys.exit(launch_paintera())
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/site-packages/paintera/__init__.py", line 59, in launch_paintera
    return jgo.util.main_from_endpoint(
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/site-packages/jgo/util.py", line 71, in main_from_endpoint
    main(argv=argv)
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/site-packages/jgo/jgo.py", line 290, in _jgo_main
    completed_process = run(parser, argv=argv, stdout=stdout, stderr=stderr)
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/site-packages/jgo/jgo.py", line 588, in run
    return launch_java(workspace, jvm_args, main_class, *program_args, additional_jars=args.additional_jars, stdout=stdout, stderr=stderr, check=False)
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/site-packages/jgo/jgo.py", line 197, in launch_java
    return subprocess.run((java, '-cp', cp) + jvm_args + (main_class,) + app_args, stdout=stdout, stderr=stderr, **subprocess_run_kwargs)
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/subprocess.py", line 503, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/subprocess.py", line 1141, in communicate
    self.wait()
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/subprocess.py", line 1204, in wait
    return self._wait(timeout=timeout)
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/subprocess.py", line 1938, in _wait
    (pid, sts) = self._try_wait(0)
  File "/home/saalfelds/anaconda3/envs/paintera/lib/python3.10/subprocess.py", line 1896, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
KeyboardInterrupt
cmhulbert commented 1 year ago

@axtimwalde do you have steps that duplicate this? I've tried just opening an existing project, do some painting/shape interpolation operations and then closing, but the process quits properly when exiting.

axtimwalde commented 1 year ago

Nothing special. Open, close. Did you test the release version?

axtimwalde commented 1 year ago

Also, I am working on a project on a network drive, may be speed matters.

cmhulbert commented 1 year ago

Nothing special. Open, close. Did you test the release version?

Yes, I was testing against the current release. I have seen similar issue while debugging for example, but can't duplicate with the release. I'll keep trying. I can test over the network also

axtimwalde commented 1 year ago

It's the MIDI controller! Needs to be closed at exit or will prevent JVM from closing. You should use it more :).

axtimwalde commented 1 year ago

Found with VisualVM.

cmhulbert commented 1 year ago

Thanks for investigating. I should be able to get a quick fix for this then :+1:

cmhulbert commented 1 year ago

Seems this is a known bug (https://bugs.openjdk.org/browse/JDK-8232862). This results in the Midi device thread never returning cooperatively when closing the midi device. When Paintera quits, it calls Platform.exit which is specific to closing a JavaFx application. However, this differs from System.exit in that it doesn't force non-daemon threads to return. The result is that the Midi thread is still running. Until the bug is fixed at least, there should be no harm in explicitly calling System.exit afterPlatform.exit