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

scrcpy not working after upgrading to latest version v2.3 #4477

Closed
2 tasks done
cyfrost opened this issue Nov 29, 2023 · 11 comments
Closed
2 tasks done

scrcpy not working after upgrading to latest version v2.3 #4477

cyfrost opened this issue Nov 29, 2023 · 11 comments

Comments

@cyfrost
Copy link

cyfrost commented Nov 29, 2023

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Ubuntu 22.04.3 LTS (x86_64) (Codename: Jammy)
  • scrcpy version: 2.3
  • installation method: Manual Build
  • device model: Google Pixel 6a (codename: Bluejay)
  • Android version: 13

Describe the bug
On a Linux shared VM (Digital Ocean Droplet), after upgrading to the latest version (2.3) from v2.2 last night, attempting to connect to the device throws an error from scrcpy with below message:

Command: scrcpy --tcpip=192.168.0.129:5555 --no-control --no-playback --video-source=display --audio-source=mic --display-buffer=200 --audio-buffer=200 --max-size=1024 --video-codec=h264 --audio-bit-rate=64000 --video-bit-rate=1M --no-clipboard-autosync --lock-video-orientation=0 --time-limit=1800 --record="test.mp4" --record-format=mp4

Output:

scrcpy 2.3 <https://github.com/Genymobile/scrcpy>
ERROR: Could not initialize SDL video: No available video device
ERROR: Could not start adb server

Scrcpy Version:

scrcpy 2.3 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.0.20 / 2.0.20
 - libavcodec: 58.134.100 / 58.134.100
 - libavformat: 58.76.100 / 58.76.100
 - libavutil: 56.70.100 / 56.70.100
 - libavdevice: 58.13.100 / 58.13.100
 - libusb: - / 1.0.25

Note: This does not happen in previous version v2.2 where the above command had worked fine.

I have tried to update the APT packages just to see if SDL has upgrades but all packages are up-to-date as reported by APT. Have tried rebooting but to no avail.

@rom1v
Copy link
Collaborator

rom1v commented Nov 29, 2023

#4361 (comment)

@cyfrost
Copy link
Author

cyfrost commented Nov 29, 2023

EDIT: the below steps should not be required and are discouraged from being performed. The issue identified was fixed and merged into the latest release thus requiring no additional fix from users.

Thanks @rom1v, your comment helped me fix this in the right direction (hopefully). I was able to fix this through the follow commands:

Based on what I see, the issue isn't likely because of scrcpy upgrade but rather with the system installed version of SDL

# First uninstall the current scrcpy version (for manual builds only)
# it is likely compiled with an old version of libsdl2 bundled in Ubuntu std repos
cd scrcpy/
sudo ninja -Cbuild-auto uninstall

# Remove the old libsdl2 packages shipped with ubuntu
sudo apt remove --purge libsdl2-2.0-0 libsdl2-dev

# Install the PPA that provides latest builds of SDL2 for Ubuntu (x86_64 only)
sudo add-apt-repository ppa:savoury1/multimedia
sudo apt update -y
# install dependencies again with updated versions
sudo apt install libsdl2-dev ffmpeg pkg-config libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libswresample-dev libusb-1.0-0 libusb-1.0-0-dev
# upgrade all packages as necessary
sudp apt upgrade -y

# Since mine is a manual build, switch to the cloned git repo of scrcpy and re-install it
cd scrcpy/
git reset --hard origin/master
git pull

# Install the latest release
# (look for the output: `Run-time dependency sdl2 found: YES 2.28.4`)
./install_release.sh

Profit! scrcpy should now work fine without reporting any errors from SDL.

If you're segfaulting, a system restart might help, or additionally try adb kill-server && adb start-server

