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

[Feature Request] [Windows] Suspend child processes #206

Closed
unphased opened this issue Feb 12, 2024 · 8 comments
Closed

[Feature Request] [Windows] Suspend child processes #206

unphased opened this issue Feb 12, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@unphased
Copy link

unphased commented Feb 12, 2024

i tried it last year in windows but it sadly did not work in many games. for example RDR2.

i hope to have better luck with it in Linux, but it would help me to reason about how it may interact with a given application if I had a working understanding of what tools and interfaces with the operating are being used to suspend processes.

@Merrit
Copy link
Owner

Merrit commented Feb 12, 2024

Games with onerous DRM and/or anti-cheat software will often not work, specifically because those things work to block outside software from affecting them. To my knowledge RDR2 is one of those; the solution in these cases is to complain to the company about their use of draconian and anti-consumer software like that. It may work better on Linux since it will be suspending the Linux emulation process rather than the native Windows process.

As to how it works, essentially it boils down to:

  • Linux: uses kill to suspend and resume the processes
  • Windows: uses the undocumented NtSuspendProcess and NtResumeProcess win32 api calls

@unphased
Copy link
Author

Thank you.

You bring up a good point that DRM middlewares routinely do unsavory things that can interfere with normal operation of the computer and this is an example. A developer may easily implement an architecture that foils this scheme, for example a simple watchdog process could shut things down if the main process is found to be unresponsive.

I may suggest a feature, if we could (and it usually is easy to) identify a number of processes associated with some app, being able to suspend them all and then resume them all simultaneously might provide more compatibility.

My hunch from playing around with this and other tools on windows (where we have access to the likes of process monitor/process lasso) is that this might do the trick. On Linux I'd also be able to do quick hacks with shell scripts, but hadn't explored it.

@Merrit
Copy link
Owner

Merrit commented Feb 12, 2024

The Linux implementation already suspends and resumes all associated processes:

Future<bool> _suspendChildren(int parentPid) async {
final childPids = await _getChildPids(parentPid);
if (childPids == null) return true;
log.i('Suspending child pids of $parentPid. Child pids: $childPids');
for (var childPid in childPids) {
bool successful;
// Suspend further children recursively.
successful = await _suspendChildren(childPid);
if (!successful) return false;
// Suspend the original child.
successful = _suspendPid(childPid);
if (!successful) return false;
}
return true;
}

The Windows implementation does not as yet do so. It may indeed help with such situations, though I could also see it causing instability given how flaky Windows reacts to such things already.

@Merrit Merrit changed the title can you explain in documentation the operating principle of this app? [Feature Request] [Windows] Suspend child processes Mar 8, 2024
@Merrit Merrit added the enhancement New feature or request label Mar 8, 2024
@Merrit
Copy link
Owner

Merrit commented Mar 26, 2024

With the games that have given you problems, and specifically Red Dead 2; have you tried running Nyrna as administrator?

@unphased
Copy link
Author

unphased commented Mar 26, 2024

that is something i did not think to try, i am very excited to try that next time!

i dont game very much these days outside of low spec games on my steam deck and valve has completely solved the pausing issue there by making suspend really awesome. although, if you forget the device for two weeks it will certainly die by then, and you still lose progress.

i'll be sure to report back and work with you on issues. my RDR2 install and savegames died with my inland 4TB NVMe drive however. it's not certain i will play that game again. it's spectacular but the pace is slow. my plan is to find a savegame online for near where i was and continue as i really cannot justify starting fresh.

worst case when i get a nvidia 5090 once that comes out ill certainly be hunting for demanding games to run at 4k120 and rdr2 will be back on the radar.

@Merrit
Copy link
Owner

Merrit commented Mar 30, 2024

Sorry to hear about your save being lost! Hardware failures are the worst!

Since this sounds a lot like #197, I will close this for now. If you encounter the issue again while running Nyrna as admin, feel free to reopen or start a new issue. :)

@Merrit Merrit closed this as completed Mar 30, 2024
@unphased
Copy link
Author

unphased commented Apr 4, 2024

Tell ya what, i have no issues so far running Nyrna as admin. I think you may want to give this at least as a suggestion in the readme. I will test more and try to compare with and without running as admin, but so far the experience is really great. I have 64GB in this machine and it is a game changer. It also seems like the OS can swap idle processes out, so it sure looks like I can run 2, 4, probably even more games at the same time, we'll see if I can get up to 8 or 10, it's going to be fun! Even if task manager is lying to me, since most any modern game requires less than 16GB, having 64GB means I can have at least 4.

Maybe this is going to fuel my ADD further, but it really completely changes the experience and allows gaming sessions to have a huge amount more variety when you can pause and resume a number of (presumably non-multiplayer) games at will. That it applies to any application is great too, since being able to pause operations like renders so you can squeeze in some other work simply lets you get more utility out of the hardware. I especially like how I can start a game (or 4) and rapidily switch between work and play, I do believe this engages my brain better and can make me more productive or at least more efficient on the work slice of that time.

Thank you so much for making this tool, I also really like how it will auto focus the game you unpause to bring you right back into the action.

Being able to run a bunch of games at the same time and switch between them freely is like getting gifted a computer from the future. As a dev I always knew the OS ought to be capable of unlocking better ux like this. But most people don't realize and there's no incentive for vendors to provide the UI.

Update: I ran into a crash trying to resume the latest Ratchet & Clank game. But chrome was already wigging out on OOM issues at this point so I need to test more.

@Merrit
Copy link
Owner

Merrit commented Apr 5, 2024

I am glad to hear it is useful to you! 💙

A suggestion to run as admin was added with v2.18.0 if suspend/resume fails.

I also added a mention to the README just now with 03f584f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants