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

What I should do in the my app to proper closing stream? #880

Open
dukobpa3 opened this issue Oct 13, 2022 · 8 comments
Open

What I should do in the my app to proper closing stream? #880

dukobpa3 opened this issue Oct 13, 2022 · 8 comments

Comments

@dukobpa3
Copy link

Is your feature request related to a problem? Please describe.
Some apps not proper recognising when closed so I need to close stream manually.

Describe the solution you'd like
In case this app is my own – how I can proper close it with closing stream also if opened?

Describe alternatives you've considered
I can close streaming process manually from app on exit, but in this case Stream closes in some kind of exception like "Stream interrupted". I think there should be more intelligent way to do it more clear?

(It is not actually feature request but hadn't other options :) Thanks! )

@cgutman
Copy link
Member

cgutman commented Oct 17, 2022

Yeah, it's a limitation or design decision of GeForce Experience when streaming manually added games. It doesn't track the game you're streaming to determine if it closes.

As a workaround, you can use the option in Moonlight called "Quit app on host PC after ending stream". That will automatically send the quit command when you stop streaming using the Ctrl+Alt+Shift+Q or Start+Select+L1+R1 key combos.

@dukobpa3
Copy link
Author

Can I do the same but from app side?

@kurac338
Copy link

kurac338 commented Oct 17, 2022

Yeah, it's a limitation or design decision of GeForce Experience when streaming manually added games. It doesn't track the game you're streaming to determine if it closes.

As a workaround, you can use the option in Moonlight called "Quit app on host PC after ending stream". That will automatically send the quit command when you stop streaming using the Ctrl+Alt+Shift+Q or Start+Select+L1+R1 key combos.

If I am not mistaken, this would also cause the application to quit on the stream host in case of an unexpected freeze/interruption/connection drop of the stream? BTW (I don't mean to hijack the thread) I have been experiencing this freezing behavior lately. Not sure if it is a known issue.

Back on topic @dukobpa3 I have created some wrapper Batch scripts for Windows. In essence, I wrap the desired process (some_game.exe) and periodically pool / monitor if this process is still active. If it no loner exists, I trigger the kill command for the NVidia streaming process on the host machine. In turn the stream client (moonlight-qt) than knows there was an actual connection termination.

This has an added benefit that it works around game launch issues for some games. In particular if a game first displays a banner / splash-screen, and than restarts the .exe process to actually launch the game.

I can share the scripts here if you would like. From what I've seen my .bat files have a minimal impact on host CPU usage, and I would gladly let the community improve them :)

@dukobpa3
Copy link
Author

@kurac338 I found the same solution already and using it for now.
But I dislike behaviour with exiting by "connection interrupted" message. Wanted some more intelligent.

@cgutman
Copy link
Member

cgutman commented Oct 23, 2022

If I am not mistaken, this would also cause the application to quit on the stream host in case of an unexpected freeze/interruption/connection drop of the stream? BTW (I don't mean to hijack the thread) I have been experiencing this freezing behavior lately. Not sure if it is a known issue.

No, we only quit if the disconnection was intentional. If it was unexpected (due to network error or something), we don't send the quit command.

Freezing issues are most likely caused by moonlight-stream/nvidia-gamestream-issues#27

@dukobpa3
Copy link
Author

dukobpa3 commented Oct 26, 2022

Main question still relevant )))

How can I say from my app to stream that it closing?
Maybe I can do something in case using moonlight and not original GS client. Send some command somewhere? Or some special exit code or at least something?

Now I'm doing it a bit dirty, but it works
(OnExit actions inside my app)

$args = [System.Environment]::GetCommandLineArgs()
if($args.Contains('--gsexit')) {
    Get-Process -Name "nvstreamer" | Stop-Process
}

This solution have two cons:
– "Connection Iterrupted error" message (not matter actually but annoying :) )
– Huge lag on exit, because waiting for interruption timeout

Can I maybe close nvstreamer with some command instead of killing process? Something like nvstreamer.Quit()

@dukobpa3
Copy link
Author

dukobpa3 commented Oct 26, 2022

Finally got it

Bit hacking solution but works for me.

Something like described here
https://forum.xda-developers.com/t/guide-adding-custom-gamestream-games-to-your-homescreen.3739689/

\Users\YourUserName\AppData\Local\Nvidia\NvBackend\ApplicationOntology\data\fingerprint.db

<Fingerprint name='your_app'>
    <DisplayName>Your App</DisplayName>
    <Version name='generic'>
      <CMSID>500000001</CMSID> <!-- Any unique ID. I set just with the same length as others -->
      <CMSVersion>1</CMSVersion>
      <Distributor>Standalone</Distributor>
      <Icon>Your.App.exe</Icon> <!-- I don't know how proper set icons and images, for now it is without cover in GS clients -->
      <Image>Your.App.exe</Image>
      <Launch>Your.App.exe</Launch>
      <IsAutomatable>0</IsAutomatable> <!-- If 1 t–en will be available on GFE App on desktop as supported but for real support it needs some lua wrapper, I can't decompile it properly for now so don't know how to make my own -->
      <IsStreamingSupported>1</IsStreamingSupported> <!-- important for being available in GS client -->
      <StreamingAutomatedLaunch>1</StreamingAutomatedLaunch>
      <StreamingCmdLine>Your.App.exe</StreamingCmdLine>
      <StreamingCaption>Your App</StreamingCaption>
      <StreamingClassName>Your App</StreamingClassName>
      <Files>
        <File name='Your.App.exe' />
      </Files>
    </Version>
</Fingerprint>

Something like that.
I wasn't doing any hacks with apk etc, but with this hack app at least closing and starting properly.
Also it is in the GS Clients like NvidiaShield games or Moonligt, and not present on GFE optimized apps list

Next I'll fix issue with Icons and Covers.
And also I thing it will be broken after next GFE update, so I'll add some automation script to reset settings...

@dukobpa3
Copy link
Author

Screenshot 2022-10-26 at 15 53 05

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

No branches or pull requests

3 participants