Please note that the above PPA includes updated SDL packages only for x86_64 arch but not for arm64 (so if you have a Raspberry Pi or similar arm64 device, you'll need to build from source to get the latest build of SDL).

This would've been painfully hard if not for Rob Savoury's PPA, cheers to them!

Hopefully this helps!

PS: another gripe with Canonical for shipping ancient versions of packages in standard repos, about time to switch to Fedora!

Closing the issue for now, thanks @rom1v for all your help here!

@cyfrost cyfrost closed this as completed Nov 29, 2023
@rom1v
Copy link
Collaborator

rom1v commented Nov 29, 2023

You should not need a PPA. The version you were using was sufficient:

  • SDL: 2.0.20 / 2.0.20

i don't know why you had a problem with it (especially if it worked beforehand).

@cyfrost
Copy link
Author

cyfrost commented Nov 29, 2023

@rom1v That's what has been baffling me too, the version shipped in the repos (although very old) should be sufficient. It has never done this before and the SDL errors were out of the blue (probably has nothing to do with upgrading scrcpy)

@cyfrost
Copy link
Author

cyfrost commented Nov 29, 2023

@rom1v I would like to re-open this issue

I have a Raspberry Pi 4b running on Ubuntu 22.04.3 LTS (arm64), upgrading scrcpy from v2.2 to v2.3 seems to break SDL with the same error described in the original post (SDL No available video device). I manually uninstalled 2.3 and downgraded to 2.2 and it works just fine without any SDL errors. I suspect that the usage of SDL library might've changed in v2.3 leading to the error, would you please see if such is the case?

scrcpy v2.2 works fine here but not v2.3:

scrcpy v2.2 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.0.20 / 2.0.20
 - libavcodec: 58.134.100 / 58.134.100
 - libavformat: 58.76.100 / 58.76.100
 - libavutil: 56.70.100 / 56.70.100
 - libavdevice: 58.13.100 / 58.13.100
 - libusb: - / 1.0.25

Ubuntu 22.04.3 LTS running on Raspberry Pi 4B with SDL 2.0.20 installed from the standard repos

@cyfrost cyfrost reopened this Nov 29, 2023
@rom1v
Copy link
Collaborator

rom1v commented Nov 29, 2023

Check without this commit (introduced between 2.2 and 2.3): 5e59ed3

@rom1v
Copy link
Collaborator

rom1v commented Nov 29, 2023

upgrading scrcpy from v2.2 to v2.3 seems to break SDL with the same error described in the original post (SDL No available video device)

Did it work with scrcpy v2.2 without --no-playback (i.e. with a mirroring window)?

@cyfrost
Copy link
Author

cyfrost commented Nov 29, 2023

Check without this commit (introduced between 2.2 and 2.3): 5e59ed3

@rom1v yep, this commit is likely the reason for the issue as my command does not work with this commit (works fine before this commit was introduced).

Command:
scrcpy --tcpip=192.168.0.155:5555 --no-playback --no-audio --no-control --no-clipboard-autosync --max-size=1024 --video-bit-rate=1M --record="test1.mp4"

since I'm passing --no-clipboard-autosync, shouldn't we ignore initialising SDL subsystem then? (even if no-video and no-playback are passed)

Did it work with scrcpy v2.2 without --no-playback (i.e. with a mirroring window)?

Unfortunately I'm on a headless VM so removing --no-playback will fail as I have no display.

rom1v added a commit that referenced this issue Nov 29, 2023
The SDL video subsystem is required for video playback and clipboard
synchronization.

If neither is used, it is not necessary to initialize it.

Refs 5e59ed3
Refs 110b3a1
Refs #4418 <#4418>
Refs #4477 <#4477>
rom1v added a commit that referenced this issue Nov 29, 2023
The SDL video subsystem may be initialized so that clipboard
synchronization works even without video playback.

But if the video subsystem initialization fails (e.g. because no video
device is available), consider it as an error only if video playback is
enabled.

Refs 5e59ed3
Fixes #4477 <#4477>
@rom1v
Copy link
Collaborator

rom1v commented Nov 29, 2023

Please test branch issue4477, there are 2 commits:

  • one to disable video subsystem initialization if there is no video or control/clipboard_autosync
  • one to not consider video subsystem initialization failure as an error if video playback is disabled

Either of one would fix your specific issue, but I think both should be applied.

@cyfrost
Copy link
Author

cyfrost commented Nov 29, 2023

@rom1v Working fine in the branch, hoping it will be merged in master!

I agree that both of the fixes should be applied

Thanks for all your help here! Really appreciate it!

@cyfrost cyfrost closed this as completed Nov 29, 2023
@rom1v
Copy link
Collaborator

rom1v commented Nov 29, 2023

hoping it will be merged in master!

Yes, I merged the commits into dev, so they will be in the next release.

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

2 participants