Skip to main content
Topic: What is the point in dbus? (Read 4129 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

What is the point in dbus?

I have been dealing recently with attempting to set up a media control keybind which can pause whatever media is currently playing in whatever program (mpv, browser, etc.) and I discovered the "mpris" protocol not so long after. It seemed simple enough; players register and then can be controlled over dbus. However, this was not as simple as it seemed. Because DBus requires a session bus to be launched in the context of a user, I had to launch the dbus process. Easy task? No! Initially, I added the dbus-launcher to my .xinitrc like many other startup commands, like starting nm-applet and mpd. Did it work? Of course not, nothing can be that simple. DBus's libraries require that you export certain environment variables (which are filled to the brim with XML garbage put there by some soydev) or it will abort applications which attempt to use DBus. Why? So that the location of the DBus session bus can be relocated. Why would it need to be relocated? I have no idea. We are just expected to accept that this is the case. So, I added the required variables, but it still didn't work, because of some unfathemable reason which I still don't understand. In the end, I had to replace my nice clean

Code: [Select]
exec dwm

call with the indescribably awful:

Code: [Select]
exec dbus-launch --exit-with-x11 --no-daemon dwm

Even with this, DBus woult still randomly exit at times, leaving me to deal with a torrent of "org.freedesktop.DBusNoReplyError"s in my terminals. In the end, I ended up writing a script that would respawn dbus automatically when it crashed (not if - when it crashed). I don't know if this is just on my end, but DBus has been really awful for me this whole time, and yet it is only needed for one single application - perhaps two at the most.

All so that I could press Mod+P and have my media pause. I will spare you the story of the rest of the time spent debugging Chromium not picking up the session bus and environment variables getting reset for some daemons so as to spare you from damnation to a depressed state, but I hope that you get the picture that DBus caused me a large amount of pain.

And so, this made me think about DBus iteslf. Why does it need to exist? We already have domain sockets, named pipes, FIFOs, temporary files and network connections, so why do we need yet another IPC system? The Arch Wiki claims that DBus "provides an easy way for inter-process communication. It consists of a daemon, which can be run both system-wide and for each user session, and a set of libraries to allow applications to use D-Bus". This seems to suggest that DBus is just a JQuery-style "ease-of-use" band-aid that was added to the UNIX space to make the jobs of the FreeDesktop developers slightly easier.

I've written quite a bit of software for UNIX-like stuff in my time and I have never come across a need for IPC which is not fullfilled by the standard UNIX IPC tools. To add insult to injury, you literally communicate with DBus through a UNIX domain socket which is placed in your run directory. Surely, this is just re-inventing the wheel, right?

DBus, at least to me, seems to be a ploy created by the FreeDesktop people to put even more Windows-ish garbage into the UNIX space. We don't need DBus. DBus is bloated and randomly spikes to 100% CPU usage on my laptop. When I kill it, the browser, with all my tabs, instantly crashes. All of this could have easily been replaced with nice, file-based IPC endpoints which software interfaces with in a natural fashion. Adding several layers of "brokers", daemons and worker processes just to handle IPC is not the UNIX way. I should not be able to completely ruin my system by killing any process other than init and (maybe) elogind. What if DBus crashes? Well, good luck getting your system back, because elogind communicates with clients through this. Seriously, try running:

Code: [Select]
sudo killall dbus-daemon

at a TTY and watch your screen freeze up. This is ridiculous. Because one process exits, the entire system is barely usable. Thank goodness for the SysRq key.

DBus and the FreeDesktop suite of software encourage this awful centralised model of a system where literally everything has to be channeled through or included in this one package (remind you of a certain init system?). This is shown off perfectly in this Reddit post. The user wishes to remove DBus, but is unable to open .desktop files without it. From my experience, .desktop files are just INI files which are placed in an XDG directory to give rich application launching facilities. Why does it need DBus to parse? At most, you might need a library (maybe call it "libdesktop" or "liblaunch"). Instead, we have to communicate over a socket which further communicates through a daemon over yet another socket to parse an INI file and launch a program. This should be maybe just over 20 lines of C (even less Go). Instead, there are likely thousands of lines of code involved. And all for "easy inter-process communication"

Let's take "mpris" for one moment and re-design it to use UNIX domain sockets. For each player which wishes to register, you create a socket in a specific directory (maybe XDG_CACHE_HOME or something). Each of these sockets can then be used to interface with the players at hand. Commands can be taken and responses given in plain text and without any XML nonsense. Just using the standard UNIX "open" and "close" syscalls is so much simpler than understanding all of this crap. The documentation literally compares DBus to a "message-based" network socket. So why can't we just use network sockets? This is not simple - it is over-complicated, messy, difficult to use and most of all it just sucks.

So why, then, you may ask are we still using DBus? Well, the aforementioned Reddit thread sums up the attitude towards it perfectly with the following quote: "Yes, DBus sucks. But, the fact the DBus sucks and that it uses a negligeble amount of resources for the average user are not mutually exclusive". In other words, DBus has the same chronic illness as Windows where the rot goes very deep but not deep enough to annoy apparently anybody other than me and two other people on earth. Most people would rather have their stupid XML endpoints and dbus-brokers taking up megabytes of RAM. DBus sucks, but not for the user. The suckiness is only really exposed once you try to write software or scripts for it.

At least in a single-user environment, I see absolutely no reason why DBus should even exist. Of course, I am perfectly willing to be enlightened if somebody disagrees. Thank you for attending my Ted Talk.

If you or someone you know has been affected by DBus or its allies at the FreeDesktop foundation, help is available in this summarising thread

Re: What is the point in dbus?

Reply #1
Yeah thanks
Code: [Select]
sudo killall dbus-daemon
Tried that and my cat died!

But I agree. Though I don't understand it on the level that you do I agree.

I swear Cups used to work just fine without dbus but now dbus is a requirement. I think just to notify me something's printing. Yet I can hear the printer so that would do for me.

I've a slight distrust in 'Freedesktop'. In my head, knowingly incorrectly, I see the Freedesktop project as intertwined with systemd.
Probably irrationally I can imagine it as a form of gatekeeping (down with the kids, I've learnt this concept from reddit recently). Make everything overly complex so the average user has no clue any more what is going on behind the scenes.

Enjoyed the rant and I hope getting that off your chest has alleviated your suffering a little  :)

Re: What is the point in dbus?

Reply #2
D-Bus is unfortunately infuriatingly omnipresent for such things, thanks to Freedesktop.org dictating many Linux standards and having a surprising amount of corporate involvement for a "desktop Linux" project. Hell, if your system D-Bus instance dies, Bluetooth will go with it, for no reason other than "it's common".

To add to your MPRIS example, notifications are also a thing that depends on D-Bus which could even be a humble FIFO if one-way, or a socket for fancier two-way communications, yet we need™ a program sitting between the notification sender and the receiver. Unlike MPRIS, there's only one notification daemon at a time, so even arguing that D-Bus could be a tool for dynamic discovery isn't valid here.



For more mildly infuriating aspects of using D-Bus, the two major implementations of a message broker (the process that breaks media keys or Bluetooth/elogind if it dies) — dbus-daemon, the original and more portable one (working on any POSIX OS) and dbus-broker — all have dependencies on systemd stemming from questionable design decisions.

The first requires systemd for process supervision since fork+exec is apparently too hard, infuriating any person who runs alternative process supervisors like runit or s6. This has bitten me and other Artix users.

The latter initially seems saner due to focusing exclusively on message passing, has quite a few gotchas:
  • It requires a controller process instead of a configuration file. Not only the controller needs to send D-Bus messages to the D-Bus message passer through a socketpair, but the format of the messages needing to be sent between them is not fully documented.
  • Verbose logging requires systemd-journald (I wish I was making this part up).
  • The example controller, used with Fedora, which could offset the lack of documentation, hard-depends on systemd the daemon, and uses libsystemd even for basic things such as event loops.
  • TL;DR using it with anything other than systemd stack is, seemingly by design, an uphill battle.

Quote
I've a slight distrust in 'Freedesktop'. In my head, knowingly incorrectly, I see the Freedesktop project as intertwined with systemd.

You aren't wrong. Systemd used to be under the freedesktop umbrella not long ago (a lot of systemd docos are still hosted on Freedesktop.org, and the source code of the last version of systemd before the migration to GitHub is still there). And all their major software (including PA, PipeWire, etc.) includes special systemd support for things like socket-activation using, you guessed it, libsystemd.

Re: What is the point in dbus?

Reply #3
. To add insult to injury, you literally communicate with DBus through a UNIX domain socket which is placed in your run directory. Surely, this is just re-inventing the wheel, right?


If you can't appreciate reinventing the wheel is the best since sliced bread, uhm and systemd, and polkit, you are just an irrational hater of progress.   ;)
Be thankful kdbus didn't make it.

Re: What is the point in dbus?

Reply #4
Just an FYI, with mpv you can just use the input-ipc-server option (creates a unix socket) and then send the running mpv instance commands via ipc. For example, to play/pause mpv, you can just do:
Code: [Select]
echo '{ "command": ["cycle", "pause"] }' | socat - /path/to/socket
I bind a command like that to my play/pause media key.

Re: What is the point in dbus?

Reply #5
dbus, originally designed as a "Message Bus" is necessary for the system, especially a Desktop system. Whether or not it's developed to meet the original goal, it's another story. The same thing even goes to the "evil" systemd, which was a good idea at beginning to replace the old SysV/BSD init system, but it has gone too far since.

Re: What is the point in dbus?

Reply #6
Slightly related I was just using htop to look at firefox memory usage and noticed /usr/lib/packagekitd was using more memory (RES) than any other process on my system. Just shy of 600Mb. Why I don't know ?

I guess I must have explicitly installed Discover (KDE package installer / updater) at some point ? As that's what pacman -Qi was telling me, but I didn't even really use it. At least not more than a visual indication that updates were available which I would then do via the command line.

So that's all removed now, Discover & Packagekit.

I think I might spend some of the holiday period experimenting with how close I can get to working system, from a base install, with no elogind (+lib) and no dbus.
I accept that I will lose fuctionality but I'm curious how much. That's if I can even get KDE working at all ?

Just an experiment and me thinking out loud.

Re: What is the point in dbus?

Reply #7
If Artix has a mission that is exemplified by purging systemd from the distribution, then perhaps DBus should equally well be purged?
For one who's been around, the provenance of things like gnome, systemd, dbus, free-desktop, pulse-audio... and the connections between them and corporate funding reveals very clearly that these are *not* good for us, the users of free/libre software.

I feel certain that, somewhere in there, there is an agenda to do this to the free software world as a means of gaining control over it.
This ridiculous, stupid complexifying of things that goes directly against solid software development ethics -- given the connections noted above -- is surely no accident.  It's far too systematic within certain connected, related currents to be simple incompetence... and it's getting (much) worse.  Imagine what a  backdoored libsystemd could do... down the road a bit.  But we're safe right now, right?  So why worry about it?

A first step in addressing this problem is to recognize it.  But of course, the money and the power (and their compliant functionaries) will gaslight you about all this.

Did i transgress getting into political topics?  But even "free" software is (extremely) political... if one looks at the bigger picture.

P.S. And at the very least, they waste an awful lot of our time and attention dealing with simple bad engineering.

Re: What is the point in dbus?

Reply #8
All commercial engineering, not just software, has intentional badness to make it more difficult for anyone to do what they want with the product. (I just went through the process of changing the battery on my Samsung phone instead of buying a new phone. Decided to get a Fairphone next.) As for dbus, just the way they tried, first to slip, then to shove it into the kernel a few years back demonstrates some big agenda.

I would gladly be rid of dbus. But this rabbit hole goes deep. To jump close to the bottom, glibc is bloated, has bad engineering in it. If you really want a well-designed system, go for Plan-9. But then nothing works!  ;)
http://harmful.cat-v.org/software/

