pegasus-frontend icon indicating copy to clipboard operation
pegasus-frontend copied to clipboard

Bug: Steam games relaunches the frontend while launching game

Open PaddyCo opened this issue 5 years ago • 46 comments

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

PaddyCo avatar Apr 06 '19 21:04 PaddyCo

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 avatar Apr 07 '19 16:04 mmatyas

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?

PaddyCo avatar Apr 10 '19 22:04 PaddyCo

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.

mmatyas avatar Apr 11 '19 17:04 mmatyas

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 🙂

PaddyCo avatar Apr 12 '19 18:04 PaddyCo

@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!

LightningXCE avatar Apr 19 '20 17:04 LightningXCE

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.

ToxicCrack avatar Sep 21 '20 10:09 ToxicCrack

Yes, that might work for now.

mmatyas avatar Sep 21 '20 17:09 mmatyas

+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!

ScottESanDiego avatar May 09 '21 02:05 ScottESanDiego

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 avatar Dec 09 '21 18:12 MrMajeeka

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

MrMajeeka avatar Dec 09 '21 18:12 MrMajeeka

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?

ThaC2027 avatar Sep 01 '22 04:09 ThaC2027

nice post like it

inqalab avatar May 06 '23 06:05 inqalab

"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.

LightningXCE avatar May 06 '23 07:05 LightningXCE

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?

jahtim avatar Feb 26 '24 06:02 jahtim

Is there a fix for this on macOS?

ianrispin avatar Mar 29 '24 23:03 ianrispin