ValveSoftware / steam-for-linux

Issue tracking for the Steam for Linux beta client
4.27k stars 174 forks source link

Some games freeze on mouse/keyboard input when using libdbus-1.so.3 from the Steam Runtime, in the absence of a session dbus daemon #4444

Open major-gnuisance opened 8 years ago

major-gnuisance commented 8 years ago

OS: Debian GNU/Linux testing, amd64

Some games "freeze" temporarily upon receiving any mouse or keyboard input, but only if using the Steam Runtime.

The following games are affected:

Removing the Steam Runtime paths from LD_LIBRARY_PATH fixes the issue. More specifically, the problem is libdbus-1.so.3, located in steam-runtime/amd64/lib/x86_64-linux-gnu/ If I make affected games use the system's version of that library, the problem disappears. (libgpg-error.so.0 also needs to be replaced with the system's version, or else games will crash with the new libdbus.)

Below is a script to give precedence of those SO files over the Steam Runtime's. Use it as a wrapper in the Steam launch options of the games affected, e.g.: "my-rt-fix %command%"

#!/bin/bash

# Exit on errors
set -e

# Create temporary directory
tmpdir="$(mktemp --directory)"

# Cleanup function
function cleanup {
    if [ -d "$tmpdir" ]; then
        rm "$tmpdir"/*
        rmdir "$tmpdir"
    fi
}
# Execute cleanup on exit
trap cleanup EXIT

# Create symlinks to SO files in temporary directory
for file in libdbus-1.so.3 libgpg-error.so.0; do
    ln -s "/lib/x86_64-linux-gnu/$file" "$tmpdir"
done

# Add temporary directory to beginning of LD_LIBRARY_PATH, so that it has precedence over the Steam Runtime
export LD_LIBRARY_PATH="$tmpdir${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"

# Run program given in arguments
"$@"

# trap takes care of cleanup upon exit

A couple more notes:

I can record a video if necessary.

major-gnuisance commented 8 years ago

This problem has existed for a while, by the way. I think it has affected Shadow Warrior for as long as I've had it in my library, but it already had a "no steam runtime" launch option.

I think there were other games affected, but I can't remember which.

major-gnuisance commented 8 years ago

Another affected game:

Note: Shadow Warrior and Skullgirls already have a "No Steam Runtime" launch option.

major-gnuisance commented 8 years ago

Other affected games:

Braid only freezes after about half a second of holding down a key, and seems to ignore mouse input.

La-Mulana doesn't actually slow down, but seems to accumulate input over time in a way that makes it unplayable, e.g., I hold "right" for three seconds and movement continues for an additional second after release.

major-gnuisance commented 8 years ago

Turns out the trigger for this issue was the absence of a session dbus.

I forgot to mention that I was running Steam with a separate user with just access to the X and pulseaudio servers, gamepad devices and the video and bumblebee system groups. This meant that Steam (and its children) didn't have a session dbus they could connect to, which triggered this problem.

I managed to fix it while still maintaining the semi-isolation of Steam by starting a session dbus daemon for the steam user. A naive solution:

# warning: this launches a new dbus daemon with every invocation
export DBUS_SESSION_BUS_ADDRESS="$(dbus-daemon --session --print-address --fork)"
steam

I'm not sure if it's reasonable to require a session dbus to run Steam games, so I'll leave the issue open for now.

joaormatos commented 8 years ago

The solution above spawns a dbus daemon each time it's run.
If you don't want to leave lingering daemon processes, use the following instead:

dbus-run-session steam

gvlasov commented 8 years ago

Painkiller: Hell & Damnation is affected by this as well

joaormatos commented 8 years ago

As I pointed out in the Dota2 issue thread, you should be able to work around this problem without running any dbus daemon at all.

Just set DBUS_SESSION_BUS_ADDRESS to some random gibberish, such as "foo"

cybik commented 7 years ago

I can confirm that both gibberish-ing DBUS_SESSION_BUS_ADDRESS and using dbus-run-session steam fix the slowdown with Skullgirls.

thigger commented 7 years ago

Steam in-home streaming is affected by this (hence I saw it on all games!) In ubuntu 16.04 there is a "dbus-user-session" package which I think is what fixed it for me.

taxilly commented 7 years ago

Using dbus-run-session steam also fixes mouse lag on Reassembly

Antidemons commented 7 years ago

script from major-gnuisance is great. Thanks. Shadow Warrior now run excellent.