[Jack-Devel] Jack server keeps playing sound after client disconnetcs

classic Classic list List threaded Threaded
47 messages Options
123
Reply | Threaded
Open this post in threaded view
|

[Jack-Devel] Jack server keeps playing sound after client disconnetcs

yuri@rawbw.com
After the user hits Ctrl-C on the client, jackd keeps playing some sound
it got from this client. Only jackd restart helps.

Why doesn't the server clear the buffer when client disconnects? What
part of code is responsible for cleaning up after a disconnected client?


Problem is observed on the FreeBSD 11.1 with jack-0.125.0


Yuri

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

Ralf Mardorf
Begin forwarded message:

Date: Thu, 24 Aug 2017 17:51:25 +0200
From: Ralf Mardorf
To: Yuri
Subject: Re: [Jack-Devel] Jack server keeps playing sound after client
disconnetcs


On Thu, 24 Aug 2017 08:14:35 -0700, Yuri wrote:
>After the user hits Ctrl-C on the client, jackd keeps playing some
>sound it got from this client.  

FWIW SIGINT could be handled by the client, IOW Ctrl+C not necessarily
does what you expect it to do, Ctrl+C doesn't result in e.g. SIGKILL.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

Ralf Mardorf
In reply to this post by yuri@rawbw.com
On Thu, 24 Aug 2017 08:56:40 -0700, Yuri wrote:
>On 08/24/17 08:51, Ralf Mardorf wrote:
>> FWIW SIGINT could be handled by the client, IOW Ctrl+C not
>> necessarily does what you expect it to do, Ctrl+C doesn't result in
>> e.g. SIGKILL.  
>
>
>If Jack relies on clients to clean up, this will require fixing a lot
>of clients for this to work. It is better if this is handled in the
>server.

Hi Yuri,

seemingly jackaudio.org was down, so consider to resend your concerns
to the mailing list, since it's up again. I'm not a jackd developer,
just a user and simply try to point out, that Ctrl+C isn't a shortcut
that ensures a specific action of an application. You seem to assume
that Ctrl+C does kill an app or something similar, but actually an app
is free to continue running or to do anything else.

Regards,
Ralf
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

Ralf Mardorf
On Thu, 24 Aug 2017 11:50:23 -0700, Yuri wrote:

>On 08/24/17 10:31, Ralf Mardorf wrote:
>> seemingly jackaudio.org was down, so consider to resend your concerns
>> to the mailing list, since it's up again. I'm not a jackd developer,
>> just a user and simply try to point out, that Ctrl+C isn't a shortcut
>> that ensures a specific action of an application. You seem to assume
>> that Ctrl+C does kill an app or something similar, but actually an
>> app is free to continue running or to do anything else.  
>
>
>No, I am not assuming this. Ctrl+C, of course, doesn't guarantee a
>particular action. I am just pointing out that in case of a
>client-server architecture, which is the case here, server can't rely
>on the client to always take a particular action before disconnecting.
>It is a much more sound strategy to always clean up after
>disconnecting client regardless of what the client did.
>
>
>So, you are saying that all OSes suffer from this problem, not only
>FreeBSD? One client I observed this recently with is 'sclang' from
>SuperCollider.

Hi,

I don't know, I'm on Linux, but don't use Ctrl+C to exit an app
launched by command line, that is a jackd client. Either I'm using the
apps regular options to exit or if something should go wrong, I'm using
a script to send all apps that are part of a jackd session, including
jackd, a SIGKILL, before the same script restores the jackd session.
IMO a sound server aimed for real-time usage should assume that clients
do the right thing. Much likely the sound architecture of FreeBSD isn't
that reliable for a real-time audio sound server as ALSA in combination
with the Linux kernel's real-time capabilities is. Actually I don't
understand the problem. Why do you sent a SIGINT to an app? What is
done by the app, after receiving the SIGINT? I don't know what jackd
does or should do. The strategy you mentions might be right or wrong,
however, using Ctrl+C IMO is asking for trouble, since we seldom know
what action does follow.

Regards,
Ralf
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

Malik Costet
On 2017-08-24 22:22, Ralf Mardorf wrote:

> On Thu, 24 Aug 2017 11:50:23 -0700, Yuri wrote:
>> No, I am not assuming this. Ctrl+C, of course, doesn't guarantee a
>> particular action. I am just pointing out that in case of a
>> client-server architecture, which is the case here, server can't rely
>> on the client to always take a particular action before disconnecting.
>> It is a much more sound strategy to always clean up after
>> disconnecting client regardless of what the client did.
>
> IMO a sound server aimed for real-time usage should assume that clients
> do the right thing.

That's a very fine line there. Yes, the server should put the onus on
the client to do the right thing /in order to achieve functionality for
that client/, but at the same time, the server should not make it
possible for one misbehaving client to impair functionality of behaving
clients.

I'm saying this because I just had an issue (see "Too many servers
already active" thread, in which Yuri was involved) which could possibly
be an example of this -- I don't know whether the two are related --
namely, that misbehaving clients would lead to a situation where the
server itself became unusable. This is something that IMHO the server
should prevent.

In other words, while compliant clients SHOULD take steps, for instance,
to de-register themselves from the server on exit, the server MUST have
means of detecting and evicting "bad" clients, at the very least so that
they don't affect the server's very functioning. It doesn't have to be
immediate, or come without any temporary, functional issues at all
costs; but at least in the long run, the server should be able to
recover. This isn't a matter of real-time or no; it's a requirement for
a collaborative software environment.

M.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

Chris Caudle
On Thu, August 24, 2017 4:12 pm, Malik Costet wrote:
> the server should not make it
> possible for one misbehaving client to impair functionality of behaving
> clients.

In general that should be the case.  When clients are too slow in
processing you will sometimes see jackd messages about removing
"zombified" clients.
The behavior you described seems like jackd for some reason was processing
the buffers as if the client app was still filling the buffers with new
data, when in fact it had not.

I think the original message said that jackd kept playing old audio. If it
was just jack playing out the buffers with old data I would expect at most
maybe 30 ms of audio (e.g. 512 samples per period, 3 periods, 48k
samples/second) which would not really be recognizable audio.  Was that
what was meant by playing back old audio, or did it mean a recognizable
section of audio, like 250 ms or more?  In that case I would suspect the
application was mismanaging the buffers in some way.

--
Chris Caudle


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

David Kastrup
"Chris Caudle" <[hidden email]> writes:

> On Thu, August 24, 2017 4:12 pm, Malik Costet wrote:
>> the server should not make it
>> possible for one misbehaving client to impair functionality of behaving
>> clients.
>
> In general that should be the case.  When clients are too slow in
> processing you will sometimes see jackd messages about removing
> "zombified" clients.
> The behavior you described seems like jackd for some reason was processing
> the buffers as if the client app was still filling the buffers with new
> data, when in fact it had not.
>
> I think the original message said that jackd kept playing old audio. If it
> was just jack playing out the buffers with old data I would expect at most
> maybe 30 ms of audio (e.g. 512 samples per period, 3 periods, 48k
> samples/second) which would not really be recognizable audio.  Was that
> what was meant by playing back old audio, or did it mean a recognizable
> section of audio, like 250 ms or more?  In that case I would suspect the
> application was mismanaging the buffers in some way.

As a note aside: I had the Aeolus/jackd combination occasionally getting
stuck and just producing noise semipermanently.  It might have been
because I was running 32-bit applications on 64-bit kernel: ALSA passes
structures into system calls that are different in size for 32-bit and
64-bit code and does no conversions to make them fit.  It's a wonder
that the application usually worked.  Until it didn't, of course.  I was
running a 64-bit Jackd however.

--
David Kastrup
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

yuri@rawbw.com
In reply to this post by Ralf Mardorf
On 08/24/17 13:22, Ralf Mardorf wrote:
> Much likely the sound architecture of FreeBSD isn't
> that reliable for a real-time audio sound server as ALSA in combination
> with the Linux kernel's real-time capabilities is.


What makes you think that the sound architecture isn't stable on the
FreeBSD?


Sorry, but you are completely wrong. It's Jack that doesn't clean up
after the failed clients that is a problem.


Yuri


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

Ralf Mardorf
On Thu, 24 Aug 2017 19:15:38 -0700, Yuri wrote:
>What makes you think that the sound architecture isn't stable on the
>FreeBSD?
>
>
>Sorry, but you are completely wrong. It's Jack that doesn't clean up
>after the failed clients that is a problem.

Beside my Linux installs I had a FreeBSD install to test a sound card.
FreeBSD is not real-time capable, you need very long latency. The sound
architecture can't compare to ALSA. Chris already mentioned that you
could expect that jackd is playing out the buffers, which means at
reasonable latencies, that you couldn't notice it.

So there are several open questions.

How much latency do you use?
What action does cause Ctrl+C?
What happens if you exit the application by a regular exit option or by
a SIGKILL?
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

yuri@rawbw.com
On 08/24/17 22:30, Ralf Mardorf wrote:
> FreeBSD is not real-time capable, you need very long latency. The sound

What exactly is the evidence of this?

> So there are several open questions.
>
> How much latency do you use?

How can I know this?


> What action does cause Ctrl+C?
Application quits, sound keeps playing.
The expected behavior: sound stops playing.
The suspected cause: jackd fails to clean up after the disconnected client.

> What happens if you exit the application by a regular exit option or by
> a SIGKILL?

This particluar application, sclang, doesn't quit by itself without
Ctrl-C, if this isn't encoded in the script.


Yuri
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack server keeps playing sound after client disconnetcs

John Rigg-16
On 08/24/17 22:30, Ralf Mardorf wrote:
> FreeBSD is not real-time capable, you need very long latency.

FreeBSD has a preemptive scheduler and facilities for allowing
realtime privlleges for processes. Are you sure you're not
confusing it with one of the other *BSDs?

John
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Jack server keeps playing sound after client disconnetcs

Ralf Mattes
 
Am Freitag, 25. August 2017 08:25 CEST, John Rigg <[hidden email]> schrieb:
 
> On 08/24/17 22:30, Ralf Mardorf wrote:
> > FreeBSD is not real-time capable, you need very long latency.
>
> FreeBSD has a preemptive scheduler and facilities for allowing
> realtime privlleges for processes. Are you sure you're not
> confusing it with one of the other *BSDs?

And, just to note: there are valid use cases for running jack without
low latency demands. As a matter of fact, unless you do realtime
(i.e. on-stage) audio processing/manipulation there's no need for
low latency. Actually, it' s a pretty good idea to increase buffer sizes
(read: high latency) when doing recordings.

 Cheers, RalfD

> John
> _______________________________________________
> Jack-Devel mailing list
> [hidden email]
> http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
 
 
 
 


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Jack server keeps playing sound after client disconnetcs

Ralf Mattes
 
Sorry, used the wrong sender:

Am Freitag, 25. August 2017 10:42 CEST, "Ralf Mattes" <[hidden email]> schrieb:
 

