theNizo / linux_rocksmith

Guides to get Rocksmith 2014 running on Linux
https://thenizo.github.io/linux_rocksmith/
GNU General Public License v3.0
111 stars 10 forks source link

Startup script & debugging improvements for Steam Deck low latency setup #27

Closed Siarkowy closed 1 year ago

Siarkowy commented 1 year ago

Hi, thanks for a great guide & kudos to all contributors too!

I've been trying to run a low latency Rocksmith setup on Steam Deck using my audio interface. However, I run into problems when running the game. Basically, it was only possible to run one of the following scenarios exclusively:

(Feel free to skip to the summary at the bottom for a solution if you are not interested in debugging.)


Setup

Relevant bits from RS_ASIO.ini

[Asio]
BufferSizeMode=custom
CustomBufferSize=256

[Asio.Output]
Driver=WineASIO

[Asio.Input.0]
Driver=WineASIO

Relevant bits from Rocksmith.ini

[Audio]
LatencyBuffer=4
ExclusiveMode=1
Win32UltraLowLatencyMode=1

Debugging wineasio errors

Running Rocksmith from Steam, the following error was produced in RS_ASIO-log.txt.

0.348 [INFO]  RSAggregatorDeviceEnum::UpdateAvailableDevices
0.348 [INFO]  AsioHelpers::FindDrivers
0.357 [INFO]    WineASIO
0.357 [INFO]  RSAsioDeviceEnum::UpdateAvailableDevices - output requesting ASIO driver: WineASIO
0.357 [INFO]  Creating AsioSharedHost - dll: wineasio.dll
6.392 [ERROR]  ASIO Error: WineASIO does not return error messages

6.392 [INFO]  Destroying AsioSharedHost - dll: wineasio.dll
6.393 [ERROR]  RSAsioDeviceEnum::UpdateAvailableDevices - failed.
6.393 [INFO]  RSAsioDeviceEnum::UpdateAvailableDevices - input[0] requesting ASIO driver: WineASIO
6.393 [INFO]  Creating AsioSharedHost - dll: wineasio.dll
6.401 [ERROR]  ASIO Error: WineASIO does not return error messages

6.401 [INFO]  Destroying AsioSharedHost - dll: wineasio.dll
6.401 [ERROR]  RSAsioDeviceEnum::UpdateAvailableDevices - failed.
6.401 [INFO]  DebugDeviceEnum::UpdateAvailableDevices - 0 render devices, 0 capture devices

Having no more debugging info, I tried running Rocksmith again with more verbose launch options.

PROTON_LOG=1 %command%

Then, when inspecting Proton log file at ~/steam-221680.log, an interesting bit showed up.

======================
Proton: 1675326504 proton-7.0-6e
SteamGameId: 221680
Command: ['/run/media/mmcblk0p1/SteamLibrary/steamapps/common/Rocksmith2014/Rocksmith2014.exe', '-uplay_steam_mode']
Options: {'forcelgadd'}
depot: 0.20230222.42118
pressure-vessel: 0.20230220.0 scout
scripts: 0.20230220.0
soldier: 0.20230222.42118 soldier 0.20230222.42118
Kernel: Linux 5.13.0-valve36-1-neptune #1 SMP PREEMPT Mon, 19 Dec 2022 23:39:41 +0000 x86_64
======================

...

7414.932:0118:011c:trace:loaddll:build_module Loaded L"E:\\SteamLibrary\\steamapps\\common\\Rocksmith2014\\RS_ASIO.dll" at 0FF40000: native
7415.291:0118:011c:trace:loaddll:build_module Loaded L"C:\\windows\\system32\\wineasio.dll" at E1AA0000: builtin
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
exec of JACK server (command = "/usr/bin/jackd") failed: No such file or directory
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Unable to open a JACK client as: Rocksmith2014
7421.319:0118:011c:trace:loaddll:free_modref Unloaded module L"C:\\windows\\system32\\wineasio.dll" : builtin
7421.328:0118:011c:trace:loaddll:build_module Loaded L"C:\\windows\\system32\\wineasio.dll" at E1AA0000: builtin
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Unable to open a JACK client as: Rocksmith2014
7421.329:0118:011c:trace:loaddll:free_modref Unloaded module L"C:\\windows\\system32\\wineasio.dll" : builtin

This log file confirmed that both wineasio & rs_asio DLLs loaded successfully.

Additionally, it seems like running Rocksmith directly from Steam results in some missing audio related socket file. This explains why wineasio complains about no devices available - since it is not able to connect to pipewire.

However, there is an interesting solution available which I found by complete coincidence.

Running the Game

After some tinkering, I found a way to make both audio & Steam auth work (without cracking anything).

First, start Rocksmith from Steam with the following launch options.

PROTON_LOG=1 PROTON_DUMP_DEBUG_COMMANDS=1 %command%

This instructs Proton to dump a game launch script at /tmp/proton_deck/run.

#!/bin/bash
#Run game or given command in environment

cd "/run/media/mmcblk0p1/SteamLibrary/steamapps/common/Rocksmith2014"
DEF_CMD=("/run/media/mmcblk0p1/SteamLibrary/steamapps/common/Rocksmith2014/Rocksmith2014.exe" "-uplay_steam_mode")
PATH="/home/deck/.local/share/Steam/steamapps/common/Proton 7.0/dist/bin/:/usr/bin:/bin" \
    TERM="xterm" \
    WINEDEBUG="-all" \
    WINEDLLPATH="/home/deck/.local/share/Steam/steamapps/common/Proton 7.0/dist/lib64//wine:/home/deck/.local/share/Steam/steamapps/common/Proton 7.0/dist/lib//wine" \
    LD_LIBRARY_PATH="/home/deck/.local/share/Steam/ubuntu12_64/video/:/home/deck/.local/share/Steam/ubuntu12_32/video/:/home/deck/.local/share/Steam/steamapps/common/Proton 7.0/dist/lib64/:/home/deck/.local/share/Steam/steamapps/common/Proton 7.0/dist/lib/:/usr/lib/pressure-vessel/overrides/lib/x86_64-linux-gnu/aliases:/usr/lib/pressure-vessel/overrides/lib/i386-linux-gnu/aliases" \
    WINEPREFIX="/home/deck/.local/share/Steam/steamapps/compatdata/221680/pfx/" \
    WINEESYNC="1" \
    WINEFSYNC="1" \
    SteamGameId="221680" \
    SteamAppId="221680" \
    WINEDLLOVERRIDES="steam.exe=b;dotnetfx35.exe=b;dotnetfx35setup.exe=b;beclient.dll=b,n;beclient_x64.dll=b,n;d3d11=n;d3d10core=n;d3d9=n;dxgi=n;d3d12=n" \
    STEAM_COMPAT_CLIENT_INSTALL_PATH="/home/deck/.local/share/Steam" \
    WINE_LARGE_ADDRESS_AWARE="1" \
    GST_PLUGIN_SYSTEM_PATH_1_0="/home/deck/.local/share/Steam/steamapps/common/Proton 7.0/dist/lib64/gstreamer-1.0:/home/deck/.local/share/Steam/steamapps/common/Proton 7.0/dist/lib/gstreamer-1.0" \
    WINE_GST_REGISTRY_DIR="/home/deck/.local/share/Steam/steamapps/compatdata/221680/gstreamer-1.0/" \
    MEDIACONV_AUDIO_DUMP_FILE="/home/deck/.local/share/Steam/steamapps/shadercache/221680/fozmediav1/audiov2.foz" \
    MEDIACONV_AUDIO_TRANSCODED_FILE="/home/deck/.local/share/Steam/steamapps/shadercache/221680/transcoded_audio.foz" \
    MEDIACONV_VIDEO_DUMP_FILE="/home/deck/.local/share/Steam/steamapps/shadercache/221680/fozmediav1/video.foz" \
    MEDIACONV_VIDEO_TRANSCODED_FILE="/home/deck/.local/share/Steam/steamapps/shadercache/221680/transcoded_video.foz" \
    "/home/deck/.local/share/Steam/steamapps/common/Proton 7.0/dist/bin/wine64" c:\\windows\\system32\\steam.exe "${@:-${DEF_CMD[@]}}"

Running /tmp/proton_deck/run script from terminal makes both audio & Steam activation work reliably!

At this point, I had crackling sound from my Scarlett Focusrite 2i2 audio interface which was fixed by amending the script to include PIPEWIRE_LATENCY env variable.

