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

1 second latency, random ghost touches when playing games, lag lag lag lag #2691

Open
yyebra28 opened this issue Oct 8, 2021 · 13 comments
Open

Comments

@yyebra28
Copy link

yyebra28 commented Oct 8, 2021

I play Call of Duty: Mobile and I've decided to start streaming. Not until I give up because scrcpy wasn't working properly. Lag would greet me if I start opening the batch file, latency is horrendous like 500ms before input is sent to the PC, the thing would randomly press buttons when I'm playing (like it would shoot my gun even tho I'm not even doing anything). Overall I have a very, very bad time with scrcpy and I think I should discontinue my plans. Hoping for some tips.

@rom1v
Copy link
Collaborator

rom1v commented Oct 8, 2021

How do you stream? OBS?

If you run scrcpy over USB without capturing with OBS, does it lag? If you don't play a game (just do simple things like scrolling in a webpage, etc.). If it works fine, then try without OBS, but in a game. And with OBS, but not in a game. Which one is ok?

In the scrcpy window, press Alt+i to log frame rate, it will print info about the frame rate every second in the console.

If you record (scrcpy --record file.mp4), is the resulting file laggy?

Does scrcpy --no-key-repeat improve the input lag?

@iamSlightlyWind
Copy link

iamSlightlyWind commented Oct 10, 2021