And obviously not enough people care/know about software quality/simplicity/whatever. They use Java code to run the Mars rover! That is the furthest reach of mankind.

Re: What is the point in dbus?

Reply #9
Well, Systemd, DBus and glibc are the obvious targets. What about the Linux kernel itself?  We're in a wild wild west world in terms of Linux kernel development now. I was joking with others early this year that the 5.10 branch's minor release number could reach 100 before the new year. It's at 88, not far away from my prediction.  :)

Re: What is the point in dbus?

Reply #10
And obviously not enough people care/know about software quality/simplicity/whatever. They use Java code to run the Mars rover! That is the furthest reach of mankind.

Don't panic; NASA's got our backs:

http://pixelscommander.com/wp-content/uploads/2014/12/P10.pdf

Highlights:
  • Use plain C99
  • No messing around with complicated control flow (longjmp, goto, etc.)
  • No allocating loads of dynamic memory

The Mars Rover might be running Java, but the ISS is probably running C.

Re: What is the point in dbus?

Reply #11
Well, Systemd, DBus and glibc are the obvious targets. What about the Linux kernel itself?  We're in a wild wild west world in terms of Linux kernel development now. I was joking with others early this year that the 5.10 branch's minor release number could reach 100 before the new year. It's at 88, not far away from my prediction.  :)

