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

Bug: Steam games relaunches the frontend while launching game #442

Open
PaddyCo opened this issue Apr 6, 2019 · 15 comments
Open

Bug: Steam games relaunches the frontend while launching game #442

PaddyCo opened this issue Apr 6, 2019 · 15 comments
Labels
bug-thirdparty A bug or issue in a third-party application ext-steam Steam-specific issue

Comments

@PaddyCo
Copy link

PaddyCo commented Apr 6, 2019

When I start a game from Steam through the frontend (default settings) it seems to trigger the exit game event while the game is still launching, causing some issues like the frontend running in the background (with videos still playing etc)

I think the reason is probably because when running steam.exe with the steam://rungameid/XXXXX parameter it simply returns exit code 0 once it has finished launching the game, which makes the frontend think the game has exited?

Here are the relevant lines from my lastrun.log:

2019-04-06T21:40:58 [i] Executing command: "c:/program files (x86)/steam/steam.exe" steam://rungameid/801630
2019-04-06T21:40:58 [i] Process 2872 started
2019-04-06T21:40:58 [i] ----------------------------------------
2019-04-06T21:40:58 [i] ----------------------------------------
2019-04-06T21:40:58 [i] The external program has finished cleanly, with exit code 0

Same problem on two different computers (Both running Windows 10) with all games I've tested so far

@mmatyas
Copy link
Owner

mmatyas commented Apr 7, 2019

Yes, unfortunately there's no way to detect when the game launched by Steam starts on closes -- frontends can only access Steam itself and ask it to launch the game. When Steam is already open this completes instantly, causing the issue you've seen.

Sadly starting from a closed-Steam state won't entirely solve the problem, because Steam keeps running after a game closes, meaning you can't properly return to Pegasus either.

These issues have been reported to Valve already (eg. Valve/steam-for-linux repo, issue 1721), but there was no interest in the past few years to improve it.

@mmatyas mmatyas added ext-steam Steam-specific issue bug-thirdparty A bug or issue in a third-party application labels Apr 7, 2019
@PaddyCo
Copy link
Author

PaddyCo commented Apr 10, 2019

That's a bummer since the Steam integration in Pegasus is extremely good except for this one issue

Since it looks like Valve won't be fixing it on their end anytime soon I started looking into some other way of launching steam games reliably, there was a workaround posted in the the issue you referred to by Github user ejthill which I liked the sound of so I adapted it a little and made a very quick & simple proof-of-concept (Windows only)

Basically what this launcher does is:

  1. Runs steam.exe steam://rungameid/APPID
  2. Keep checking the foreground window, as long as it is Steam (or the launcher itself) it will keep checking. When it detects another window it will mark that as the game window
  3. Now we keep checking that the game window is open, the second it closes we simply exit the launcher

I would be willing to look into implementing something like this (ofcourse way more robust and cross-platform) directly into the frontend, or alternatively add some optional configuration option that lets the user configure what command is used to launch steam games if either of those sounds like a good idea to you?

@mmatyas
Copy link
Owner

mmatyas commented Apr 11, 2019

Yes I've seen these workarounds, but I had some issues:

  • I'm not sure if it'd work for games that have a custom launcher (eg. a self-updater, configuration app or something like that). In this case the frontend would continue when such launchers are closed.
  • I'm not sure if it's possible to do it in a cross platform way. Depending on the platform (eg secure Linux with Wayland) perhaps a program might not have the right to query other program's window.
  • Requires large amounts and mutually exclusive windowing-system specific code. I'm mainly thinking about X11/Wayland here, but I think there was also some API difference between Windows 7 and 8/10 too, which would need either separate builds or runtime library loading.
  • It requires active waiting. OSes don't provide signals when another program's window is closed (as far as I know), so it's required to check continuously in a loop whether the game is still running.
  • Steam stays in the background when the game quits. At least for me on Linux, when I start a game from the command line, it never gets into the foreground.

I was also thinking about another approach, that we should check the process tree and see if Steam has any non-built-in child processes running. In theory that should be reliable, but it also have most of the same problems as above.

Another idea, perhaps a Steam wrapper script could be set, which Pegasus would call instead of the Steam binary. One could set it to a script like the one you linked, but if that itself has bugs, there might be no way to return to the frontend. I'm also not sure if it'd work on macOS as things are launched differently there.

Now these are only how I see things at the moment. However if you have a better idea or a working implementation I'd be always happy to take a look on it.

@PaddyCo
Copy link
Author

PaddyCo commented Apr 12, 2019

After reading your reply and looking at it a little closer, it's safe to say I underestimated the complexity of the task 😅

But yes, the idea of letting the user set their own Steam wrapper script sounds like the best way forward, I'll try my hand at implementing it and submitting a PR and you can decide if it makes sense to merge or not 🙂

@LightningXCE
Copy link

@PaddyCo apologies for the ping, but I'm hitting this issue now and was wondering if you had a binary built anywhere for your launcher?

Cheers, thanks!

@ToxicCrack
Copy link

As this is still a problem, how about that: If one starts a steam game, the video stops playing as long as no other game gets selected. This would easily work on all platforms.

@mmatyas
Copy link
Owner

mmatyas commented Sep 21, 2020

Yes, that might work for now.

@ScottESanDiego
Copy link

+1 to the @ToxicCrack idea. I finally got around to configuring Pegasus on my gaming VM, and this issue makes Stream integration effectively unusable, since Pegasus does a great job finding videos for everything!

@mmatyas mmatyas pinned this issue Jun 2, 2021
@MrMajeeka
Copy link

steam-launcherv1.0.zip

I fixed this issue by writing this launcher for steam.

Instructions are in the zip file.

You can add individual games and it will launch them, monitor them to allow Pegasus to go back to fullscreen when you are finished with the game.

This works whether Steam is open or not.

DJ.

@MrMajeeka
Copy link

I also have a working Battle.net system too. I'll upload that when I have made the code look prettier.

@ThaC2027
Copy link

ThaC2027 commented Sep 1, 2022

steam-launcherv1.0.zip

I fixed this issue by writing this launcher for steam.

Instructions are in the zip file.

You can add individual games and it will launch them, monitor them to allow Pegasus to go back to fullscreen when you are finished with the game.

This works whether Steam is open or not.

DJ.

Hi DJ,

Tried your launcher but received some errors even after using the correct version of the .net framework.
Do you have any updates using the latest framework?

In general, the issue remains - I can still hear the video for the Steam game playing in the background after launch.
Any updates on this issue?

@inqalab
Copy link

inqalab commented May 6, 2023

nice post like it

@LightningXCE
Copy link

"If you have purchased a game on Steam and found that it doesn't meet your expectations, you can request a refund. Steam offers a simple refund process that allows users to get their money back for any game they have purchased within a certain time frame. Here's how to refund a game on Steam:

1. Open the Steam client and go to the ""Help"" section.

2. Click on ""Steam Support.""

3. Click on the game that you want to refund.

4. Select the reason for the refund and provide additional information (if required).

5. Click on ""Submit Request.""

If your refund request is approved, the game's purchase price will be refunded to your Steam wallet or the original payment method, depending on your preference.

It's important to note that there are certain conditions that must be met for a refund to be approved. For example, you must have purchased the game within the last 14 days, and you must have played it for less than 2 hours. Additionally, some games may have specific refund policies that differ from the standard Steam policy.

For more information on how to refund a game on Steam, visit https://appuals.com/how-to-refund-a-game-on-steam/. By following these steps, you can get a refund for any game that doesn't meet your expectations and use the funds to purchase another game that you'll enjoy."

Not sure if you're in the right place here, or an AI bot mass replying to tickets, but this has nothing to do with what you are describing.

@TataTawa
Copy link

i just found a slight workaround, use the launch line in some metadata file:
launch: cmd /c start /b metal.bat steam://rungameid/123456789

metal.bat:
cmd /c %1
taskkill /IM Pegasus_latest.exe

it just lauches the steam game and kill pegasus process, so you need to relauches pegasus manually when needed.
ps , is it good option to have some hotkeys/cmd/url to freeze/unfreeze pegasus?

@ianrispin
Copy link

Is there a fix for this on macOS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-thirdparty A bug or issue in a third-party application ext-steam Steam-specific issue
Projects
None yet
Development

No branches or pull requests

10 participants