brummer10 / Mamba

Virtual Midi keyboard and Midi Live Looper for Jack Audio Connection Kit
BSD Zero Clause License
76 stars 5 forks source link

mamba hangs when trying to rm in non-session-manager #44

Closed grammoboy2 closed 2 years ago

grammoboy2 commented 2 years ago

Sorry, but mamba hangs when trying to rm in non-session-manager. It gets killed, but not removed it seems (at session close for instance).

edit: mamba latest git version

grammoboy2 commented 2 years ago

$ mamba & [1] 1698428 [~]$ NSM: Successfully registered. NSM says: Well hello, stranger. Welcome to the party.Samplerate 48000Hz Buffersize is 256 samples jack running with realtime priority

~ pgrep mamba 1698428 ~ kill 1698428 ~ pgrep mamba 1698428 ~ pkill mamba ~ pgrep mamba 1698428 ~killall -9 mamba ~ pgrep mamba [1]+ Killed mamba

brummer10 commented 2 years ago

Hi When mamba is under session control the way to remove it is with the used session controller. Here is the output from Raysession when show/hide stop and remove mamba from a session. Works as expected here.

raysession 
[ray-daemon]GUI connected at osc.udp://box:17591/
[ray-daemon]URL : osc.udp://192.168.2.104:16187/
[ray-daemon]      osc.udp://box:16187/
[ray-daemon]ROOT: /home/brummer/Ray Sessions
[ray-daemon]Attempting to open /home/brummer/Ray Sessions/testmamba
qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 630, resource id: 60819469, major code: 40 (TranslateCoords), minor code: 0
[ray-daemon]Commanding smart clients to switch
[ray-daemon]Process has pid: 59133
[ray-daemon]The client "Mamba" at "osc.udp://127.0.0.1:17599/" informs us it's ready to receive commands.

[Mamba-mamba]
NSM: Successfully registered. NSM says: Howdy, what took you so long?
[ray-daemon]Telling all clients that session is loaded...
[ray-daemon]Telling client Mamba that session is loaded.
[ray-daemon]Loaded
[ray-daemon]Done

[Mamba-mamba]
Samplerate 48000Hz 
Buffersize is 128 samples 
jack running with realtime priority

[ray-daemon]Client 'mamba' sends gui hidden
[ray-daemon]Client 'mamba' sends gui shown
[ray-daemon]Client 'mamba' sends gui hidden

[Mamba-mamba]

Mamba: signal 15 received, bye bye ...

[ray-daemon]Done
[ray-daemon]Bye Bye...
grammoboy2 commented 2 years ago

But nsmd kills it which signal 15, which is the same as: pkill mamba, or kill AFAIK. So why isn't mamba killed when sending it pkill or kill when running in NSM.

brummer10 commented 2 years ago

because mamba is a multithread app. To kill it with pkill simply use pkill mamba and don't bother with the pid.

grammoboy2 commented 2 years ago

Did you try to kill mamba when it's running in NSM?

$$ pgrep mamba 1932502 $$ pkill mamba $$ pgrep mamba 1932502

Are you sure about your multi-thread comment? Never heard it before.

brummer10 commented 2 years ago

Work Here as expected. tested with raysession.

grammoboy2 commented 2 years ago

Did a quick test with agordejo and nsm fork on arch linux, same problem

brummer10 commented 2 years ago

Peek 2022-06-25 08-03

grammoboy2 commented 2 years ago

Thanks, will explore further. Maybe it's the Arch package I was using.

grammoboy2 commented 2 years ago

Tested again, also with agordejo. Doesn't work here. NSM_URL is set, nsmd already running, not sure if that makes a difference.

brummer10 commented 2 years ago

Here, there is no problem using pkill, kill -1, kill -9 or kill -15 to terminate mamba when it is under NSM control. There is not much I could do about that, as long I can't reproduce this behave, I can't fix it.

grammoboy2 commented 2 years ago

If I comment out some code (and add a exit 0), it's working.

/*** Exit handlers ****/

void XKeyBoard::signal_handle (int sig) { fprintf (stderr, "signal_handle"); //if(xjack->client) jack_client_close (xjack->client); //xjack->client = NULL; //XLockDisplay(win->app->dpy); //quit(win); //XFlush(win->app->dpy); //XUnlockDisplay(win->app->dpy); fprintf (stderr, "\n%s: signal %i received, bye bye ...\n",client_name.c_str(), sig); exit (0); }

brummer10 commented 2 years ago

That lead to a memleak. Looks like the XServer have take a lock which leads to a deadlock on your machine. It's arch, isn't it? What version of libx11 do you use?

grammoboy2 commented 2 years ago

libx11 1.8.1-3

brummer10 commented 2 years ago

With your edit you disable two different things, first, you disable a clean exit from the jack server, second, you disable a clean exit from the XServer. Both, I strongly recommend to "Not do that". I wonder what happen when you run glxinfo?

grammoboy2 commented 2 years ago

my_glxinfo.txt

brummer10 commented 2 years ago

Okay, that look good. Now, it would be of some interest if, the comment out for the jack server exit, or, the comment out for the XServer exit introduce this issue for you. Have tried it separated, one by one? I mean comment out the first two lines, or comment out the remaining 4 lines?

grammoboy2 commented 2 years ago

Hm strange, seems to work fine now. Did running glxinfo or installing it, fix it?

brummer10 commented 2 years ago

Don't know. I know that upstream X11 have changed there init struct in a way which break a lot of things recently. ( That happen really, really rare) I know that glxinfo didn't run with that break. So, maybe, you get now the fix for libx11 by installing glxinfo, because glxinfo request it, but, I don't know enough about arch to know that. I'm on debian sid, so a bit behind the blending age, At least I'm glade it works now for you. Whenever you face this (or a other) issue again, you are welcome.