...
    PIPEWIRE_LATENCY="256/48000" \
    "/home/deck/.local/share/Steam/steamapps/common/Proton 7.0/dist/bin/wine64" c:\\windows\\system32\\steam.exe "${@:-${DEF_CMD[@]}}"

I think I found the proper buffer size of 256 by inspecting pw-top entries when the game was running. The standard recommendation to try 48/96/192 as buffer size for Focusrite 2i2 didn't work correctly.

As a side note, it might be a good idea to save /tmp/proton_deck/run under a different path. Otherwise it will be overwritten the next time Rocksmith is run from Steam. Also, the generated script doesn't contain any env vars defined in game launch options by default.

Summary

The way of launching Rocksmith on Steam Deck as described in the guide, when using Steam installation defaults and custom terminal script, results for me in either Steam auth/profile/(C)DLC working or wineasio working with the audio interface at all.

By running Rocksmith from Steam with PROTON_DUMP_DEBUG_COMMANDS=1 %command% launch option, it is possible to generate a Proton script that works flawlessly. It is unknown, why the very same Proton works from terminal script, and doesn't work from Steam directly. (pipewire/jack socket connection problem might be a good lead.)

Debug output can be produced with PROTON_LOG=1 %command% launch option, to verify wineasio & rs_asio are registered and running. Solving the pipewire/jack socket issue would allow it to run without resorting to customized Proton scripts. (Maybe Steam runtime misses/doesn't see pipewire-jack client libs? or it is some container isolation problem?)

Gaming mode might be a bit more tricky to figure out, as the default Deck audio devices need to be disabled from Desktop mode anyway. But solving the socket issue would also possibly enable Gaming mode setup. (I can smell HDMI related issues already.)

What Next

@theNizo Should we extend the Steam Deck guide? I could try integrating relevant info as a PR.

Someone more knowledgeable might be able to tinker with custom Proton version and patch audio socket issue.

Anyway, back to my bass. Thanks! ❤️

theNizo commented 1 year ago

First of all, thank you very much for the work and the debug info. You'll be credited.

Now, this still doesn't resolve the issue why wineasio doesn't work when an application is launched from Steam, but this is a solution that could replace JustInCaseWeNeedIt

One note, could it be possible to generate the "correct" script by using PROTON_LOG=1 PROTON_DUMP_DEBUG_COMMANDS=1 PIPEWIRE_LATENCY="256/48000" %command% for Steam launch options? (The difference being pipewire latency added)

There's a lot of overlapping information between the guides, which is why they are generated from building pieces that can be found in the src folder (I hope that's documented good enough). If you're quicker than me (I don't have time immediately), you can do either one the following:

Siarkowy commented 1 year ago

Wow, thanks for such a quick response!

One note, could it be possible to generate the "correct" script by using PROTON_LOG=1 PROTON_DUMP_DEBUG_COMMANDS=1 PIPEWIRE_LATENCY="256/48000" %command% for Steam launch options? (The difference being pipewire latency added)

I tried this but sadly, no lunch options are propagated to the generated script. One might try running PIPEWIRE_LATENCY="256/48000" /tmp/proton_deck/run from terminal. However my gut feeling is, the env variable will not be propagated to Steam properly.

Best to move the original Proton script somewhere else and amend it with PIPEWIRE_LATENCY so everything is contained in one place, in my opinion.

There's a lot of overlapping information between the guides, which is why they are generated from building pieces that can be found in the src folder (I hope that's documented good enough). If you're quicker than me (I don't have time immediately), you can do either one the following:

Let me try looking into this the following days.

Siarkowy commented 1 year ago

I tried this but sadly, no lunch options are propagated to the generated script. One might try running PIPEWIRE_LATENCY="256/48000" /tmp/proton_deck/run from terminal. However my gut feeling is, the env variable will not be propagated to Steam properly.

Quick update, my gut feeling was wrong! It is enough to regenerate the script from Steam and run from terminal:

PIPEWIRE_LATENCY="256/48000" /tmp/proton_deck/run

This might be the most reproducible way to run things with minimal changes needed.

(Also, tried hacking this up to run in Lutris but since it's in its own flatpak on Steam Deck, it makes no sense. I would ditch the mention of Lutris in Steam Deck guide altogether to be fair, aside from how useful of a tool it is.)

theNizo commented 1 year ago

since it's in its own flatpak on Steam Deck, it makes no sense.

Didn't think of this since I don't own a Steam Deck, but I see your point.

Siarkowy commented 1 year ago

Also added /tmp/proton_deck/run as a non Steam game, with following launch options:

PIPEWIRE_LATENCY="256/48000" %command%

No need for terminal anymore! This makes it at most a two click process:

Not sure if Steam counts playtime correctly but this is peak UX now.

theNizo commented 1 year ago

I just noticed a few things about the path /tmp/proton_deck/run.

/tmp ist obviously temporary. AFAIK, this is actually stored in your RAM. The second part is proton_$USER The file name run sounds really generic

so I would recommend to copy it to steamapps/common and calling it something like "rocksmith-launcher":

cp /tmp/proton_$USER/run $STEAMLIBRARY/steamapps/common/rocksmith-launcher.sh

Also added /tmp/proton_deck/run as a non Steam game

I also thought about trying this as well when I first saw this issue and it's kind of ridiculus (launch it from Steam? Well yes, but actually no). But if it works, I'll take it ^^

You might even make the entry pretty with something from SteamGridDB

theNizo commented 1 year ago

The non-important stuff first ^^ (so that I don't forget)

make the entry on steam pretty

hero - the art you see above the "play" button logo - usually text that you see at the same place icon - shown in desktop mode in steam to the left of the name grid - cover art, seen in big picture mode


game properties -> select an icon right below the text "shortcut" - rename the game to something pretty too, eg. "Rocksmith 2014 - Launcher" right click where the hero would be -> set custom background navigate to $HOME/.steam/steam/userdata/<number>/config/grid/ there's a file that represents the hero. you need the number of that (it represents the game's ID). copy the grid in this folder and name it p.png or whatever file ending you have.

I would recommend making the shortcut look different than the game so you can see which is which.

theNizo commented 1 year ago

Seems like I was quicker, now I just need to fix everything I broke.

Siarkowy commented 1 year ago

Btw we can output the Proton script outside of /tmp using another variable.

PROTON_DEBUG_DIR Root directory for the Proton debug scripts, /tmp by default.

Maybe something like the following works (didn't test yet)?

PROTON_DUMP_DEBUG_COMMANDS=1 PROTON_DEBUG_DIR=~/.rocksmith-launcher %command%
theNizo commented 1 year ago

This would create the proton_$USER folder in the given directory, along with the other files in it.

We could either do that and specify another folder, or copy it like it is now.

Since we only need one file from the debug info to start the game, I would opt for copying from /tmp, but I'm open to other opinions too.

theNizo commented 1 year ago

I'll close the issue now, since the main thing is resolved. Thank you for all the information.

but I'm open to other opinions too.

You can still do that of course

Siarkowy commented 1 year ago

Sure thing; in the end I opted for the following launch options in my Steam Deck setup.


Rocksmith 2014 - Steam game entry

Launch Options

PROTON_LOG=1 PROTON_DUMP_DEBUG_COMMANDS=1 PROTON_DEBUG_DIR=~/.rocksmith2014 %command%

Rocksmith 2014 Launcher - non Steam game entry

Launch Options

PIPEWIRE_LATENCY="256/48000" %command%

Target Path

/home/deck/.rocksmith2014/proton_deck/run

Adjust to taste. Cheers!

theNizo commented 1 year ago

After switching to onboard audio instead of the random sound card I use, as well as opening pavucontrol and keeping it open, I can finally start the game reliably.

I should really write a troubleshooting page at this point.

Siarkowy commented 1 year ago

Just a heads up; after any SteamOS update (which most recently shipped like 3 days ago), it is necessary to reinstall wine-staging & copy DLLs/SOs over again, since all OS customizations are wiped clean.

I spent far too much time the other day debugging the changed setup - instead of just redoing it from scratch. Posting my Rocksmith install script - https://gist.github.com/Siarkowy/f834658f4903058992f4a1247ec0a6d6

theNizo commented 1 year ago

Sounds great. Shoud I copy that, or link to your gist?

One question, do you have to disable readonly mode again after the update? Because I didn't see it in this script.