>
> Am Freitag, 25. August 2017 04:15 CEST, Yuri <[hidden email]> schrieb: >
> > Sorry, but you are completely wrong. It's Jack that doesn't clean up> after the failed clients that is a problem.
> >
>
> So far this is only your diagnosis and it's backed up by very little evidence.
> You haven't provided us with information about the real symptoms -
> "old audio" is a pretty broad description. Are we talking about the amount
> of audio data that gets processed in one jack process callback (as Chris Claude
> wrote, that would be sample-rate / (n-periods * buffer-size) ). I doubt you can
> even hear this. For anything longer, I think your diagnosis is off. Where should
> those sample came from? Who would be filling the shared memory buffers?
> I think for any serious debugging you need to provide us with better symptom
> descriptions. For example, as Ralf already did notice, sending an interrupt signal
> to a process doesn't mean that that process dies an instant death. The process could
> have installed a signal handler that performs, a graceful fade-out. Also, you wrote:
>
> > This particluar application, sclang, doesn't quit by itself without
> > Ctrl-C, if this isn't encoded in the script.
>
> I hope you now that sclang is not a jack (audio) client, it's only an interpreter that
> controls the supercollider server process (scsynth or supernova) by means of OSC
> messages. You either need to send the server a stop message or kill it.
> > Sorry, but you are completely wrong. It's Jack that doesn't clean up> after the failed clients that is a problem.
>
> Can you describe what you would expect as a "clean up? AFAIK jackd plays the
> last filled buffer, then detects that the client fails to fill the buffers and "zombifies"
> (read: kills) the client - unless you told the server not to! Did you? Or did you crank up
> the client timeout?
>
>  Cheers, Ralf Mattes
>
>
> > Yuri
> >
> >
> > _______________________________________________> Jack-Devel mailing list
> > [hidden email]
> > http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
>
 
 
 
 


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Jack server keeps playing sound after client disconnetcs

Ralf Mardorf
In reply to this post by Ralf Mattes
On Fri, 25 Aug 2017 10:15:26 +0200, Ralf Mattes wrote:

>
>Am Freitag, 25. August 2017 08:25 CEST, John Rigg <[hidden email]>
>schrieb:
>
>> On 08/24/17 22:30, Ralf Mardorf wrote:  
>> > FreeBSD is not real-time capable, you need very long latency.  
>>
>> FreeBSD has a preemptive scheduler and facilities for allowing
>> realtime privlleges for processes. Are you sure you're not
>> confusing it with one of the other *BSDs?  
>
>And, just to note: there are valid use cases for running jack without
>low latency demands. As a matter of fact, unless you do realtime
>(i.e. on-stage) audio processing/manipulation there's no need for
>low latency. Actually, it' s a pretty good idea to increase buffer
>sizes (read: high latency) when doing recordings.

To idiotic high values, that long that playing out the buffer could be
considered to be annoying?

This is the context you seem to ignore:
On Thu, 24 Aug 2017 17:35:33 -0500, Chris Caudle wrote:
>I think the original message said that jackd kept playing old audio.
>If it was just jack playing out the buffers with old data I would
>expect at most maybe 30 ms of audio (e.g. 512 samples per period, 3
>periods, 48k samples/second) which would not really be recognizable
>audio.

Wouldn't it be around 15 ms, since 30 ms would be round-trip latency?

To get something audible of e.g. annoying long 128 ms you need 4096
frames, 3 periods, 48k sample rate. 128 ms are 1/16 note at 117 BPM.

And assuming I should be mistaken, than it would be 256 ms, 1/8 note at
117 BPM.

The OP does use that long latency, if playing out the buffer should be
that long audible, or the issue is not related to playing out the
buffer.

Regards,
Ralf

PS:

On Fri, 25 Aug 2017 06:25:03 +0000, John Rigg wrote:
>FreeBSD has a preemptive scheduler and facilities for allowing
>realtime privlleges for processes. Are you sure you're not
>confusing it with one of the other *BSDs?

I installed FreeBSD because it has got a driver for the RME HDSPe AIO.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Jack server keeps playing sound after client disconnetcs

Chris Caudle
On Fri, August 25, 2017 9:05 am, Ralf Mardorf wrote:
> To get something audible of e.g. annoying long 128 ms you need 4096
> frames, 3 periods, 48k sample rate. 128 ms are 1/16 note at 117 BPM.

If jackd had a bug that caused it to continue playing buffers even when
the client stopped processing (not confirmed, I think that is not very
likely), but if that occured, even a very short buffer replayed
continuously would make a very annoying buzzing noise from repeatedly
playing the same samples.

Given the  information from Ralf Mattes it seems more likely that the
sclang program that was stopped stopped providing data, but the scserver
process kept processing the buffers, so from the jackd perspective the
client was still active.
I may try to replicate this weekend, but may be a little difficult, I
changed my machine to Fedora 26, but SuperCollider is from the CCRMA
repositories, and Fernando is still on summer holiday, so there is no
Planet CCRMA for Fedora 26 yet.  Maybe F25 packages will still work, I
will try.

--
Chris Caudle


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Jack server keeps playing sound after client disconnetcs

yuri@rawbw.com
On 08/25/17 07:56, Chris Caudle wrote:

> If jackd had a bug that caused it to continue playing buffers even when
> the client stopped processing (not confirmed, I think that is not very
> likely), but if that occured, even a very short buffer replayed
> continuously would make a very annoying buzzing noise from repeatedly
> playing the same samples.
>
> Given the  information from Ralf Mattes it seems more likely that the
> sclang program that was stopped stopped providing data, but the scserver
> process kept processing the buffers, so from the jackd perspective the
> client was still active.

I can tell you with certainty that no SC server keeps running. The
testcase causing this problem creates its own server, see it below.

I also observed the problem with other clients.



Yuri


---testcase---

s = Server.local;
s.boot;

(
   s.waitForBoot{
     (
       play(
         {
           SinOsc.ar(
             freq: 1000
           )
         }
       );
       s.record(path:
"/home/yuri/proj/app-stable-working/gui-sound/out-xxx.wav", numChannels: 1);
       3.wait;
       s.stopRecording;
     )
   }
)

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Jack server keeps playing sound after client disconnetcs

Ralf Mardorf
In reply to this post by Chris Caudle
On Fri, 25 Aug 2017 09:56:56 -0500, Chris Caudle wrote:

>On Fri, August 25, 2017 9:05 am, Ralf Mardorf wrote:
>> To get something audible of e.g. annoying long 128 ms you need 4096
>> frames, 3 periods, 48k sample rate. 128 ms are 1/16 note at 117
>> BPM.  
>
>If jackd had a bug that caused it to continue playing buffers even when
>the client stopped processing (not confirmed, I think that is not very
>likely), but if that occured, even a very short buffer replayed
>continuously would make a very annoying buzzing noise from repeatedly
>playing the same samples.
>
>Given the  information from Ralf Mattes [snip]

Oops, my apologies to Ralf Mattes, I didn't notice this reply, where he
also mentions the "latency" in the context of playing out the buffer.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Jack server keeps playing sound after client disconnetcs

yuri@rawbw.com
On 08/25/17 08:50, Ralf Mardorf wrote:
> Oops, my apologies to Ralf Mattes, I didn't notice this reply, where he
> also mentions the "latency" in the context of playing out the buffer.


The question in this thread is why jack keeps playing sound after client
disconnects.

Latency positively has nothing to do with this problem.


Yuri


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Jack server keeps playing sound after client disconnetcs

Malik Costet
On 2017-08-25 18:07, Yuri wrote:
> On 08/25/17 08:50, Ralf Mardorf wrote:
>> Oops, my apologies to Ralf Mattes, I didn't notice this reply, where he
>> also mentions the "latency" in the context of playing out the buffer.
>
> The question in this thread is why jack keeps playing sound after
> client disconnects.
>
> Latency positively has nothing to do with this problem.

Are you saying in goes on indefinitely? So not a matter of some leftover
buffers being rendered and then that's it -- but something that keeps
going on, like the "buzzing noise" Chris mentioned?

FWIW, I believe I've seen cases of this occurring in my testing, upon
buggy shutdowns of clients.

M.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Jack server keeps playing sound after client disconnetcs

yuri@rawbw.com
On 08/25/17 09:11, Malik Costet wrote:
> Are you saying in goes on indefinitely? So not a matter of some leftover
> buffers being rendered and then that's it -- but something that keeps
> going on, like the "buzzing noise" Chris mentioned?

Yes, it goes indefinitely, and requires jackd restart.


Yuri
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
123