scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

scrcpy broken for Linux/Ubuntu?

Open sunarowicz opened this issue 1 year ago • 3 comments

  • [x] I have read the FAQ.
  • [x] I have searched in existing issues.

Environment

  • OS: Ubuntu 22.04.3 LTS aarch64 and Ubuntu 22.04 x86_64
  • scrcpy version: 2.3.1
  • installation method: manual build
  • device model: [Xiaomi] POCO M2012K11AG and NOKIA TV box
  • Android version: 13 (phone) and 11 (TV box)

Describe the bug scrcpy lags and skips a lot of frames:

tux@rock5b ~> SDL_VIDEODRIVER=wayland scrcpy --tcpip=192.168.1.110 --print-fps
scrcpy 2.3.1 <https://github.com/Genymobile/scrcpy>
INFO: Connecting to 192.168.1.110:5555...
INFO: Connected to 192.168.1.110:5555
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 2.3 MB/s (66007 bytes in 0.027s)
[server] INFO: Device: [Xiaomi] POCO M2012K11AG (Android 13)
INFO: Renderer: opengl
INFO: OpenGL version: 3.3 (Compatibility Profile) Mesa 23.0.0-devel
INFO: Trilinear filtering enabled
INFO: [FFmpeg] Picture format is yuv420p.
INFO: Texture: 1080x2400
INFO: [FFmpeg] Decoder noticed an info change
rga_api version 1.9.3_[0]
INFO: FPS counter started
INFO: 7 fps (+5 frames skipped)
INFO: 22 fps (+14 frames skipped)
INFO: 10 fps (+48 frames skipped)
INFO: 4 fps (+44 frames skipped)
INFO: 30 fps (+26 frames skipped)
INFO: 21 fps (+26 frames skipped)
INFO: 10 fps (+8 frames skipped)
INFO: 2 fps (+1 frames skipped)
INFO: 20 fps (+19 frames skipped)
INFO: 14 fps (+16 frames skipped)
INFO: 12 fps (+12 frames skipped)
INFO: 16 fps (+10 frames skipped)

Please note:

  • This does happen in the same way on USB connection as well as via WiFi (two different ones, at home and at work).
  • This does happen in the same way in Ubuntu running on the Arm SBC as well as in Ubuntu running in the VirtualBox VM on the x86_64 machine.
  • This does happen in the same way with different devices, the POCO phone as well as the NOKIA 8010 TV box (via WiFi only in this case).
  • This is not the case of the latest version 2.3.1 only. I have the same experience with the older versions too. To be honest I thought this is the way how scrcpy works until I tried scrcpy in Windows today.

To sum it up, it does the same in all Ubuntu/aarch64/x86_64/USB/WiFi/phone/TV box scenarios I used/tested scrcpy in.

But on Windows 11 with the same (phone) device via USB or WiFi the scrcpy 2.3.1 runs very smoothly with no skipped frames!

I guess the culprit could be in the very low transfer rate in Ubuntu, see the 2.3 MB/s only above. At the same time, OS, device, connection I can achieve much higher speeds for adb push:

tux@rock5b ~> adb pull /sdcard/Download/boot/boot.img
/sdcard/Download/boot/boot.img: 1 file pulled. 33.2 MB/s (134217728 bytes in 3.857s)

Also on Windows with the same device via USB or WiFi the scrcpy reports 30 - 90 MB/s transfer rates.

While I was searching the web for solution I found many screens provided by Linux users showing the similar low transfer rates like in my case, e.g.:

  • https://github.com/Genymobile/scrcpy/issues/2597
  • https://www.tecmint.com/scrcpy-connect-android-linux/
  • https://www.cnx-software.com/2023/03/13/scrcpy-2-0-android-screen-mirroring-and-control-utility-for-pcs-released-with-audio-forwarding-support/

But on the other hand I also found some sporadic cases, like the following one from the Arch Linux, showing the rates I cannot believe to according to my personal experience:

  • https://github.com/Genymobile/scrcpy/issues/4120

Is there something wrong with scrcpy in Ubuntu?

sunarowicz avatar Feb 07 '24 23:02 sunarowicz

It's probably a problem with graphics drivers. Try with --render-driver=software.

Or maybe the decoder, but that would be surprising. If you record (scrcpy --record=file.mp4) and play with vlc, is the recorded file playback smooth?

I guess the culprit could be in the very low transfer rate in Ubuntu, see the 2.3 MB/s only above.

Doesn't matter, it's just the bit rate reported by adb for pushing the server (a very small file).

rom1v avatar Feb 08 '24 00:02 rom1v

Thank you for looking at this. I tried your hint on using the software renderer, but it doesn't have any substantial impact. There is a slightly improvement, but really negligible. It still skips a ton of frames.

The screen record looks exactly as what I see in the scrcpy window, no visible difference.

I already checked that I'm using the correct version of ffmpeg for the Rockchip based SBC I run scrcpy at and that the Mali-G610 (Panfrost) renderer is in use.

sunarowicz avatar Feb 08 '24 21:02 sunarowicz

The screen record looks exactly as what I see in the scrcpy window, no visible difference.

Given that you get a lot of frames skipped in scrcpy logs, that's unexpected.

Could you play the recorded file on another computer? (or on a phone)

rom1v avatar Feb 08 '24 22:02 rom1v

Just want to let know that the problem has solved by its own. I used the scrcpy again after couple of days and it runs pretty fine as for now. Although it still skips some frames from time to time, it is finally usable now. The interesting thing is that I did nothing towards solving the problem (because I had no idea what to do). Only applied the system updates as I usually do. Below is the current scrcpy output. The absence of the FFmpeg messages is the only difference.

tux@rock5b ~> SDL_VIDEODRIVER=wayland scrcpy --tcpip=192.168.1.110 --print-fps
scrcpy 2.3.1 <https://github.com/Genymobile/scrcpy>
INFO: Connecting to 192.168.1.110:5555...
INFO: Connected to 192.168.1.110:5555
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 2.6 MB/s (66007 bytes in 0.025s)
[server] INFO: Device: [Xiaomi] POCO M2012K11AG (Android 13)
INFO: Renderer: opengl
INFO: OpenGL version: 3.3 (Compatibility Profile) Mesa 23.0.0-devel
INFO: Trilinear filtering enabled
INFO: Texture: 1080x2400
INFO: FPS counter started
INFO: 32 fps (+9 frames skipped)
INFO: 31 fps
INFO: 27 fps
INFO: 34 fps
INFO: 15 fps
INFO: 20 fps

sunarowicz avatar Mar 07 '24 22:03 sunarowicz