This is simply a performance issue.
If you are running scrcpy on slow (2.4ghz/far) wifi, try switching to 5ghz or ethernet, or usb.
If your pc is too weak (which probably isn't the case, but your android device can be), try changing the decoder to see which works best.
What caused the lag prob are background tasks, which should be plenty in Windows

My laptop: 10yo E6420, i7 2760QM (1 single heat pipe, overheat whenever it can), 8gb ddr3 1666, ac7260
(stock: i5 2430m, 4gb ddr3 1666, something 2.4ghz can't remember)
Tablet: Samsung Galaxy Tab S7

The laptop is shit, but running on lxde(on ubuntu), 5ghz wifi, 1600x900, I got 60fps constantly without drop, and latency was not very noticeable (was also running discord app in background with chrome and code-server)
footage: https://imgur.com/a/B2A8bwd (dex on hdmi dummy, thanks to #898 ) (this was scrcpy max 50fps, but on later tests, 60fps give the absolute same performance)

edit: turn on sound to hear the mouse click

@rdp
Copy link

rdp commented Jan 11, 2022

I get some lag as well, OS X 2018 macbook pro, connected via USB., FWIW.

2022-01-11 13:15:01.824 scrcpy[3363:109195] INFO: 10 fps (+20 frames skipped)
2022-01-11 13:15:02.820 scrcpy[3363:109195] INFO: 0 fps
2022-01-11 13:15:03.822 scrcpy[3363:109195] INFO: 0 fps
2022-01-11 13:15:04.821 scrcpy[3363:109195] INFO: 14 fps (+15 frames skipped)
2022-01-11 13:15:05.821 scrcpy[3363:109195] INFO: 0 fps
2022-01-11 13:15:06.820 scrcpy[3363:109195] INFO: 0 fps
2022-01-11 13:15:07.821 scrcpy[3363:109195] INFO: 13 fps (+21 frames skipped)

@deoxal
Copy link

deoxal commented Mar 10, 2022

try changing the decoder to see which works best. What caused the lag prob are background tasks, which should be plenty in Windows

How do you do that?

My specs aren't that good but that's for playing new AAA games so I don't think hardware is my issue. I think the latency in the USB protocol is just too high for video streaming.

For reference, I have a i7-3770, GTX 560 TI, I'm running Mint 20.3, my phone is from 2019 - a Zenfone 6 with 8 GB of RAM running Android 11, and I used a USB 3 port.

Even if I limit the FPS to 10, frames I still get dropped frames regularly. When I started using the program, I was averaging 60 FPS though and now I'm averaging 50 and I have no idea why. Funny thing is previously I had more apps running on my phone and PC when I was getting 60 than when I was averaging 50 because I rebooted both my phone and PC. And I restarted scrcpy multiple times too.

@iamSlightlyWind
Copy link

How do you do that?

Read before asking.

I actually haven't successfully tried scrcpy on windows, but compared to your desktop there, the laptop I which I used for scrcpy was dog shit. You should first try a ubuntu 20.04 live iso, extract it to a fat32 partition on your drive (4-5gb is prob more than enough), and select it as your boot device in bios. Upon landing on the desktop, open a terminal and

sudo snap install scrcpy
scrcpy #preferrably with arguments in the readme, go for 100mb bandwidth, your monitor native res at 60fps.

I would expect minor but noticeable latency without any kind of noticeable frame drop. If the experience is flawless, then I suspect windows is messing with scrcpy, not the hardware.

@rom1v
Copy link
Collaborator

rom1v commented Mar 10, 2022

I think the latency in the USB protocol is just too high for video streaming.

Definitively not.

Even if I limit the FPS to 10, frames I still get dropped frames regularly.

What is the output of scrcpy --print-fps?

(You should do your tests without capturing with OBS or similar.)

If you record (scrcpy --record file.mp4), is the recorded file laggy?

@deoxal
Copy link

deoxal commented Mar 13, 2022

Here's the FPS read out. No idea why it's averaging 20 instead of 60 like before.

20 fps (+1 frames skipped)
INFO: 20 fps
INFO: 19 fps
INFO: 21 fps
INFO: 20 fps
INFO: 20 fps
INFO: 20 fps
INFO: 20 fps
INFO: 20 fps
INFO: 20 fps
INFO: 20 fps
INFO: 20 fps
INFO: 20 fps
INFO: 20 fps
INFO: 20 fps
INFO: 21 fps
INFO: 19 fps
INFO: 21 fps
INFO: 20 fps
INFO: 20 fps
INFO: 19 fps
INFO: 20 fps
INFO: 21 fps
INFO: 19 fps
INFO: 20 fps
INFO: 20 fps

Here's a recording I did with scrcpy, didn't use OBS or similar.

https://youtu.be/XIWQWopUxIQ

@rom1v
Copy link
Collaborator

rom1v commented Mar 13, 2022

This is the rate as it is captured on the device, either because the rendering is at 20fps, or because the encoder could not encode frames fast enough.

@deoxal
Copy link

deoxal commented Mar 13, 2022

@iamSlightlyWind

I would expect minor but noticeable latency without any kind of noticeable frame drop. If the experience is flawless, then I suspect windows is messing with scrcpy, not the hardware.

Did you miss that I said I'm running Mint 20.3? Windows is not messing with scrcpy because I'm not running Windows.

The version of scrcpy does not recognize the --encoder option. I'm guessing that's because the version in apt is too old: 1.12.1.

I went to the release section of this repo but there is no Linux build and the source code doesn't have a Linux build option or include Mono.

I could live boot Ubuntu but I have other things going on. I just thought I'd give this a shot is all.

@rom1v
Copy link
Collaborator

rom1v commented Mar 13, 2022

the source code doesn't have a Linux build option or include Mono.

??

You can build & install the latest version from sources easily: https://github.com/Genymobile/scrcpy/blob/master/BUILD.md#simple

@iamSlightlyWind
Copy link

Any distro is fine. You havent told us what arguments you include with your command yet.

scrcpy #preferrably with arguments in the readme, go for 100mb bandwidth, your monitor native res at 60fps.

For the record, since you are running a full fledge distro rather than a live iso, there shouldnt be anything stopping you from building the latest scrcpy and try it.

@rdp
Copy link

rdp commented Apr 18, 2022

Update: on my pixel 3a it used to have like 1.5s lag, 10 fps. 30 fps if I used the camera app. Something changed (software? I replaced the screen as well), now it's 0 fps, then 60 fps if I 'do something' (i.e. movement on the screen, the way it should be), and the keyboard input used to feel super slow, now it's super responsive. I think this was all with 1.21 and it's fast now on windows or linux hosts, so I'm happy, thanks!

@rom1v
Copy link
Collaborator

rom1v commented Apr 18, 2022

I replaced the screen as well

If the screen was broken/damaged, then it was probably the issue: #1285

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

5 participants