-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dbus-daemon is not killed after playback complete #59
Comments
identical for me ;) Aiexis> Can you explain me how you play with omxplayer and dbus, because now, i don't have keyboard ;( only CTRL+C |
I haven't done anything special, just install omxplayer and dbus-x11 (apt-get install dbus-x11). I do not use X11 neither. |
Hello, I have a little solution, Explain : in omxplayer, we have : if test -z "$DBUS_SESSION_BUS_ADDRESS"; then in DBus website (http://www.linuxfromscratch.org/blfs/view/svn/general/dbus.html), I decided to re-crosscompile 'DBus 1.6.8' with little modification : printf ("DBUS_SESSION_BUS_ADDRESS='%s';\n", bus_address); i add this line after : printf ("export DBUS_SESSION_BUS_PID;\n"); And replace /usr/bin/dbus-launch with the new version And, in omxplayer.cpp, i add : int iDBUS_SESSION_BUS_PID = 0; in main function : int main(int argc, char *argv[]) char* pDBUS_SESSION_BUS_PID; After, m_keyboard.Close(); kill(iDBUS_SESSION_BUS_PID, SIGQUIT); Voili Voila, it's OK !! A+ |
@skgsergio
It looks like that is intended to only run dbus-launch once, but it doesn't do that. It launches every time. |
after send a mail to Simon McVittie (DBus Developper) """
""" I'm testing a new call script with dbus-daemon ('deprecate dbus-launch') Florent |
Removing the X11 dependency sounds good. |
SOLUTION 👍 """ cleanup () trap cleanup INT HUP TERM dbus-daemon --fork --print-address 5 --print-pid 6 --session DBUS_SESSION_BUS_ADDRESS=" $OMXPLAYER --font $FONT --italic-font trap - INT HUP TERM Warning `cat testing !! |
If you commit the solution, I sent an email to thank Simon McVittie |
I'll dig about this later, I can't atm. Maybe tomorrow moring I should be able to do it. Anyway seems fair the change. |
i propose commit |
I've been so busy these days, too much work... I've compiled yesterday a new version and I've uploaded it to http://omxplayer.sconde.net/ with @fcarlier fix adapted to my script (I'm not using the same launch script that there is in the repo). You can see my script here: https://gist.github.com/skgsergio/6825354 I've tested it and seems that it's working without problems (Ctrl+C, q, end of the video, ...). |
Hi All, thanks for looking into this issue. Has this fix worked for others? I loop omxplayer via a python subprocess and am still having the problem of dbus-daemon not being killed using the Dec 16 commit. After a day's running, I have hundreds and hundreds of orphan dbus-daemon processes until the Raspberry Pi finally freezes up. |
I still have this issue with this version. I use an old one. |
Thanks Aiexis. Very good to know. This is a pretty serious issue. Unfortunately, correct video rotation was added after dbus support...so it doesn't seem possible to have one without the other. Is it possible (or would it make sense) to disable dbus via command line option? Or maybe a command line option should be required to enable it--since only a very sophisticated user or programmer would be using dbus. |
Aiexis...I've worked around this issue by commenting the DBUS calls in the omxplayer startup script. If you're not using DBUS, this will allow you to use a more recent version of omxplayer (e.g. with correct rotation) without having an issue with dbus-daemon not getting killed. I've found the 12/16 build b34143c works best for me...I've had some aspect ratio and visibility issues with more recent version of the script.
|
Just wondering if there is has any relationship with Issue #124. In the HANG1 situation omxplayer.bin does not terminate and hence I assume the code in omxplayer that comes after it does not get executed, hence the dbus daemons do not get deleted. I have seen the number of daemons increase during the 40 hour run. |
I don't use the omxplayer script at all to run omxplayer. I just run LD_LIBRARY_PATHxxx omxplayer.bin xxxx. I don't see multiple dbus-daemon after multiple starts and stops of omxplayer. I use 'ps xaf | grep -i dbus', and only see ONE dbus-daemon still hanging around. It is also the dbus-daemon omxplayer has started up. When I run the script I get
Maybe a silly question here but what should I do TO GET multiple daemons? @andyjagoe you commented the D-BUS stuff in your script to avoid the dbus-daemon not being killed. I assume without the dbus-daemon forking your application (on top of omxplayer) runs just fine. Do you also have ONE dbus-daemon hanging around? @KenT2 I am running your omx.sh script. I assume that the 'omxplayer' started is the omxplayer script. So, how is it possible to run the script WITH the forking, and does running the script causes the multiple dbus-daemons? I can live with just ONE dbus-daemon hanging around ;) |
I have always assumed my script shown in #124 runs the script and NOT omxplayer.bin. If not I have been doing an unintended thing for 18 months :-( |
Please don't understand me wrong. I'm not saying one shouldn't use the script! I only find it strange why I can't use the script and also like to know if the script really kills the forked daemon, so ZERO daemon hanging around. In my (very little) understanding of D-Bus, the dbus-launch-er starts the dbus-daemon, and providing so a D-Bus interface to omxplayer. But then, shouldn't the dbus-launch-er also be responsible for killing the daemon? Is it correct to be stuck with ONE daemon? Also when omxplayer is started again, how does the launcher knows it is omxplayer again and use the 'hanging around' daemon in stead of starting a new one? Again, I can live with the one hanging around daemon -doesn't causes any harm (yet :) but should it be? |
Just to clarify. With the script in #124 you do not get orphan dbus-daemons because the daemon is killed of by CTRL-C used to get back to the command line. Sorry for misleading you. Orphan daemons occur when testing with Pi Presents. This is probably because I am not killing the omxplayer script correctly. Does anyone know the proper way to dispose of the omxplayer script such that the daemons and omxplayer.bin also get removed. Ideally I would like this to be by the using the PID of the omxplayer script returned by pexpect as I would like eventually to have mooe than one copy of omxplayer running. |
@jehutting Yes, I have one dbus-daemon hanging around. I'm using omxplayer via python subprocess...and perhaps I'm not killing it properly either and have an issue similar to @KenT2 . My code is below and you can see the timer...though most times the EOS from omxplayer ends the subprocess. Would love any thoughts or pointers on how to do this better.
|
Googling a bit, including here http://www.tutorialspoint.com/unix/unix-signals-traps.htm it looks like we should be sending SIGINT rather than SIGTERM or SIGKILL. This gives the omxplayer script a chance to tidy up. Having said that I cannot see anything in the omxplayer script to catch the SIGINT. Maybe there is something magic that means trap is not required or CRTL C from LXTerminal does some special magic. I'll experiment tomorrow. |
Thanks @andyjagoe and @KenT2 for the feedback. So if I summarize,
With killing is meant really killing, just abrupt ending omxplayer and/or omxplayer script. I can imagine that this makes them unable to do some house cleaning stuff; allocated space, OMX core components resources not being released, and the forked dbus-daemon not being notified that it should die. How would a bash script be able to do so? Is there a signal trap handling? Don't think there is something automatically done for that. Also, there will be a point where the OS runs out of resources (memory). Don't think there is such a thing as a garbage collector, or is there nowadays? The ONE dbus-daemon should it be there? Still have the feeling it shouldn't. Would be interesting to know if WE ALL have this ONE dbus-daemon left over. SO if one has some spare time, use 'ps xaf | grep -i dbus' and let me know. Just for fun! Besides this D-Bus problem, I think that all those orphans is caused by that other issue which I'm looking at: the hangups. THAT issue is the reason why you guys need to kill omxplayer. It is simply a work around :-) Sending a signal Andyjagoe, I see that the monitor does send a SIGTERM. Event with this, omxplayer does NOT wish you a nice day? Would be interesting too. |
@jehutting I notice that when I boot Raspbian even before running omxplayer that there is a dbus-daemon and dbus-launch when I look at the processes with top -upi. I wonder if this is your leftover daemon? |
Thanks all for the feedback and research. I can experiment with sending SIGINT instead of SIGTERM. One thing to note in my code is that in most cases subprocess receives EOS and is not actually killed via the monitor. I'll have to look at the logs...but not sure whether receiving 'have a nice day' indicates dbus-daemons were successfully shut down. I agree with @KenT2 that the dbus-daemon running might be present prior to omxplayer and not related... |
Hi @KenT2 and @andyjagoe What I see BEFORE starting omxplayer is
and AFTER omxplayer is started (and ended) is
So yes there is a dbus-daemon already running but that is the SYSTEM dbus-daemon (noticeable by --system). Omxplayer (or something) starts the dbus-launch, which starts the SESSION dbus-daemon (noticeable by --session). That is what I make of the D-Bus process so far. I'm running only from the command line (ssh) and not from X windows (GUI). Maybe there is a difference. I don't know. |
This is what I get before and after running omxplayer. SSH is enabled but not in use. I am using X and LXDE. uncluttter is running. pi@raspberrypi ~/pp_home/media $ ps xaf | grep -i dbus pi@raspberrypi ~/pp_home/media $ omxplayer xthresh.mp4 pi@raspberrypi ~/pp_home/media $ ps xaf | grep -i dbus pi@raspberrypi ~/pp_home/media $ |
@KenT2 Thanks for the output. |
The first ps WAS before running omxplayer for the first time. i.e. immediately after reboot |
And thanks. Sending a SIGINT to omxplayer script worked wonderfully. I have had three crashes of omxplayer in a run and no orphan dbus-daemons. :-) |
@KenT2, again thanks for the feedback...so I lost my bet... ;))))) Nice too see that I'm still hunting for the crashes, but I'm a little bit stuck on the OMX_ErrorInsufficientResources as mentioned in issue 124 and 12. |
I also ran So my conclusion (from what I understand untill now about D-Bus, and yes I have to read more ;) would be:
Anyone any comment on this? |
My opinion is that there should only be one D-Bus session bus created, that's discoverable at some well-known location instead of a mktemp'ed file. All omxplayer instances should share it. The MPRIS spec says "In the case where the media player allows multiple instances running simultaneously, each additional instance should request a unique bus name, adding a dot and a unique identifier to its usual bus name, such as one based on a UNIX process id." There is no need to fork a dbus-daemon, this is true, but if omxplayer can't get onto a session bus you won't be able to use keyboard controls. |
@blakee |
So the bus name for each MPRIS instance (omxplayer) should be unique. Seems reasonable, but when this name is made from the process id (just like mktemp seems to do) isn't it than for a client hard to find out which name belongs to which instance? |
We could have an instance id that gets passed as a command-line argument to omxplayer, and causes omxplayer to attempt to register org.mpris.mediaplayer2.omxplayer.{instance id} on dbus. If no instance id is specified, it will first attempt to register org.mpris.mediaplayer2.omxplayer, if that fails it will use org.mpris.mediaplayer2.omxplayer.instance{pid}. My reasoning is that when there is only one instance of omxplayer running at once (the common case, I believe) the user doesn't have to specify an instance id, and can still use any dbus client pointed at org.mpris.mediaplayer2.omxplayer. If you are trying to juggle multiple players at once, you probably have your own unique identifier you can use, so just pass that. |
@Aiexis |
@popcornmix it seems that dbus process is now correctly killed. Thank you ;) |
Good to hear. |
Everything is in the title ;)
$ ps xaf
22126 ? Ss 0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
22192 ? Ss 0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
etc...
In my case, omxplayer plays lots of file per day, and Pi hangs after one or two days, due to full memory use.
The text was updated successfully, but these errors were encountered: