Skip to content
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

Sound sub-system is not ownering XDG_RUNTIME_DIR when xpra is started from the system proxy server. #1614

Closed
totaam opened this issue Aug 5, 2017 · 29 comments
Labels

Comments

@totaam
Copy link
Collaborator

totaam commented Aug 5, 2017

Issue migrated from trac ticket # 1614

component: sound | priority: major | resolution: fixed

2017-08-05 19:32:19: kundanvp created the issue


Sound sub-system is not ownering the XDG_RUNTIME_DIR when it is getting created through systemd.

xpra Command.

XDG_RUNTIME_DIR=/tmp/10 xpra start :10 --bind-tcp=192.168.0.20:10000 --start="xterm" -d sound

Due to it, multiple xpra server's with different display no's can't be created with their own pulseaudio servers on Ubuntu 16.04.

I was also, not able to see PULSEAUDIO_SERVER in xprop -root. So, I don't know how the xpra instances and pulseaudio servers are connected.

A current workaround to my problem is:-

systemctl stop xpra

After this, things work as earlier.

@totaam
Copy link
Collaborator Author

totaam commented Aug 5, 2017

2017-08-05 19:34:25: kundanvp uploaded file xprop_systemctl.txt (8.6 KiB)

xprop -root output from the started xterm after successful attach.

@totaam
Copy link
Collaborator Author

totaam commented Aug 5, 2017

2017-08-05 19:35:47: kundanvp uploaded file pactl_systemctl.txt (0.4 KiB)

pactl info output from the xterm after attach.

@totaam
Copy link
Collaborator Author

totaam commented Aug 5, 2017

2017-08-05 19:37:20: kundanvp uploaded file xpra_server_systemctl.log (3.0 KiB)

xpra server output log when created through systemctl.

@totaam
Copy link
Collaborator Author

totaam commented Aug 5, 2017

2017-08-05 19:41:17: antoine changed owner from antoine to kundanvp

@totaam
Copy link
Collaborator Author

totaam commented Aug 5, 2017

2017-08-05 19:41:17: antoine commented


Try using start-env instead:

xpra start :10 --bind-tcp=192.168.0.20:10000 --start="xterm" -d sound --start-env=XDG_RUNTIME_DIR=/tmp/10

@totaam
Copy link
Collaborator Author

totaam commented Aug 6, 2017

2017-08-06 05:11:10: kundanvp changed owner from kundanvp to antoine

@totaam
Copy link
Collaborator Author

totaam commented Aug 6, 2017

2017-08-06 05:11:10: kundanvp commented


Hi Antoine,

I tried the suggested option.
After this, the xterm started and attached in the client shows the right pulseaudio server string with pactl info. The pavucontrol started from the xterm also shows the devices correctly.

But, neither microphone forwarding nor speaker forwarding works.

The reason seems to be the failures reported in the xpra log, where neither pactl info nor pactl list is reporting the expected values. Both are refusing the connection.

I am also able to see some other issues in the log like,
IndexError: list index out of range

I don't know, whether they are related.

@totaam
Copy link
Collaborator Author

totaam commented Aug 6, 2017

2017-08-06 05:13:35: kundanvp uploaded file xpra_systemd_sound.log (7.2 KiB)

xpra sound failure when systemd is enabled and XDG_RUNTIME_DIR environment variable is used.

@totaam
Copy link
Collaborator Author

totaam commented Aug 6, 2017

2017-08-06 05:14:47: kundanvp uploaded file pactl_systemd_new.txt (0.4 KiB)

pactl info output from the xterm after attach reporting the correct values.

@totaam
Copy link
Collaborator Author

totaam commented Aug 6, 2017

2017-08-06 11:26:15: antoine changed owner from antoine to kundanvp

@totaam
Copy link
Collaborator Author

totaam commented Aug 6, 2017

2017-08-06 11:26:15: antoine commented


Please try with r16643 or later and --env= instead of --start-env=, as this will affect all the subprocesses, including pactl. (start-env is meant to be used for start and start-child options).

The IndexError is unrelated and was already fixed in r16610.

@totaam
Copy link
Collaborator Author

totaam commented Aug 7, 2017

2017-08-07 18:08:22: kundanvp commented


Hi Antoine,

I tried with this option as well. The command used was:-

xpra start :10 --bind-tcp=192.168.0.20:10000 --start="xterm" --env="XDG_RUNTIME_DIR=/tmp/10" -d server

But, no luck. xpra failed to create pulseaudio server because, it tried to create with the same pulseaudio string i.e /run/user//pulse/native. When I tried on a clean system, with no pulseaudio already running. It doesn't owner the environment variable passed. It simply creates the pulseaudio with default XDG_RUNTIME_DIR. I tried to remove quotes around XDG_RUNTIME_DIR=/tmp/10. But, still couldn't get success.

With, --start-env , at least it used to pick-up the XDG_RUNTIME_DIR. But, failed to start speaker or microphone forwarding. One more issue, which I noted, is that, when pulseaudio is created this way. When we stop the xpra server through xpra stop :10. It doesn't kill the started pulseaudio server automatically.

I tried to add some debug statement to search for the issue. But couldn't make progress. I am attaching the debug statements added and the logs.

@totaam
Copy link
Collaborator Author

totaam commented Aug 7, 2017

2017-08-07 18:09:47: kundanvp uploaded file debug.diff (0.8 KiB)

debug diff used.

@totaam
Copy link
Collaborator Author

totaam commented Aug 7, 2017

2017-08-07 18:10:57: kundanvp uploaded file pactl_info_new.txt (0.5 KiB)

