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

Custom Command: Allow Using Steam Linux Runtime with Custom Commands #1124

Merged
merged 14 commits into from
Jun 16, 2024

Conversation

sonic2kk
Copy link
Owner

@sonic2kk sonic2kk commented Jun 16, 2024

Adds the ability to use the Steam Linux Runtime with Custom Commands. This should help with compatibility, as Proton is not intended to be used to run games without the Steam Linux Runtime.

This functionality should improve compatibility with custom commands, especially Proton custom commands. This should also mean that, effectively, using a custom command, with ONLY_CUSTOMCMD enabled, and with the Steam Linux Runtime option from this PR enabled, allows the custom command to act as a full replacement for the default Steam executable. There are some caveats and limitations (no integration with Steamworks as usual, mod managers won't respect this, etc) but in my testing it acts as a smooth drop-in replacement strategy now even in edge-cases where this didn't work before.

This currently works, but there is no option for this on the UI, it is hardcoded with __DEBUG_CUSTCMD_SLR in the code.


Note: The implementation here may serve as a basis for using the SLR with Winetricks, see #860.


TODO:

  • Add checkbox for toggling Steam Linux Runtime
    • Needs tested!!!!
  • Add support for Native Linux SLR (currently only Scout 1.0, as 3.0 has slightly different logic needed to fetch, would need handled sepatately as this PR only handles integrating the current SLR logic)
  • Update langfiles
  • Version bump

EDIT: The checkbox has been added, and the option for this (CUSTOMCMD_USESLR) will be enabled by default. This is because it is supposed to improve compatibility. Proton also requires the SLR; many things work without it on some systems but it's still meant to be used. With Native Linux commands, it is unnecessary, but can still be very useful except for things like scripts.

So for broad compatibility, this is enabled by default, but can be disabled in cases where it causes issues. For example it may get in the way of inter-process communication, and it would prevent scripts from accessing things on PATH (as it would be isolated to the container).

The tooltip notes the compatibility benefit and briefly illustrates some limitations.

@sonic2kk sonic2kk marked this pull request as draft June 16, 2024 00:20
@sonic2kk
Copy link
Owner Author

Tested and this works with native games now without breaking Proton games! The log is also correct, it will log when it has a native game and when it's building a log for a Proton game.

I confirmed the Steam Linux Runtime is used by checking for additional pressure-vessel-* processes that appear when launching custom commands with this PR, and verified that without this PR those processes disappear.

Now we have to implement this option on the UI.

@sonic2kk
Copy link
Owner Author

Replaced the hardcoded debug var __DEBUG_CUSTCMD_SLR with a config variable CUSTOMCMD_USESLR.

This PR is untested with this change.

@sonic2kk
Copy link
Owner Author

Tested with SA-Mod-Manager as a Custom Command for Sonic Adventure 2, the SLR is enabled/disabled as expected.

@sonic2kk
Copy link
Owner Author

sonic2kk commented Jun 16, 2024

Wine custom commands cannot be ran for native Linux titles as there is no compat data folder for them to run inside of, forgot about that...

So testing Proton custom commands with Native titles doesn't work, but that is to be expected.

@sonic2kk
Copy link
Owner Author

Verified that this worked with To the Moon where a custom command was set as the game start script and a different native Linux game in a different directory. The Steam Linux Runtime was enabled and disabled as expected.

sonic2kk added 7 commits June 16, 2024 05:23
Very hacky logic atm and untested,
not sure if unsetting logic will
remove SLR where it is needed.

This needs a LOT of testing!
don't feel like dealing with this now,
and not relevant to this PR, but I
want to put them somewhere \:P
for config file
@sonic2kk sonic2kk force-pushed the customcmd-slr-ver-2 branch from 4d85433 to d5c94e8 Compare June 16, 2024 04:25
@sonic2kk sonic2kk marked this pull request as ready for review June 16, 2024 04:25
@sonic2kk
Copy link
Owner Author

I think testing for this PR is dev complete now, the functionality seems to work. It is in very good shape from my testing.

The main things left are:

  • Retouch the logic for extProtonRun SLR fetching, can it be as simple as the logic for Native Linux SLR in launchCustomProg?
    • I wrote the logic in extProtonRun quite a while back, but wrote the logic in launchCustomProg with a fresh mind, so perhaps I need to revisit extProtonRun's implementation (I left a comment about this in the code as well)
  • Give the implementation here another pass to make sure it's fine
  • Update langfiles & version bump as usual

@sonic2kk
Copy link
Owner Author

sonic2kk commented Jun 16, 2024

In future we should look into integrating the Crash Guesser, or some kind of Crash Guesser, with custom commands IF ONLY_CUSTOMCMD is enabled. A custom program that I'm testing with, SAModManager, sometimes fails to start with Wine. It would be nice to quickly be able to retry this.

We should also look into integrating PROTON_LOG for custom commands. This is not super important but it would give a little bit more Proton insight, and would be some extra sugar on top of the goal of making ONLY_CUSTOMCMD essentially replace the game start command but with some more flexibility.

@sonic2kk
Copy link
Owner Author

Did some more testing to make sure this played nicely with regular custom command usage (Custom Command, then game after Custom Command exits), Fork Custom Command, and Inject Custom Command. I realised most of my testing last night was for Only Custom Command.

I tested this with a retouch of the extProtonRun logic for setting the Steam Linux Runtime and it works fine, it is much cleaner now! I will push this shortly.

The last thing I want to test a bit more is native custom programs with Proton games; the inverse doesn't work - you can't run Proton custom commands with native games because native games don't have a prefix; we could theoretically generate one but that's probably unnecessary. I don't see a case either where you'd need to run a Windows binary to do something with a native title.

But the case of running a native custom command with a Proton game does exist. I think it works fine, and logically it should work because launchCustomProg will check if an executable is Windows or not, and if it's not Windows it will fall through in launchCustomProg. But doesn't hurt to test some more.

Also improve logging for launching native custom programs
@sonic2kk
Copy link
Owner Author

Running custom programs with Proton will not use the native SLR but the Proton one. Seems we will have to force this in some way.

setSLRReap is fetching the SLR based on the same logic that it would for Proton titles, because all of the set variables are for Proton. We need to find a way to make setSLRReap (or rather, setNonGameSLRReap which calls it for us) to get the native SLR. Probably the simplest way is to give it a flag.

@sonic2kk
Copy link
Owner Author

We could actually just refactor for force Proton var in setSLRReap and setNonGameSLRReap to take a value of 2 to state that it should force native. We could make it SLRFORCETYPE.

Going to test such a refactor locally and see if it works.

@sonic2kk
Copy link
Owner Author

Seems like I got it working locally.

  • Native standalone games still use the right SLR
  • Proton standalone games still use the right SLR
  • Native games with native custom commands still use the right SLR, forked, injected, and used together
  • Proton games with Proton custom commands still use the right SLR, forked, injected, and used together
  • Proton games with native custom commands are now correctly forced to use the native SLR, and the Proton game still runs the SLR fetcher and correctly gets the required SLR when forked/launched after a native custom command

Will push the latest changes in a bit.

@sonic2kk
Copy link
Owner Author

Functionality has been tested pretty extensively and it seems to work without introducing regressions, implementation is all good as well from another scan. ShellCheck is green, langfiles are updated, version is bumped, this is good to merge!

Could probably merge this somehow in future.
@sonic2kk sonic2kk merged commit 19fd787 into master Jun 16, 2024
2 checks passed
@sonic2kk sonic2kk deleted the customcmd-slr-ver-2 branch June 23, 2024 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant