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

Rumble event listening effectively caps framerate #14

Closed
maxdirocco opened this issue Aug 16, 2024 · 8 comments · Fixed by #15
Closed

Rumble event listening effectively caps framerate #14

maxdirocco opened this issue Aug 16, 2024 · 8 comments · Fixed by #15

Comments

@maxdirocco
Copy link

maxdirocco commented Aug 16, 2024

Hello! First of all, thank you for your hard work on this project.

I am using Sunshine on Fedora Linux 40.

GPU: RX 6900 XT
CPU: i7 14700K

Since this library has been adopted into Sunshine as of:
LizardByte/Sunshine#2606

I have noticed that when my controller is rumbling continuously, the framerate is effectively capped at 50FPS. I believe I have narrowed down this issue to:

std::this_thread::sleep_for(20ms); // TODO: configurable?

When modifying this line and recompiling Sunshine, the "capped" framerate changes to the inverse of the specified delay (provided the GPU / CPU can keep up, of course), e.g.

std::this_thread::sleep_for(20ms); // (1 / 20ms) = 50 FPS
std::this_thread::sleep_for(13ms); // (1 / 13ms) = 77 FPS

I am not sure what the proper fix for this is, but I've gone as low as 3ms without noticing any issues.

Please let me know if more information is required.

Thanks and have a great day.

@ABeltramo
Copy link
Member

Thanks for the very detailed report, I'm in the middle of other stuff, but I'll check it out properly in the next few days.
Can you just confirm that this issue wasn't present in Sunshine before inputtino?

@maxdirocco
Copy link
Author

Hi, thanks for getting back to me!

When compiling Sunshine with the cmake flag SUNSHINE_USE_LEGACY_INPUT (LizardByte/Sunshine@a11b69c), this issue is not present. This, plus the above experiment with changing the sleep duration suggests to me that the issue is tied to inputtino.

I'm not too familiar with the code here, but I'll conduct some additional experiments on my end.

Beyond that, if more information is required (logs, a video demonstration of the issue, etc.), I will do my best to produce that ASAP.

@ABeltramo
Copy link
Member

Thanks for confirming, that should narrow it down then. Just one last question: is this happening on any game or is it specific to some games? It seems odd that that part is causing a slowdown since it's running on a different thread but maybe the game (or the kernel itself) is accumulating those rumble events until we process them? 🤔

@maxdirocco
Copy link
Author

Yeah I also found that strange.

I've been able to reproduce this on the following games:

  • Watch_Dogs (2014)
  • LEGO Star Wars: The Skywalker Saga (2022)

Both running on the latest version of Proton Experimental. I have yet to find a native Linux game in my library with a lot of rumble events.

I also tried Helldivers II, and I couldn't seem to reproduce the issue.

I will test more games / Proton configurations later today and will report back here.

@maxdirocco
Copy link
Author

A little bit more information:

  • Kernel 6.10.3
  • Gnome 46 (also tested KDE Plasma 6, same issue)

I tested another game, Dying Light (2015), and observed this issue in both the native Linux port and when running the game through proton.

Disabling "Vibration" in the in-game settings menu alleviates the issue.

@ABeltramo
Copy link
Member

I've just pushed a potential fix, when you've got a chance could you give it a go on your setup? This should completely remove the busy loop and potentially be even better than the old Sunshine implementation.

@maxdirocco
Copy link
Author

Seems like the fix works! I'm no longer experiencing frame drops in the above games.

Please let me know if there's anything else you need from me.

Thank you so much for the work you put into this project!

@ABeltramo
Copy link
Member

Thank you for the incredibly detailed issue, it was a very easy fix thanks to all the info that you've provided!

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 a pull request may close this issue.

2 participants