Products › lamco-dbus-tools › Use cases

A desktop service slow to appear after login: D-Bus activation

A desktop service slow to appear after login: Find what a D-Bus activated service and its systemd unit spend the seconds on, with dbussee and dbustell.

A desktop's file previews take seconds to show the first time after login, then appear at once. lamco-dbus-tools found the cause with dbussee, which recorded the bus and read the journal, and dbustell, whose activation followed the systemd unit and quoted the service's own line.

A real run on 2026-12-02 on Debian 13 (a test VM) in its GNOME session, session bus dbus-daemon 1.16.2, with a development build of lamco-dbus-tools, version 0.1.0. run.sh ran it, previewer.py is the made-up service, not a real application, and the outputs are in the use case's directory as they were printed. The capture is kept, cut to what bears on the start, as tests/fixtures/activation/systemd-unit.json.

The symptom

A desktop's file previews take seconds to show the first time after login, then appear at once. The previews come from a session service, com.example.Previewer, which a package installs the usual way: A D-Bus service file that names a user unit for it, so that the service manager starts it when it's first called.

# ~/.local/share/dbus-1/services/com.example.Previewer.service
[D-BUS Service]
Name=com.example.Previewer
Exec=/bin/false
SystemdService=com-example-previewer.service

The unit isn't named after the bus name, as many desktop services' aren't: xdg-desktop-portal.service starts org.freedesktop.portal.Desktop.

The bus, before

$ dbussee check
Bus (session): dbus-daemon 1.16.2
    Read from the process behind the bus, and what its program prints for --version.
Names: 76 well-known, 83 connections, 80 names that can be started
Instrument: 243 questions, all to the bus itself and none able to start a service
Findings: 0 problems, 1 notices

Nothing is wrong with the bus. BUS-003, its one notice, is about the system bus, which isn't this one. dbussee names lists who owns each name; com.example.Previewer isn't there, because nothing runs it yet. It's among the 80 names that can be started.

The symptom, recorded

The service called twice while the whole bus was recorded:

$ dbussee --quiet record --all --duration 10 --out rec.json &
$ busctl --user call com.example.Previewer /preview com.example.Previewer Ping
$ busctl --user call com.example.Previewer /preview com.example.Previewer Ping
$ wait

Timed at the caller by the run's script, the first call took 2,624 ms and the second 7 ms.

$ dbustell activation rec.json
1 activations. Request to name taken is on the recorder's clock, ± 569.94 µs: The longest the bus took to answer a call to itself, which it answers at once. Request to started is to journald's receipt of the bus's or the service manager's line, on the same monotonic clock, and also holds however long journald took to receive it.

com.example.Previewer: started, requested by :1.178 with a call to com.example.Previewer.Ping
    started 19.73 µs before the recorder read the request, which it read late: the service manager ran its unit
    name taken 2.62 s after the request, ± 569.94 µs
    the service manager has a unit for it: com-example-previewer.service
    the service wrote: cache loaded

The bus asked the service manager to start the unit at once, and the service took its name 2.62 s later, at the bus. In between, its own line, "cache loaded": The service spent the time loading before it took its name, and every call waited for it. dbustell findings says the same as findings:

CALL-005 (notice): A call took a second or more
    1 calls took a second or more, the longest com.example.Previewer com.example.Previewer.Ping at 2.62 s.
ACT-002 (notice): A service took a second or more to start
    com.example.Previewer took its name 2.62 s after :1.178 asked for it, the start beginning 0 ns in, each figure ± 569.94 µs.

The recording also read the unit's state from the service manager, the host-units records: The unit the bus named, com-example-previewer.service, loaded and running, and the two units named after the bus name, which don't exist.

Without recording

The journal had it all along. dbussee journal shows the bus's and the service manager's lines, and what the services the bus started wrote:

$ dbussee journal --since 2m
    8.478 s ago  the bus                     [session uid=1000 pid=815 pidfd=5] Activating via systemd: service name='com.example.Previewer' unit='com-example-previewer.service' requested by ':1.178' (uid=1000 pid=6109 comm="busctl --user call com.example.Previewer /preview")
    8.475 s ago  the service manager         Starting com-example-previewer.service - Example previewer...
    5.867 s ago  a service the bus started   cache loaded
    5.862 s ago  the bus                     [session uid=1000 pid=815 pidfd=5] Successfully activated service 'com.example.Previewer'
    5.862 s ago  the service manager         Started com-example-previewer.service - Example previewer.

Without the messages there's no saying which call waited, but the start and its 2.6 s, in the journal's own stamps, are there.

Found on the way

The first run of this page showed the start, its time and nothing else: Not the unit, not the manager's lines, not "cache loaded". The recorder kept a journal line about a start only when it named the bus name or a dbus-broker launcher's unit, and asked the service manager only for dbus-NAME.service and NAME.service. A unit named by SystemdService= and called anything else was lost. Now the unit dbus-daemon names in its own line, unit='...', is followed: Its lines and the manager's about it are kept, its state is read, and activation names it. A test reads the kept capture and fails without the change.

The cause, and what to do

The service loads its cache before it takes its name. A service that takes its name first and loads after, answering what it can at once, appears to its callers in milliseconds; or the unit can be started with the session, so the wait happens before anyone asks.

The made-up service and its two files were removed at the end, and the run's last line says no process or unit of it was left.

Related