pactl info after using --env.

@totaam
Copy link
Collaborator Author

totaam commented Aug 7, 2017

2017-08-07 18:11:58: kundanvp uploaded file xpra_journal_log.txt (10.5 KiB)

log in journalctl -u xpra, The last sections would be more meaningful.

@totaam
Copy link
Collaborator Author

totaam commented Aug 7, 2017

2017-08-07 18:12:08: antoine commented


@kundan: please make sure that you test using r16643 or later.

@totaam
Copy link
Collaborator Author

totaam commented Aug 7, 2017

2017-08-07 18:14:20: kundanvp uploaded file xpra_output_log.txt (4.3 KiB)

xpra output of the command used, mentioning pulseaudio daemon already running means pulseaudio won't start because XDG_RUNTIME_DIR variable is same as older.

@totaam
Copy link
Collaborator Author

totaam commented Aug 7, 2017

2017-08-07 18:19:29: kundanvp commented


Hi Antoine,

My xpra version is xpra v2.2-r16643. It seems, it has the changes. I also, verified the server.py file in /usr/lib/python2.7/dist-packages/xpra/scripts directory. It do possess the changes. But, I fail to understand, why it's not working.

@totaam
Copy link
Collaborator Author

totaam commented Aug 7, 2017

2017-08-07 18:20:59: antoine commented


Thanks for the logs. It looks like the pam config file needs tweaking for Debian / Ubuntu:

PAM _pam_load_conf_file: unable to open /etc/pam.d/system-auth
PAM _pam_load_conf_file: unable to open /etc/pam.d/postlogin

This may prevent #1105 from working as expected, but may actually help here if it causes pam auth to fail!

The XDG_RUNTIME_DIR may actually get updated by the pam authentication.
Please try to sprinkle some print statements in xpra/scripts/server.py to see where it gets overriden, maybe it is provided by pam in protected_env.

@totaam
Copy link
Collaborator Author

totaam commented Aug 8, 2017

2017-08-08 14:17:09: antoine commented


With the latest r16660 beta builds on Ubuntu 16.04, I have verified that XDG_RUNTIME_DIR is correctly set in the xpra server process and the same value is also used when calling pactl.
Pulseaudio starts without errors as long as I use a different env value for XDG_RUNTIME_DIR.
If you are still having problems, please apply this patch and post the server log:

--- xpra/sound/pulseaudio/pulseaudio_pactl_util.py	(revision 16610)
+++ xpra/sound/pulseaudio/pulseaudio_pactl_util.py	(working copy)
@@ -38,7 +38,8 @@
     env["LC_ALL"] = "C"
     try:
         import subprocess
-        log("running %s", cmd)
+        log.info("running %s with env=%s", cmd, env)
+        log.info("XDG_RUNTIME_DIR=%s", env.get("XDG_RUNTIME_DIR"))
         process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, close_fds=True)
         from xpra.child_reaper import getChildReaper
         procinfo = getChildReaper().add_process(process, "pactl", cmd, True, True)

@totaam
Copy link
Collaborator Author

totaam commented Aug 8, 2017

2017-08-08 17:57:58: kundanvp commented


Hi Antoine,

But, I am still seeing the issue.
It seems your earlier suspicion was right. The OS envrionment variables are getting overwritten, after we have set it to our desired value.

I have created a short diff, where I am disabling the overwrite of os environment variables by protected_env in about 4 instances. And, after that, magically things start to work.

In both the cases i.e with overwrite and without overwrite, I have captured the logs with your provided debug statements. And, i.e also, proving the theory.

The xpra command used.

xpra start :10 --bind-tcp=192.168.0.20:10000 --start="xterm" --env=XDG_RUNTIME_DIR=/tmp/10 -d server

@totaam
Copy link
Collaborator Author

totaam commented Aug 8, 2017

2017-08-08 17:59:40: kundanvp uploaded file stop_override.diff (1.7 KiB)

Stopping the override of os environment variables by protected_env.

@totaam
Copy link
Collaborator Author

totaam commented Aug 8, 2017

2017-08-08 18:02:03: kundanvp uploaded file xpra_log_with_debug_with_overwrite.log (6.3 KiB)

xpra log without applying my diff of stopping overwrite.

@totaam
Copy link
Collaborator Author

totaam commented Aug 8, 2017

2017-08-08 18:03:25: kundanvp uploaded file xpra_log_debug_without_overwrite.log (6.3 KiB)

xpra log after applying my diff of stop overwrite.

@totaam
Copy link
Collaborator Author

totaam commented Aug 8, 2017

2017-08-08 18:04:34: antoine commented


Does r16669 fix things?

@totaam
Copy link
Collaborator Author

totaam commented Aug 8, 2017

2017-08-08 18:40:50: kundanvp commented


Hi Antoine,

Yes, I tested the changes by modifying my installed xpra directly, and it is working properly. I will also test the changes in the beta version when it would be available tomorrow.

Thanks again, for the help and support.

@totaam
Copy link
Collaborator Author

totaam commented Aug 9, 2017

2017-08-09 16:24:53: kundanvp commented


Hi Antoine,

I tested with the beta version (xpra version v2.2-r16672) as well.
Things are working properly.

Thank you.

@totaam
Copy link
Collaborator Author

totaam commented Aug 9, 2017

2017-08-09 16:55:31: antoine changed status from new to closed

@totaam
Copy link
Collaborator Author

totaam commented Aug 9, 2017

2017-08-09 16:55:31: antoine set resolution to fixed

@totaam totaam closed this as completed Aug 9, 2017
@totaam totaam added the audio label Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant