Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
104.37k stars 10.15k forks source link

Device is found but no screen displayed (Fedora, SDL 2.0.24) #3431

Open luckyvictor opened 1 year ago

luckyvictor commented 1 year ago

I have had USB debug enabled, and windows can find my device. Scrcpy can also find my device, however it never shows a pop up screen of my device screen, below is everything it outputs before the cmd closes itself.

scrcpy-ser... file pushed, 0 skipped. 17.8 MB/s (41159 bytes in 0.002s) [server] INFO: Device: OPPO CPH1919 (Android 11)

Sorry it seems to be a very simple problem, but i don find any thing here or google, I guess nobody experience such problem.

Environment

rom1v commented 1 year ago

Try with a lower resolution (scrcpy -m1024) or with another encoder.

luckyvictor commented 1 year ago

tried lower resolution, doesn't work. tried 3 encoders, none of them work as well scrcpy --encoder 'OMX.qcom.video.encoder.avc' scrcpy --encoder 'c2.android.avc.encoder' scrcpy --encoder 'OMX.google.h264.encoder'

I used another software named Vysor and I can see my android screen on my PC, so pretty sure my PC is ready, just some settings in Scrcpy has not been configured correctly.

Astrosp commented 1 year ago

would you share screenshot...

luckyvictor commented 1 year ago

image

luckyvictor commented 1 year ago

any one has any suggestion?

rom1v commented 1 year ago

Does it record with screenrecord?

adb shell screenrecord /sdcard/file.mp4
adb pull /sdcard/file.mp4
o-data commented 1 year ago

What driver did you use @luckyvictor ? SCRCPY can't find my Oppo device

luckyvictor commented 1 year ago

how to do the screenrecord? is it under scrcpy?

luckyvictor commented 1 year ago

I don't what driver, it just finds it, I am using windows 10.

yunopie commented 1 year ago

I have similar issues. The output thinks it is working, but the picture doesnt appear. Tried the different encoders and lower resolution.

OS: Fedora 36 scrcpy version: [1.24] installation method: [dnf copr zeno/scrcpy] device model: motorola moto g(6) Android version: [9]

This just started the past week when I updated booted previous (5.18.17) kernel and still didnt work. Today i updated to 5.18.19 and that didnt help.

yunopie commented 1 year ago

There were recently SDL2 and mesa package updates .. i wonder if thats what caused this issue

jremond commented 1 year ago

I have similar issues. The output thinks it is working, but the picture doesnt appear. Tried the different encoders and lower resolution.

OS: Fedora 36 scrcpy version: [1.24] installation method: [dnf copr zeno/scrcpy] device model: motorola moto g(6) Android version: [9]

This just started the past week when I updated booted previous (5.18.17) kernel and still didnt work. Today i updated to 5.18.19 and that didnt help.

Same issue for me, OS: Fedora 36 scrcpy version: [1.24] installation method: [dnf copr zeno/scrcpy] device model: Xiaomi Mi A2 Lite Android version: [10]

-> scrcpy 
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
WARN: Could not disable minimize on focus loss
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 540.5 MB/s (41159 bytes in 0.000s)
[server] INFO: Device: Xiaomi Mi A2 Lite (Android 10)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 22.1.7
INFO: Trilinear filtering enabled
INFO: Initial texture: 1080x2280
jremond commented 1 year ago

Does it record with screenrecord?

adb shell screenrecord /sdcard/file.mp4
adb pull /sdcard/file.mp4

screenrecord works for me, I can read the mp4 file on my computer without issue

rom1v commented 1 year ago

@jremond Try with another encoder: https://github.com/Genymobile/scrcpy#encoder

jremond commented 1 year ago

@jremond Try with another encoder: https://github.com/Genymobile/scrcpy#encoder

[server] ERROR: Try to use one of the available encoders:
[server] ERROR:     scrcpy --encoder 'OMX.qcom.video.encoder.avc'
[server] ERROR:     scrcpy --encoder 'c2.android.avc.encoder'
[server] ERROR:     scrcpy --encoder 'OMX.google.h264.encoder'

Trying with all 3 encoders still fails, no window.

scrcpy -r file.mp4

does work but I still don't see any window on my computer.

rom1v commented 1 year ago

Does the recorded file work?

jremond commented 1 year ago

Yes, I did some actions using the phone directly and the video shows everything correctly. It does seem like it's only the scrcpy window that is missing.

rom1v commented 1 year ago

Then do not use the COPR package, but install manually: https://github.com/Genymobile/scrcpy/blob/master/BUILD.md#simple

jremond commented 1 year ago

Same issue with a manual install, I did retry all the steps (3 different encoders, scrcpy -r command) Still no window showing up.

genodeftest commented 1 year ago

I can confirm this issue on Fedora 36 with two different almost-stock android phones (on Android 9 and 11) and the following software installed:

SDL2-2.24.0-1.fc36.x86_64
android-tools-31.0.2-3.fc36.x86_64
ffmpeg-libs-5.0.1-3.fc36.x86_64
libavdevice-5.0.1-3.fc36.x86_64
glibc-2.35-15.fc36.x86_64
libusb1-1.0.25-8.fc36.x86_64

After downgrading SDL2 to SDL2-2.0.20-3.fc36.x86_64 by using dnf downgrade SDL2, scrcpy works fine again. As far as I remember, SDL2-2.0.22-3.fc36.x86_64 also worked fine. The update to 2.24.0 has been pushed to Fedora's stable repositories on 2022-08-23

I don't know how/whether SDL2 is being used and/or updated on Windows but this may help @yunopie and @jremond as a first workaround.

I have some experience in debugging using gdb, so if you need some more info please tell me (though it may take some time).

PS: If you wonder how I isolated SDL2, here is the Fedora-specific description how I found out: I did not remember that I updated scrcpy lately (dnf info update scrcpy | less will help you remember when the last update has been installed). I also remembered that I did not update Android on the two phones lately, so it had to be some configuration (don't remember changing any configuration lately) or other dependency on my computer. Getting dependencies of scrcpy can be done with rpmreaper scrcpy (press the r key) or dnf repoquery --requires --resolve scrcpy. Then I tried downgrading them. SDL2 was the only package updated lately so it could be downgraded and that worked around this issue for me.

genodeftest commented 1 year ago

Possibly related, on Linux:

Possibly related, on Windows:

jremond commented 1 year ago

dnf downgrade SDL2-2.0.20-3.fc36.x86_64 solves the problem for me, thanks @genodeftest !

yunopie commented 1 year ago

using dnf downgrade SDL2, scrcpy works fine again.

Can confirm. The dnf downgrade of SDL2 fixed the window not showing up.

Im even on 5.19.4 kernel

huang-jy commented 1 year ago

Just adding that

SDL_VIDEODRIVER=x11 scrcpy

worked for me, without having to downgrade any packages

yunopie commented 1 year ago

I updated my SDL2 back to SDL2-2.24.0-1.fc36.x86_64 to try using the variable

SDL_VIDEODRIVER=x11

I updated the scrcpy.desktop file so it can launch it again.

Exec=bash -c "SDL_VIDEODRIVER=x11 scrcpy -m 740"

luckyvictor commented 1 year ago

so for my original problem, which is on windows, what would be the solution please?

rom1v commented 1 year ago

how to do the screenrecord? is it under scrcpy?

Nope, open a terminal (click on open_a_terminal_here.bat from the scrcpy folder), and execute the commands from https://github.com/Genymobile/scrcpy/issues/3431#issuecomment-1229454579

luckyvictor commented 1 year ago

/system/bin/sh: screenrecord: inaccessible or not found

this is the error i have

rom1v commented 1 year ago

Weird, all Android ROMs are expected to have screenrecord available.

sgros commented 1 year ago

/system/bin/sh: screenrecord: inaccessible or not found

this is the error i have

This is the same error I'm getting when trying 'adb shell screenrecord'. This is Huawei P30 Pro, if that matters.

fernandoherreradelasheras commented 1 year ago

This issue happening Fedora 36 is a bug on SDL2 2.24.0 when using wayland and compiled with libdecor support. I have reported it here: https://github.com/libsdl-org/SDL/issues/6204

TLDR: SDL_WaitEvent() blocks and doesn't process SDL_USEREVENTs pushed before the window is shown (and in general, the libdecor_dispatch call there breaks heavily user events)

A workaround would be using SDL_PollEvent() instead.

winkelnp commented 1 year ago

Same issue happening with my Fairphone4 with Android 11 on Fedora 36 GNOME with Wayland

derino commented 1 year ago

Had the same problem. Changing the encoder as suggested above, but also installing these multimedia codecs solved the problem.

gilice commented 1 year ago

Hey! For me, on NixOs the solution to this same issue was very weird: sudo scrcpy works, but simply srcpy didn't.

genodeftest commented 1 year ago

Hey! For me, on NixOs the solution to this same issue was very weird: sudo scrcpy works, but simply srcpy didn't.

Please don't run scrcpy with sudo. You should avoid running any application with higher privileges as it would weaken security and safety concepts of your operating system. Scrcpy for example runs video codecs which are used as an attack surface sometimes.

gilice commented 1 year ago

While that is good advice in general, it is what works for me. I didn't have time to debug it properly by reading dmesg yet, maybe I'll update this comment if I find out the cause.

masiv1001 commented 8 months ago

Can't downgrade (running Fedora 38), SDL_VIDEODRIVER=x11 scrcpy does not work. Installed media codecs as suggested above but still not working.

genodeftest commented 8 months ago

The fedora issue described above was fixed before SDL2 version 2.26.0, so it has been fixed almost a year ago, which I can confirm on my machine (even with very old hardware that only supports OpenGL 2.1). On Fedora 38, you should not be able to run a version older than that, so the issue you are seeing is something different. I recommend you try without SDL_VIDEODRIVER=x11 and if that does not help, I recommend opening a new issue. Also, please provide a lot more information, i.e., which software versions you are running (of scrcpy, SDL2, android-tools, ffmpeg-libs, libavdevice, mesa), on which interface you are connected (USB?) and the output of scrcpy from a shell.

Anyway, most of this thread has diverged a lot from the first comment, so I suggest this thread should be closed.