Pulse Audio exits shortly after logging in

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Redsandro
Level 4
Level 4
Posts: 201
Joined: Sun Jul 17, 2011 6:40 pm
Contact:

Pulse Audio exits shortly after logging in

Post by Redsandro »

Since Mint 20 (and also after upgrading to Mint 21), pulse audio and the little speaker audio volume indicator at the right of the default panel disappears about 6 - 8 seconds after logging in. This means I can't use audio until I run: systemctl --user restart pulseaudio. However, if the browser is opened before that time, it will not have audio (e.g. youtube) until the browser is closed and reopened.

So I need to set up an autostart for systemctl --user restart pulseaudio, not too early or it will already be active, but after it is closed, so at about 10 seconds. But before I start any audio-related app such as the browser. Basically it means my boot+login time until the computer is ready is extended with 10 seconds.

Where can I find out why pulse is killed after logging in? I don't notice anything relevant in syslog around this time.
Last edited by LockBot on Tue Feb 14, 2023 11:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
🤘 Amp.lol. No bloat, just radio.
Ninite-killer. 1000+ packages.
akred3
Level 2
Level 2
Posts: 55
Joined: Sun Sep 13, 2015 12:22 pm

Re: Pulse Audio exits shortly after logging in

Post by akred3 »

Hello,
Just for information, I have also the same exact issue on LM 21 (fresh install)
Interested to see how to troubleshoot this ;)
Redsandro
Level 4
Level 4
Posts: 201
Joined: Sun Jul 17, 2011 6:40 pm
Contact:

Re: Pulse Audio exits shortly after logging in

Post by Redsandro »

Thank you for confirming you have the same problem on a fresh installation. I haven't figured out the root cause yet, but at least I won't have to do a fresh installation first to see if the problem is caused by old residual configurations.

By the way, do you have any non-default filesystems or encryption mechanisms? I use fscrypt, a non-default home encryption scheme. I was wondering if my home directory is locked a few milliseconds too long when pulse is trying to read from my home directory.
🤘 Amp.lol. No bloat, just radio.
Ninite-killer. 1000+ packages.
akred3
Level 2
Level 2
Posts: 55
Joined: Sun Sep 13, 2015 12:22 pm

Re: Pulse Audio exits shortly after logging in

Post by akred3 »

Very good question
Yes, my partition is encrypted, I have select the option during the installation process (I think it's to encrypt the /home right ?)
I don't know which type of encryption it is, do you know how I can check that ?


Other than that, what I noticed is that the sound icon is not display on task bar when the issue happens
Then, I went to Sound settings, and no device are in the list, kind of weird, because it supposed to display the default audio controller and my headset (if it's plugged)
To see them, I had to use your command (and then, the sound and devices appear)
luc2
Level 1
Level 1
Posts: 2
Joined: Sat Jan 13, 2018 7:49 am

Re: Pulse Audio exits shortly after logging in

Post by luc2 »

Start pulseaudio manually

Code: Select all

$ pulseaudio --start
$ echo "Hey! The sound works now!"
pulseaudio startup workaround

Code: Select all

$ sudo vim /usr/lib/systemd/user/pulseaudio.service
In the Service section, add:

Code: Select all

RestartSec=2s
For example:

Code: Select all

...
[Service]
ExecStart=/usr/bin/pulseaudio --daemonize=no --log-target=journal
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
Restart=on-failure
RestartSec=2s
RestrictNamespaces=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
# Note that notify will only work if --daemonize=no
Type=notify
UMask=0077
Slice=session.slice
...
Restart your computer. It should work but it will break again when the package is updated because the file will be overwritten.

Understanding the issue

If I understand correctly, pulseaudio fails to start because it's trying to access your encrypted homedir while it's not mounted yet:

Code: Select all

$ grep pulseaudio /var/log/syslog
...
Nov 22 13:10:52 plouc-2020-mint pulseaudio[2930]: Failed to create secure directory (/home/luc2/.config/pulse): Aucun fichier ou dossier de ce type
...
(french logs, sorry)

The workaround makes pulseaudio wait 2 seconds between each attempt to start, to allow time for the encrypted homedir to be mounted.

References
Redsandro
Level 4
Level 4
Posts: 201
Joined: Sun Jul 17, 2011 6:40 pm
Contact:

Re: Pulse Audio exits shortly after logging in

Post by Redsandro »

Hi @luc2 good find! Thank you for this. Looks like I was on the right track, but never found the issues you are referring to.
luc2 wrote: Tue Nov 22, 2022 8:44 am It should work but it will break again when the package is updated because the file will be overwritten.
In extension of the solution you brought to light, knowing systemd, I am pretty sure you can do this so the patch will survive updates:

Create new file /usr/lib/systemd/user/pulseaudio.service.d/10-restartsec.conf

Code: Select all

[Service]
RestartSec=2s
(yes only those two lines.)

I haven't been able to test this yet, but I am certain enough that configuration files in .d are merged with the main configuration, I thought I'd share this with you.
🤘 Amp.lol. No bloat, just radio.
Ninite-killer. 1000+ packages.
Locked

Return to “Software & Applications”