No Sound with graphics-accelerated GUI app (Chrome) in LXD containers

Greetings:

I originally encountered this issue when I was attempting to run Firefox inside of a LXD container (see link here):

No Sound with graphics-accelerated GUI apps in LXD containers

I followed Simos’ direction within that same thread and got Firefox working with sound.

Now, I have attempted to follow the same directions to create a Chrome LXD container using the x11 profile that works with the Firefox container but again, am faced with no sound. These are the errors that pop-up when I start chrome:

[12977:13018:0601/174916.430081:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[12977:13018:0601/174916.430121:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[12977:13035:0601/174916.546426:ERROR:object_proxy.cc(632)] Failed to call method: org.freedesktop.DBus.Properties.Get: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[12977:13035:0601/174916.546926:ERROR:object_proxy.cc(632)] Failed to call method: org.freedesktop.UPower.GetDisplayDevice: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[12977:13035:0601/174916.547496:ERROR:object_proxy.cc(632)] Failed to call method: org.freedesktop.UPower.EnumerateDevices: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[13014:13014:0601/174916.620977:ERROR:sandbox_linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.
[13014:13070:0601/174916.637707:ERROR:gbm_wrapper.cc(271)] Failed to export buffer to dma_buf: No such file or directory (2

And these are the errors that arise when I try to play a video with sound via youtube.com:

[12977:13018:0601/174930.057964:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[12977:13018:0601/174930.057991:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
Fontconfig error: Cannot load default config file: No such file: (null)
LaunchProcess: failed to execvp:
update-desktop-database
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
[13692:13692:0601/174945.138280:ERROR:alsa_util.cc(204)] PcmOpen: default,No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
[13692:13692:0601/174945.144631:ERROR:alsa_util.cc(204)] PcmOpen: plug:default,No such file or directory
[12977:13018:0601/174945.152698:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

This is my x11 profile:

config:
  environment.DISPLAY: :0
  environment.PULSE_SERVER: unix:/home/ubuntu/pulse-native
  nvidia.driver.capabilities: all
  user.user-data: |
    #cloud-config
    runcmd:
      - 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'
    packages:
      - x11-apps
      - mesa-utils
      - pulseaudio
description: GUI LXD profile
devices:
  PASocket1:
    bind: container
    connect: unix:/run/user/1000/pulse/native
    gid: "1000"
    listen: unix:/home/ubuntu/pulse-native
    mode: "0777"
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
    uid: "1000"
  X0:
    bind: container
    connect: unix:@/tmp/.X11-unix/X0
    listen: unix:@/tmp/.X11-unix/X0
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
  mygpu:
    type: gpu
name: x11
used_by:
- /1.0/instances/Firefox
- /1.0/instances/lxdchrome

Any help is greatly appreciated, thank you.

If you want to try an alternative, you can use pulseaudio networking:
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Network/

In this case you simply create a proxy device for the port.
Set up a config in pulseaudio to allow only connect over 127.0.0.1.
Then you add an environment variable to .profile and every application that you open inside the container will use the pulseaudio server of your host.

This is a weird message. I would focus on this one.
Check the value of $PULSE_SERVER.

:~$ $PULSE_SERVER

on the Host and in the Container did not produce any output

In the container run

export PULSE_SERVER="unix:/home/ubuntu/pulse-native"
pactl info

If this works, then the issue is with the container not setting up the variable PULSE_SERVER.

So that worked in so much as I launched Chrome from within the container and was able to hear sound. Here is a pastebin of the output from your advice, through launch, including youtube.com, followed with closing chrome via the “x” in the upper righthand corner.

pastebin

Thank you for all your help!

Well I decided to be cute and install Chrome in the existing Firefox container thinking “hey, if it works for firefox …” Well all that managed was to mess up the Firefox container and not it does not have sound. And, of course, since I don’t consider Firefox mission critical, I dont have a back-up :confused:

The error Firefox throws, now:

Setting PATH
Starting up Feral SSH tunnel
Starting Firefox
Sandbox: /tmp/.X11-unix/X0 is inaccessible (No such file or directory); can't isolate network namespace in content processes

(firefox:964): LIBDBUSMENU-GLIB-WARNING **: 19:20:23.738: Unable to get session bus: Failed to execute child process “dbus-launch” (No such file or directory)

As an aside, I have not made any progress. If anyone has any advice I would greatly appreciate it. Thank you.

I came to a solution though it is not stable (per Google).
The issue (as I understood it) was two fold:

  1. Chrome cannot run with sudo privileges*
  2. the lxc container cannot connect to the pulse without sudo privileges

The solution is to run Chrome with the “–no-sandbox” flag as a user with sudo privileges within the lxc container. However, this will cause problems with Chrome (and it says as much as it is running) with stability.

If anyone wants to investigate further I would love to see a work-around however I am marking this solved on my end as I am moving on. Thank you!

Ok, let’s go.

(I use the lxc ubuntu mycontainer alias to get a shell into the container. See the Summary at See https://blog.simos.info/using-command-aliases-in-lxd-to-exec-a-shell/ on how to set it up yourself as well.)

$ lxc launch ubuntu:18.04 guicontainer --profile default --profile x11
Creating guicontainer
Starting guicontainer
$ lxc file push /usr/share/sounds/ubuntu/stereo/dialog-information.ogg guicontainer/home/ubuntu/
$ lxc ubuntu guicontainer
ubuntu@guicontainer:~$ pactl info                             # Both at version 32. 
Server String: unix:/home/ubuntu/pulse-native
Library Protocol Version: 32
Server Protocol Version: 32
Is Local: yes
...
ubuntu@guicontainer:~$ paplay dialog-information.ogg       # works for me.
ubuntu@guicontainer:~$ sudo apt install -y firefox 
ubuntu@guicontainer:~$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
ubuntu@guicontainer:~$ sudo apt install -y ./google-chrome-stable_current_amd64.deb

Having done that,

  1. I am able to run Firefox and play videos from Youtube, with sound.
  2. I am able to run Chrome and play videos from Youtube, with sound.

In Chrome, I get the warning and errors that you showed earlier. But it still works. Here are the warnings as soon as I start Google Chrome.

$ google-chrome
Gtk-Message: 08:41:31.498: Failed to load module "canberra-gtk-module"
Gtk-Message: 08:41:31.499: Failed to load module "canberra-gtk-module"
[6825:6864:0615/084131.531852:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server add
ress: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[6825:6864:0615/084131.532032:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server add
ress: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[6825:6864:0615/084131.550370:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server add
ress: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[6825:6864:0615/084131.550394:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server add
ress: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[6825:6915:0615/084131.690306:ERROR:object_proxy.cc(632)] Failed to call method: org.freedesktop.DBus.Pro
perties.Get: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name or
g.freedesktop.UPower was not provided by any .service files
[6825:6915:0615/084131.690812:ERROR:object_proxy.cc(632)] Failed to call method: org.freedesktop.UPower.G
etDisplayDevice: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The nam
e org.freedesktop.UPower was not provided by any .service files
[6825:6915:0615/084131.691533:ERROR:object_proxy.cc(632)] Failed to call method: org.freedesktop.UPower.E
numerateDevices: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The nam
e org.freedesktop.UPower was not provided by any .service files

As soon as I play a video (that has audio), I get more of the following,

[6825:6864:0615/084303.620067:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server add
ress: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[6825:6864:0615/084303.620101:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server add
ress: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[6825:6864:0615/084303.620117:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server add
ress: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

It looks to me that Chrome runs in an unfamiliar setup and complains hard. But still it works.

Simos:

Thank you for the response and I was able to replicate your process and achieve the same results. The only thing I was doing differently was that I was unawares of the the need (option?) to push the dialog-information.ogg file.

The other “problem” is that while I know much more than I knew even a few weeks ago, I still don’t know enough to provide comprehensive explanations of my situations. It is quite possible there is something I am overlooking when evaluating my issues.

Irrespective, thank you!

EDIT: On a far less important level, I’ve noticed that when a gui app is installed its appearance is “gnome.” Is there a way to install a gui app and force it to use a plasma aesthetic?

This is just an interim test to verify that things are working.

There are several ways to get a shell into a LXD container. Depending on the way, your shell may or may not be able to receive the PULSE_SERVER variable. Therefore, if pactl info gives you an error, it may be due to the shell not getting the PULSE_SERVER variable.

This is related to theming. I have not looked into this. There should be a way for the container to use the theming from the host.