Regarding the Linux kernel, Hyperbola -- Arch-based, fully free,  LTS, adheres to GNU FSDG -- published their HyperbolaBSD Roadmap, 21 Dec 2019, where they wrote:

Quote
Due to the Linux kernel rapidly proceeding down an unstable path, we are
planning on implementing a completely new OS derived from several BSD
implementations.  This was not an easy decision to make, but we wish to
use our time and resources to create a viable alternative to the current
operating system trends which are actively seeking to undermine user
choice and freedom.  This will not be a "distro", but a hard fork of the
OpenBSD kernel and userspace including new code written under GPLv3 and
LGPLv3 to replace GPL-incompatible parts and non-free ones.

Reasons for this include:

   Linux kernel forcing adaption of DRM, including HDCP.

   Linux kernel proposed usage of Rust (which contains freedom flaws
   and a centralized code repository that is more prone to cyber
   attack and generally requires internet access to use.)

   Linux kernel being written without security and in mind.  (KSPP is
   basically a dead project and Grsec is no longer free software)

   Many GNU userspace and core utils are all forcing adaption of
   features without build time options to disable them.
   E.g. (PulseAudio / SystemD / Rust / Java as forced dependencies)

I was investigating Hyperbola as a potential distribution but, unfortunately, a BSD-based release isn't yet available and i doubt very much anything will be available any time next year that will be stable enough to meet my needs as more of a user than a developer/tester.  But i love the idea and the effort and look forward to seeing what results from it.

Re: What is the point in dbus?

Reply #12
Regarding the Linux kernel, Hyperbola -- Arch-based, fully free,  LTS, adheres to GNU FSDG -- published their HyperbolaBSD Roadmap, 21 Dec 2019, where they wrote:

I was investigating Hyperbola as a potential distribution but, unfortunately, a BSD-based release isn't yet available and i doubt very much anything will be available any time next year that will be stable enough to meet my needs as more of a user than a developer/tester.  But i love the idea and the effort and look forward to seeing what results from it.


Thanks for the info. Looking forward to Hyperbola's BSD-based releases.

 

Re: What is the point in dbus?

Reply #13
After reading this thread I am so happy that I'm not the only one that thinks things are really sucking now. systemd, dbus, even the kernel now. And idiots in the Kernel Code of Conduct Be Nice to Others group. The fact that the artix crowd understands this bring me joy.

Can't use the word blacklist/whitelist. No more F word in kernel dev posts.

And screw opendesktop. I'd seen some stuff about them that leads me to believe they love snooping on people.

Hell it's all so political now. And big player's money has ruined it all. lol - MicroLinux.

Down with meritocracy. Up with BS.

I'm sold. I'm installing artix in a partition alongside my beloved slackware.
I just want to be left alone.