Bug 178930

Summary: aRts starts in multiple instances
Product: [openSUSE] openSUSE 10.3 Reporter: Michael Schueller <schueller-berlin>
Component: KDEAssignee: E-mail List <kde-maintainers>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P3 - Medium CC: james, kde-maintainers, mc, mike_wells, mrmazda, suse-beta, vgorobets
Version: RC 1   
Target Milestone: ---   
Hardware: All   
OS: SuSE Linux 10.1   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: /work/SRC/all/KDE/arts/arts-start-on-demand.diff
arts patch
kdebase3 patch
kdebase3 patch

Description Michael Schueller 2006-05-25 20:55:50 UTC
Hello,
when i try to start aRts by an application (like xine with aRts-output), aRts starts in multiple instances. 
The Problem seems to depend to the "arts-start-on-demand" Patch, because when i remove the Patch before rebuilding aRts, i can start arts with no Problem.
I already explained the Problem to the Author of aRts, and i would like to let you know the answer.

Michael

---------------------------------------------------------------------------
   Hi!

Ich schreib' Dir erstmal eine schnelle Antwort. Wenn Du mehr wissen
willst, frag' mich nochmal nach Details.

Also

1. das in mcop/tmpglobalcomm.cc reinzuhacken ist eine schlechte Idee,
aus mehreren Gründen
  - es gibt noch X11GlobalComm (was man verwendet, wenn artsd nicht über
    /tmp sondern übers X11-Display zwischen den einzelnen Programmen
    Informationen austauscht, wo artsd läuft, und was er da macht

  - der richtige Ort wäre 

string ObjectManager::getGlobalReference(const string& name)
    
    Code sollte in etwa lauten:

    (a) prüfen ob das Objekt da ist
    (b) wenn nicht, es sich aber um ein bekanntes Objekt handelt:

        (das wären diese hier (aus artsd.cc kopiert)):

        result=om->addGlobalReference(server,"Arts_SoundServerV2")
            && om->addGlobalReference(server,"Arts_SoundServer")
            && om->addGlobalReference(server,"Arts_SimpleSoundServer")
            && om->addGlobalReference(server,"Arts_PlayObjectFactory")
            && om->addGlobalReference(audioManager,"Arts_AudioManager");


       (1) Startvorgang auslösen (also system("kcminit arts"))
       (2) warten, bis artsd gestartet ist (also etwa mit Timeout,
           und immer wieder prüfen ob artsd da ist)

           das ist *ganz wichtig*, weil kcminit arts sofort zurückkommt,
           aber artsd dann noch nicht notwendigerweise fertig
           initialisiert ist

    (c) Referenz auf den frisch gestarteten artsd zurückgeben (also
        nochmal das GlobalComm objekt fragen)

2. eine statische Variable verhindert nicht ausreichend gut, dass nicht
zweimal artsd gestartet werden kann; der Grund ist, dass es mehrere
Prozesse gibt, die auf artsd zugreifen können - wenn artsd jetzt nicht
da ist, wird in *jeder* Prozess artsd starten, und dann hat man halt
fünf Stück, wenn das fünf Prozesse waren

Hier kann auch das GlobalComm Objekt helfen: *vor* dem starten von artsd
eine art lock damit anlegen, *nach* dem starten von artsd den lock
wieder wegmachen - allerdings ist das Problem dabei, dass der lock
liegenbleiben könnte, und dann würde niemand mehr versuchen artsd zu
starten

Zuverlässigen Code, der sowas macht, gibt es in artsd.cc, der kümmert
sich ja darum, daß im GlobalComm Objekt die Referenzen dann gelöscht
werden, wenn artsd nicht mehr läuft, aber die entsprechenden Einträge
trotzdem noch da sind. Das funktioniert darüber, daß tatsächlich
versucht wird eine Verbindung zu artsd aufzubauen.


3. wenn man sowas macht, dann will man vielleicht einen generischen Weg
implementieren, der nicht irgendwas hardcoded; aber dann wird es noch
komplizierter, weil alles was wir bisher als fest annehmen
(beispielsweise welches Programm man aufrufen muss, damit artsd
gestartet wird, und welche Objekte er dann registriert) dann Variablen
sind; also selbst wenn alles in (1) und (2) entsprechend geändert wird,
würde ich nicht empfehlen, daß KDE das Feature backfolded und mit neuen
aRts Versionen mitreleast.


Zusammenfassend: der Patch kann so nicht gehen, und es ist nicht einfach
einen zu schreiben, der tut.

   Cu... Stefan

On Thu, May 25, 2006 at 12:15:14PM +0200, Michael Schueller wrote:
> Hallo Stefan,
> bitte erlaube mir mich an Dich zu wenden.
> Da Du der Author von arts bist, und ich hier mit arts ein kleines 
> Problem hab, dachte ich Du wärst der Richtige Ansprechpartner.
> 
> Es geht in meinem Problem um den "arts-start-on-demand" Patch, der , 
> soweit ich weiß, seit SuSE 10.0 verbaut wird.
> Es scheint so als ob dieser Patch dazu führt das arts, wenn er 
> gestartet wird, nicht nur einmal sondern 3-6 mal gestartet wird.
> 
> Im ~/.xsession-errors ist dazu folgendes notiert
> --------------------------------------------------------------------------------
> There are already artsd objects registered, looking if they are 
> active...
> server status: running, autosuspend disabled
> real-time status: real-time
> server buffer time: 31.9728 ms
> buffer size multiplier: 1
> minimum stream buffer time: 31.9728 ms
> auto suspend time: 0 s
> audio method: alsa
> sampling rate: 44100
> channels: 2
> sample size: 16 bits
> duplex: half
> device: default
> fragments: 6
> fragment size: 940
> warning: leaving MCOP Dispatcher and still 9 object references 
> alive.
>   - Arts::SampleStorage
>   - Arts::Synth_MULTI_ADD
>   - Arts::Synth_MULTI_ADD
>   - Arts::Synth_PLAY
>   - Arts::StereoVolumeControl
>   - Arts::StereoEffectStack
>   - Arts::Synth_BUS_DOWNLINK
>   - Arts::SoundServerV2
>   - Arts::MidiManager
> warning: leaving MCOP Dispatcher and still 75 types alive.
> sound server terminated
> ... cleaned 5 unused mcop global references.
> 
> There are already artsd objects registered, looking if they are 
> active...
> There are already artsd objects registered, looking if they are 
> active...
> 
> Error: Can't add object reference (probably artsd is already 
> running).
>        If you are sure it is not already running, remove the 
> relevant files:
> 
>        /tmp/ksocket-marvin/Arts_SoundServerV2
>        /tmp/ksocket-marvin/Arts_SoundServer
>        /tmp/ksocket-marvin/Arts_SimpleSoundServer
>        /tmp/ksocket-marvin/Arts_PlayObjectFactory
>        /tmp/ksocket-marvin/Arts_AudioManager
> 
> starting artsd!
> There are already artsd objects registered, looking if they are 
> active...
> 
> Error: Can't add object reference (probably artsd is already 
> running).
>        If you are sure it is not already running, remove the 
> relevant files:
> --------------------------------------------------------------------------------
> 
> ...und so geht das dann immer weiter.
> Beobachte ich den Vorgang mit top, sehe ich wie bis zu 6 Instanzen 
> um die Vorherschaft kämpfen und dabei bis zu 40% CPU vereinnahmen.
> Der Vorgang hält ca 5 min an, bis dann nur noch eine Instanz übrig 
> ist.
> 
> Nun hab ich versucht den Patch wegzulassen.
> Das Ergebniss ist eindeutig. Arts wird nunmehr nicht mehr durch eine 
> Anwendung gestartet, aber wenn ich im Kontrollzentrum den Sound 
> prüfe, wird arts in wenigen sekunden gestartet, und auch nur 
> einmal.
> 
> Da ich nun also den Eindruck habe das mit dem Patch was nicht 
> stimmt, wollte ich Dich bitten mal einen Blick darauf zu werfen.
> Ich denke das hier irgendwas mit dem Aufruf von aRts nicht stimmt.
> 
> Vielen Dank
> Michael Schüller
> 
> Index: mcop/tmpglobalcomm.cc
> ================================================================================
> --- mcop/tmpglobalcomm.cc
> +++ mcop/tmpglobalcomm.cc
> @@ -54,8 +54,17 @@
>       {
>               string result = "";
>               string filename = MCOPUtils::createFilePath(variable);
> +             static bool started_arts = false;
>  
>               int fd = open(filename.c_str(),O_RDONLY);
> +             if (fd == -1 && !started_arts) 
> +             {
> +                       fprintf(stderr, "starting artsd!\n");
> +                       system("kcminit arts");
> +                       fd = open(filename.c_str(),O_RDONLY);
> +                    started_arts = true;
> +             }
> +
>               if(fd != -1)
>               {
>                       char buffer[8192];
> 

-- 
Stefan Westerfeld, Hamburg/Germany, http://space.twc.de/~stefan
Comment 1 Lukas Tinkl 2006-11-06 14:00:25 UTC
Fixed package submitted (next time please post only English content to Bugzilla)
Comment 2 Stephan Binner 2006-11-09 13:13:05 UTC
Updated to Factory this morning and atm I have seven artsd processes running and get every minute a messagebox stating a fatal sound server error: "device /dev/dsp can't be opened (Device or resource busy).
Comment 3 Stephan Kulow 2006-11-09 13:16:21 UTC
Stephan, please revert Lukas's fix for now (and attach it here)
Comment 4 Stephan Binner 2006-11-10 10:03:20 UTC
*** Bug 219760 has been marked as a duplicate of this bug. ***
Comment 5 Stephan Binner 2006-11-10 10:07:29 UTC
Created attachment 104621 [details]
/work/SRC/all/KDE/arts/arts-start-on-demand.diff
Comment 6 Michael Schueller 2006-11-10 12:57:03 UTC
Sorry, but i really can´t see what this patch (and the dependig one in kdebase3) shell do at all.
Since i know about this patches i remove them both,rebuild arts and kdebase3, and everything works fine.
I can use alsa and arts side by side. For some applications i set ALSA as the soundserver, for some arts, and i can use them without any Problems by the same time. And even if i don´t wanne use arts at all, i can disable it from the KControl.
So please, remove this patches, try it, and think about why you actualy need it ...

Thanks
Michael
Comment 7 Stephan Kulow 2006-11-10 13:33:21 UTC
It's pretty clear what we want with the patches: not having artsd running without any applications needing it.
Comment 8 Michael Schueller 2006-11-10 13:42:23 UTC
(In reply to comment #7)
> It's pretty clear what we want with the patches: not having artsd running
> without any applications needing it.
> 

Ok, so disable artsd automatically after x second by kcontrol
Comment 9 Stephan Kulow 2006-11-10 13:51:45 UTC
it's still running then
Comment 10 Michael Schueller 2006-11-10 14:06:25 UTC
(In reply to comment #9)
> it's still running then
> 

And where ?

If i take a look with top, there is no artsd running, and i have 0,0% CPU usage. So if there is a artsd waiting in the backround, it does not take any CPU usage, and this is most importand.
This was the reason why you don´t wanne have artsd running, because of the CPU usage, but there is non.
Comment 11 Christian Boltz 2006-11-14 22:15:15 UTC
I hit exactly the same bug - it causes a high load on the CPU (high enough to activate the fan of my laptop, which usually happens very rarely).
I also see my .xsession-errors flooded (12 MB) with the messages described in the duplicate (bug 219760)

This bug is not just major, it's critical because of a "major CPU leak" ;-)
Comment 12 Stephan Kulow 2006-11-16 11:21:21 UTC
you hit the bug before #3
Comment 13 James Mason 2006-11-22 21:59:45 UTC
I'm having this trouble as well, with 10.2 beta2+ on intel i810 sound.  Bug 222540 alluded to a fix by adding the users to the audio group.

I'm using Active Directory (samba) authentication, how can I automatically include  samba-authenticated users into the audio group?
Comment 14 Dirk Mueller 2006-11-22 22:51:29 UTC
James: please don't hijack bugreports. File a new one if you have troubles with starting arts under samba-authenticated users. 
Comment 15 James Mason 2006-11-24 18:37:19 UTC
Dirk: sorry for the 'hijack'.  I'm experience the root problem described in the bug report.  I post here because I think it is relevant that I am not logging in with a local user account, but through samba authentication.  Perhaps there is something in the default permissions applied to non-local authenticated users that may be contributing to the problem.

Is anybody else experiencing this logging in as a non-local user?
Comment 16 Mike Wells 2006-11-29 17:50:01 UTC
After installing Macromedia Flash-Player (from Beta2 dvd) and visiting a website (via Konqueror) that invokes same, MANY instances of aRtsd are invoked and remain until system is rebooted. Essentially brings system to its knees. Had to uninstall Flash-Player.
Comment 17 Lubos Lunak 2007-04-26 16:34:52 UTC
Ok, I think I have a fix (actually a rather ugly hack, but this is for arts, right?).
Comment 18 Lubos Lunak 2007-04-26 16:36:51 UTC
Created attachment 135201 [details]
arts patch

Updated arts-start-on-demand.diff
Comment 19 Lubos Lunak 2007-04-26 16:37:39 UTC
Created attachment 135205 [details]
kdebase3 patch

New patch, arts-start-on-demand-kdebase.diff
Comment 20 Lubos Lunak 2007-04-26 16:38:06 UTC
Created attachment 135207 [details]
kdebase3 patch

Updated startkde.diff (last snippet).
Comment 21 Lubos Lunak 2007-04-26 16:38:53 UTC
The arts-start-on-demand-kdebase.diff patch also adds new binary /opt/kde3/bin/arts-start .
Comment 22 Lubos Lunak 2007-05-17 13:57:24 UTC
*** Bug 216043 has been marked as a duplicate of this bug. ***
Comment 23 Dirk Mueller 2007-09-14 13:33:16 UTC
.
Comment 24 Lubos Lunak 2007-09-19 14:33:53 UTC
No idea why this is closed, it's apparently not done for 10.3 at least.
Comment 25 Lubos Lunak 2007-09-19 14:34:24 UTC
*** Bug 326378 has been marked as a duplicate of this bug. ***
Comment 26 Dirk Mueller 2007-09-20 08:22:28 UTC
submitted for 10.3